summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOKURA Masafumi <masafumi.o1988@gmail.com>2021-09-20 23:18:14 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-10-09 09:07:47 +0900
commit7e506716d2c7085c6f243705a0b6eb79b2176c49 (patch)
tree5c3a86747b89538561fdb001ea383f234c0f1d8b /lib
parent91f794b5160e9253410d06b0811451d7db448720 (diff)
Newly generated gems require Ruby 2.6.0
In 2021, Ruby 2.5 and older are EOL. We can set the default required Ruby version to 2.6.0 to encourage people to use newer Ruby. If the command is executed with old Ruby, it falls back to 2.3.0. It's still possible to create a gem for older Ruby just by changing two lines of code (one in gemspec and another is in rubocop.yml).
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli/gem.rb31
1 files changed, 28 insertions, 3 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