diff options
-rw-r--r-- | lib/bundler/cli/gem.rb | 31 | ||||
-rw-r--r-- | spec/bundler/commands/newgem_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/support/path.rb | 18 | ||||
-rw-r--r-- | tool/bundler/rubocop_gems.rb.lock | 21 | ||||
-rw-r--r-- | tool/bundler/standard_gems.rb.lock | 31 |
5 files changed, 72 insertions, 31 deletions
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index a034aea324..e917ceb7d4 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -68,7 +68,7 @@ module Bundler :bundler_version => bundler_dependency_version, :git => use_git, :github_username => github_username.empty? ? "[USERNAME]" : github_username, - :required_ruby_version => Gem.ruby_version < Gem::Version.new("2.4.a") ? "2.3.0" : "2.4.0", + :required_ruby_version => required_ruby_version, } ensure_safe_gem_name(name, constant_array) @@ -166,11 +166,11 @@ module Bundler config[:linter] = ask_and_set_linter case config[:linter] when "rubocop" - config[:linter_version] = Gem.ruby_version < Gem::Version.new("2.4.a") ? "0.81.0" : "1.7" + config[:linter_version] = rubocop_version Bundler.ui.info "RuboCop enabled in config" templates.merge!("rubocop.yml.tt" => ".rubocop.yml") when "standard" - config[:linter_version] = Gem.ruby_version < Gem::Version.new("2.4.a") ? "0.2.5" : "1.0" + config[:linter_version] = standard_version Bundler.ui.info "Standard enabled in config" templates.merge!("standard.yml.tt" => ".standard.yml") end @@ -403,5 +403,30 @@ module Bundler def open_editor(editor, file) thor.run(%(#{editor} "#{file}")) end + + def required_ruby_version + if Gem.ruby_version < Gem::Version.new("2.4.a") then "2.3.0" + elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "2.4.0" + elsif Gem.ruby_version < Gem::Version.new("2.6.a") then "2.5.0" + else + "2.6.0" + end + end + + def rubocop_version + if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.81.0" + elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.12" + else + "1.21" + end + end + + def standard_version + if Gem.ruby_version < Gem::Version.new("2.4.a") then "0.2.5" + elsif Gem.ruby_version < Gem::Version.new("2.5.a") then "1.0" + else + "1.3" + end + end end end diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index 0a4e683a04..5ba513861c 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -569,7 +569,7 @@ RSpec.describe "bundle gem" do it "sets a minimum ruby version" do bundle "gem #{gem_name}" - expect(generated_gemspec.required_ruby_version).to eq(Gem::Requirement.new(Gem.ruby_version < Gem::Version.new("2.4.a") ? ">= 2.3.0" : ">= 2.4.0")) + expect(generated_gemspec.required_ruby_version.to_s).to start_with(">=") end it "requires the version file" do diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb index a98ef7c6cf..a73b3e699e 100644 --- a/spec/bundler/support/path.rb +++ b/spec/bundler/support/path.rb @@ -283,11 +283,25 @@ module Spec end def rubocop_gemfile_basename - source_root.join("tool/bundler/#{RUBY_VERSION.start_with?("2.3") ? "rubocop23_gems.rb" : "rubocop_gems.rb"}") + filename = if RUBY_VERSION.start_with?("2.3") + "rubocop23_gems" + elsif RUBY_VERSION.start_with?("2.4") + "rubocop24_gems" + else + "rubocop_gems" + end + source_root.join("tool/bundler/#{filename}.rb") end def standard_gemfile_basename - source_root.join("tool/bundler/#{RUBY_VERSION.start_with?("2.3") ? "standard23_gems.rb" : "standard_gems.rb"}") + filename = if RUBY_VERSION.start_with?("2.3") + "standard23_gems" + elsif RUBY_VERSION.start_with?("2.4") + "standard24_gems" + else + "standard_gems" + end + source_root.join("tool/bundler/#{filename}.rb") end extend self diff --git a/tool/bundler/rubocop_gems.rb.lock b/tool/bundler/rubocop_gems.rb.lock index ab8c259659..a4d2446902 100644 --- a/tool/bundler/rubocop_gems.rb.lock +++ b/tool/bundler/rubocop_gems.rb.lock @@ -4,12 +4,12 @@ GEM ast (2.4.2) diff-lcs (1.4.4) minitest (5.14.4) - parallel (1.19.2) - parser (3.0.1.0) + parallel (1.21.0) + parser (3.0.2.0) ast (~> 2.4.1) - power_assert (2.0.0) + power_assert (2.0.1) rainbow (3.0.0) - rake (13.0.3) + rake (13.0.6) rake-compiler (1.1.1) rake regexp_parser (2.1.1) @@ -27,25 +27,26 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.2) - rubocop (1.12.1) + rubocop (1.21.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.2.0, < 2.0) + rubocop-ast (>= 1.9.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.4.1) - parser (>= 2.7.1.5) + rubocop-ast (1.11.0) + parser (>= 3.0.1.1) ruby-progressbar (1.11.0) - test-unit (3.4.0) + test-unit (3.4.7) power_assert - unicode-display_width (2.0.0) + unicode-display_width (2.1.0) PLATFORMS arm64-darwin-20 universal-java-11 + x86_64-darwin-19 x86_64-linux DEPENDENCIES diff --git a/tool/bundler/standard_gems.rb.lock b/tool/bundler/standard_gems.rb.lock index c4e3ee685e..326d88b5a7 100644 --- a/tool/bundler/standard_gems.rb.lock +++ b/tool/bundler/standard_gems.rb.lock @@ -4,12 +4,12 @@ GEM ast (2.4.2) diff-lcs (1.4.4) minitest (5.14.4) - parallel (1.19.2) - parser (3.0.1.0) + parallel (1.21.0) + parser (3.0.2.0) ast (~> 2.4.1) - power_assert (2.0.0) + power_assert (2.0.1) rainbow (3.0.0) - rake (13.0.3) + rake (13.0.6) rake-compiler (1.1.1) rake regexp_parser (2.1.1) @@ -27,31 +27,32 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.2) - rubocop (1.11.0) + rubocop (1.20.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.2.0, < 2.0) + rubocop-ast (>= 1.9.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.4.1) - parser (>= 2.7.1.5) - rubocop-performance (1.10.1) - rubocop (>= 0.90.0, < 2.0) + rubocop-ast (1.11.0) + parser (>= 3.0.1.1) + rubocop-performance (1.11.5) + rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) ruby-progressbar (1.11.0) - standard (1.0.4) - rubocop (= 1.11.0) - rubocop-performance (= 1.10.1) - test-unit (3.4.0) + standard (1.3.0) + rubocop (= 1.20.0) + rubocop-performance (= 1.11.5) + test-unit (3.4.7) power_assert - unicode-display_width (2.0.0) + unicode-display_width (2.1.0) PLATFORMS arm64-darwin-20 universal-java-11 + x86_64-darwin-19 x86_64-linux DEPENDENCIES |