<commit_before>#
# Methadone/Aruba "extensions"/"customizations"
#

When /^I get the version of "([^"]*)"$/ do |script_name|
  @script_name = script_name
  step %(I run `#{script_name} --version`)
end

Then /^the output should include the version$/ do
  step %(the output should match /v\\d+\\.\\d+\\.\\d+/)
end

Then /^the output should include the app name$/ do
  step %(the output should match /#{Regexp.escape(@script_name)}/)
end

Then /^the output should include a copyright notice$/ do
  step %(the output should match /Copyright \\(c\\) [\\d]{4} [[\\w]+]+/)
end

#
# Steps that interact with `git` (via `rugged`)
#

Given /^a git repo in directory "([^"]*)"$/ do |project_name|
  @pwd = File.join(current_dir, project_name)
  @repo = Rugged::Repository.init_at(@pwd, false)
end

Given /^a git repo in directory "([^"]*)" with files:$/ do |project_name, files_table|
  step %(a git repo in directory "#{project_name}")
  files_table.raw.each do |(file_path)|
    step %(an empty file named "#{File.join(project_name, file_path)}")
  end
end

#
# Steps that interact with `Dir.pwd`
#

When /^I run `([^`]*)` in a non-git working dir$/ do |cmd|
  working_dir = "foo/bar/qux_blegga"
  @dirs = [Dir.tmpdir] # sets Aruba::API.current_dir
  step %(I run `#{cmd}` in "#{working_dir}" directory)
end

When /^I run `([^`]*)` in a git working dir$/ do |cmd|
  working_dir = "foo/bar/qux_blegga"
  step %(a git repo in directory "#{working_dir}")
  step %(I run `#{cmd}` in "#{working_dir}" directory)
end

When /^I run `([^`]*)` in a git working dir with files:$/ do |cmd, files_table|
  working_dir = "foo/bar/qux_blegga"
  step %(a git repo in directory "#{working_dir}" with files:), files_table
  step %(I run `#{cmd}` in "#{working_dir}" directory)
end

When /^I run `([^`]*)` in a git working dir without ".gitconform"$/ do |cmd|
  step %(I run `#{cmd}` in a git working dir)
end

When /^I run `([^`]*)` in a git working dir with ".gitconform"$/ do |cmd|
  step %(I run `#{cmd}` in a git working dir with files:), Cucumber::Ast::Table.parse("| .gitconform |", nil, nil)
end

When /^I run `([^`]*)` in a sub\-directory of a git working dir with ".gitconform"$/ do |cmd|
  working_dir = "foo/bar/qux_blegga"
  step %(a git repo in directory "#{working_dir}" with files:), Cucumber::Ast::Table.parse("| .gitconform |", nil, nil)
  sub_dir = File.join(working_dir, "subdir")
  step %(I run `#{cmd}` in "#{sub_dir}" directory)
end

When /^I run `([^`]*)` in "([^"]*)" directory$/ do |cmd, working_dir|
  step %(a directory named "#{working_dir}")
  cd working_dir
  step %(I run `#{cmd}`)
  @dirs = ['tmp', 'aruba'] # reset Aruba::API.current_dir
end
<commit_msg>Major re-org/refactor of the step definitions<commit_after>#
# Methadone/Aruba "extensions"/"customizations"
#

When /^I get the version of "([^\042]*)"$/ do |cmd|
  @cmd = cmd
  step %(I run `#{cmd} --version`)
end

Then /^the output should include the version$/ do
  step %(the output should match /v\\d+\\.\\d+\\.\\d+/)
end

Then /^the output should include the app name$/ do
  step %(the output should match /#{Regexp.escape(@cmd)}/)
end

Then /^the output should include a copyright notice$/ do
  step %(the output should match /Copyright \\(c\\) [\\d]{4} [[\\w]+]+/)
end

When /^I run `([^\140]*)` in "([^\042]*)" directory$/ do |cmd, working_dir|
  step %(a directory named "#{working_dir}")
  cd working_dir
  step %(I run `#{cmd}`)
  @dirs = ['tmp', 'aruba'] # reset Aruba::API.current_dir
end

#
# Steps that interact with `git` (via `rugged`)
#

Given /^a git repo in directory "([^\042]*)"$/ do |repo_path|
  pwd = File.join(current_dir, repo_path)
  Rugged::Repository.init_at(pwd, false)
end

Given /^a git repo in directory "([^\042]*)" with files:$/ do |repo_path, files_table|
  step %(a git repo in directory "#{repo_path}")
  files_table.raw.each do |(file_path)|
    step %(an empty file named "#{File.join(repo_path, file_path)}")
  end
end

#
# Steps that set up a git repo before running a cmd
#

AD_HOC_REPO_PATH = "foo/bar/qux_blegga".freeze

When /^I run `([^\140]*)` in a non-git working dir$/ do |cmd|
  @dirs = [Dir.tmpdir] # sets Aruba::API.current_dir
  step %(I run `#{cmd}` in "#{AD_HOC_REPO_PATH}" directory)
end

When /^I run `([^\140]*)` in a git working dir$/ do |cmd|
  step %(a git repo in directory "#{AD_HOC_REPO_PATH}")
  step %(I run `#{cmd}` in "#{AD_HOC_REPO_PATH}" directory)
end

When /^I run `([^\140]*)` in a git working dir with files:$/ do |cmd, files_table|
  step %(a git repo in directory "#{AD_HOC_REPO_PATH}" with files:), files_table
  step %(I run `#{cmd}` in "#{AD_HOC_REPO_PATH}" directory)
end

When /^I run `([^\140]*)` in a git working dir without ".gitconform"$/ do |cmd|
  step %(I run `#{cmd}` in a git working dir)
end

When /^I run `([^\140]*)` in a git working dir with ".gitconform"$/ do |cmd|
  step %(I run `#{cmd}` in a git working dir with files:), Cucumber::Ast::Table.parse("| .gitconform |", nil, nil)
end

When /^I run `([^\140]*)` in a sub\-directory of a git working dir with ".gitconform"$/ do |cmd|
  step %(a git repo in directory "#{AD_HOC_REPO_PATH}" with files:), Cucumber::Ast::Table.parse("| .gitconform |", nil, nil)
  sub_directory = File.join(AD_HOC_REPO_PATH, "sub_directory")
  step %(I run `#{cmd}` in "#{sub_directory}" directory)
end

{'fraction_non_alphanumeric': 0.19145719145719145, 'fraction_numerical': 0.006615006615006615, 'mean_word_length': 4.073825503355705, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1361416', 'n_tokens_mistral': 2052, 'n_tokens_neox': 2015, 'n_words': 667}