diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0e2aa25..4287e3f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: - matrix: { ruby: ['2.7', '3.0', '3.1', '3.2', head] } + matrix: { ruby: ['3.0', '3.1', '3.2', head] } steps: - name: Check out code diff --git a/.rubocop.yml b/.rubocop.yml index ad8844e..0ab97e3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,7 +8,7 @@ inherit_gem: - rspec.yml AllCops: - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.0 Exclude: - dev/**/* - sample/**/* diff --git a/lib/recode/handler/prompt.rb b/lib/recode/handler/prompt.rb index d056908..843ce85 100644 --- a/lib/recode/handler/prompt.rb +++ b/lib/recode/handler/prompt.rb @@ -22,12 +22,12 @@ def apply? when 'q', "\u0003" say 'b`Quit`' raise Recode::Abort - when 'n' - say 'r`No`' - false - else + when 'y' say 'g`Yes`' true + else + say 'r`No`' + false end end end diff --git a/lib/recode/runner.rb b/lib/recode/runner.rb index 8c6a353..d16a53f 100644 --- a/lib/recode/runner.rb +++ b/lib/recode/runner.rb @@ -53,7 +53,7 @@ def changes end def files - @files ||= Dir["#{path}/**/*.{#{extensions.join ','}}"].sort + @files ||= Dir["#{path}/**/*.{#{extensions.join ','}}"] end def refresh_files diff --git a/recode.gemspec b/recode.gemspec index e40d0a5..b36317e 100644 --- a/recode.gemspec +++ b/recode.gemspec @@ -14,11 +14,17 @@ Gem::Specification.new do |s| s.homepage = 'https://github.com/dannyben/recode' s.license = 'MIT' - s.required_ruby_version = '>= 2.7.0' + s.required_ruby_version = '>= 3.0' s.add_runtime_dependency 'colsole', '>= 0.8.1', '< 2' s.add_runtime_dependency 'diffy', '~> 3.3' s.add_runtime_dependency 'mister_bin', '~> 0.7' s.add_runtime_dependency 'strings-inflection', '~> 0.1' - s.metadata['rubygems_mfa_required'] = 'true' + + s.metadata = { + 'bug_tracker_uri' => 'https://github.com/DannyBen/recode/issues', + 'changelog_uri' => 'https://github.com/DannyBen/recode/blob/master/CHANGELOG.md', + 'source_code_uri' => 'https://github.com/DannyBen/recode', + 'rubygems_mfa_required' => 'true', + } end diff --git a/spec/recode/command_spec.rb b/spec/recode/command_spec.rb index 9d54dd8..96a4a3b 100644 --- a/spec/recode/command_spec.rb +++ b/spec/recode/command_spec.rb @@ -33,22 +33,13 @@ end context 'with --prompt' do - it 'applies the refactor changes' do - allow($stdin).to receive(:getch).and_return('y') - - in_sample_dir do - expect { subject.run %w[Person to User in rb yml --prompt] } - .to output_approval('cli/refactor/person-user-prompt') - end - end - - context 'when answering no' do - it 'does not apply the changes' do - allow($stdin).to receive(:getch).and_return 'n' + context 'when answering yes' do + it 'applies the refactor changes' do + allow($stdin).to receive(:getch).and_return('y') in_sample_dir do expect { subject.run %w[Person to User in rb yml --prompt] } - .to output_approval('cli/refactor/person-user-prompt-no') + .to output_approval('cli/refactor/person-user-prompt') end end end @@ -65,6 +56,17 @@ end end end + + context 'when answering anything but quit or yes' do + it 'does not apply the changes' do + allow($stdin).to receive(:getch).and_return 'k' + + in_sample_dir do + expect { subject.run %w[Person to User in rb yml --prompt] } + .to output_approval('cli/refactor/person-user-prompt-no') + end + end + end end end end