Skip to content

Commit d54898b

Browse files
authored
Merge pull request #821 from rails/rm-drop-ruby
Drop support to Ruby 2.6
2 parents 291d93d + 0df572a commit d54898b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+396
-475
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ on: [push, pull_request]
33
jobs:
44
test:
55
runs-on: ubuntu-latest
6-
env:
7-
BUNDLE_GEMFILE: lint_gems.rb
86
steps:
97
- uses: actions/checkout@v2
108
- uses: ruby/setup-ruby@v1

.github/workflows/tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ jobs:
55
strategy:
66
fail-fast: false
77
matrix:
8-
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
9-
ruby: ['2.0', 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, head]
8+
ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', 'head']
109
runs-on: ubuntu-latest
1110
steps:
1211
- uses: actions/checkout@v2

.rubocop.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
inherit_from: .rubocop_todo.yml
2-
31
AllCops:
4-
TargetRubyVersion: 2.0
2+
TargetRubyVersion: 2.6
53
DisabledByDefault: true
4+
SuggestExtensions: false
65
Exclude:
76
- spec/sandbox/**/*
87
- spec/fixtures/**/*
98
- vendor/bundle/**/**
109

11-
# Enforce Ruby 1.8-compatible hash syntax
1210
Style/HashSyntax:
13-
EnforcedStyle: hash_rockets
11+
EnforcedStyle: ruby19
1412

1513
# No spaces inside hash literals
1614
Layout/SpaceInsideHashLiteralBraces:

.rubocop_todo.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

Gemfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ gem "rake"
55
group :development do
66
gem "pry"
77
gem "pry-byebug"
8+
gem "rubocop", "~> 1.30"
89
end
910

1011
group :test do
1112
gem "childlabor"
12-
gem 'coveralls_reborn', '~> 0.23.1', :require => false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
13+
gem "coveralls_reborn", "~> 0.23.1", require: false
1314
gem "rspec", ">= 3.2"
1415
gem "rspec-mocks", ">= 3"
1516
gem "simplecov", ">= 0.13"
16-
gem "webmock", '~> 3.14.0' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.4.0")
17-
gem "webmock", '>= 3.14' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.4.0")
18-
gem "rexml", '3.2.4' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.1.0")
17+
gem "webmock", ">= 3.14"
1918
end
2019

2120
gemspec

lib/thor.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def command_help(shell, command_name)
258258

259259
if command.long_description
260260
shell.say "Description:"
261-
shell.print_wrapped(command.long_description, :indent => 2)
261+
shell.print_wrapped(command.long_description, indent: 2)
262262
else
263263
shell.say command.description
264264
end
@@ -283,7 +283,7 @@ def help(shell, subcommand = false)
283283
shell.say "Commands:"
284284
end
285285

286-
shell.print_table(list, :indent => 2, :truncate => true)
286+
shell.print_table(list, indent: 2, truncate: true)
287287
shell.say
288288
class_options_help(shell)
289289
print_exclusive_options(shell)
@@ -318,7 +318,7 @@ def subcommand(subcommand, subcommand_class)
318318

319319
define_method(subcommand) do |*args|
320320
args, opts = Thor::Arguments.split(args)
321-
invoke_args = [args, opts, {:invoked_via_subcommand => true, :class_options => options}]
321+
invoke_args = [args, opts, {invoked_via_subcommand: true, class_options: options}]
322322
invoke_args.unshift "help" if opts.delete("--help") || opts.delete("-h")
323323
invoke subcommand_class, *invoke_args
324324
end
@@ -459,7 +459,7 @@ def print_exclusive_options(shell, command = nil) # :nodoc:
459459
opts += class_exclusive_option_names
460460
unless opts.empty?
461461
shell.say "Exclusive Options:"
462-
shell.print_table(opts.map{ |ex| ex.map{ |e| "--#{e}"}}, :indent => 2 )
462+
shell.print_table(opts.map{ |ex| ex.map{ |e| "--#{e}"}}, indent: 2 )
463463
shell.say
464464
end
465465
end
@@ -470,7 +470,7 @@ def print_at_least_one_required_options(shell, command = nil) # :nodoc:
470470
opts += class_at_least_one_option_names
471471
unless opts.empty?
472472
shell.say "Required At Least One:"
473-
shell.print_table(opts.map{ |ex| ex.map{ |e| "--#{e}"}}, :indent => 2 )
473+
shell.print_table(opts.map{ |ex| ex.map{ |e| "--#{e}"}}, indent: 2 )
474474
shell.say
475475
end
476476
end
@@ -539,8 +539,8 @@ def create_command(meth) #:nodoc:
539539

540540
if @usage && @desc
541541
base_class = @hide ? Thor::HiddenCommand : Thor::Command
542-
relations = {:exclusive_option_names => method_exclusive_option_names,
543-
:at_least_one_option_names => method_at_least_one_option_names}
542+
relations = {exclusive_option_names: method_exclusive_option_names,
543+
at_least_one_option_names: method_at_least_one_option_names}
544544
commands[meth] = base_class.new(meth, @desc, @long_desc, @usage, method_options, relations)
545545
@usage, @desc, @long_desc, @method_options, @hide = nil
546546
@method_exclusive_option_names, @method_at_least_one_option_names = nil

lib/thor/actions.rb

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ def source_paths_for_search
4646
# Add runtime options that help actions execution.
4747
#
4848
def add_runtime_options!
49-
class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime,
50-
:desc => "Overwrite files that already exist"
49+
class_option :force, type: :boolean, aliases: "-f", group: :runtime,
50+
desc: "Overwrite files that already exist"
5151

52-
class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime,
53-
:desc => "Run but do not make any changes"
52+
class_option :pretend, type: :boolean, aliases: "-p", group: :runtime,
53+
desc: "Run but do not make any changes"
5454

55-
class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime,
56-
:desc => "Suppress status output"
55+
class_option :quiet, type: :boolean, aliases: "-q", group: :runtime,
56+
desc: "Suppress status output"
5757

58-
class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime,
59-
:desc => "Skip files that already exist"
58+
class_option :skip, type: :boolean, aliases: "-s", group: :runtime,
59+
desc: "Skip files that already exist"
6060
end
6161
end
6262

@@ -113,9 +113,9 @@ def destination_root=(root)
113113
#
114114
def relative_to_original_destination_root(path, remove_dot = true)
115115
root = @destination_stack[0]
116-
if path.start_with?(root) && [File::SEPARATOR, File::ALT_SEPARATOR, nil, ''].include?(path[root.size..root.size])
116+
if path.start_with?(root) && [File::SEPARATOR, File::ALT_SEPARATOR, nil, ""].include?(path[root.size..root.size])
117117
path = path.dup
118-
path[0...root.size] = '.'
118+
path[0...root.size] = "."
119119
remove_dot ? (path[2..-1] || "") : path
120120
else
121121
path
@@ -223,8 +223,7 @@ def apply(path, config = {})
223223

224224
contents = if is_uri
225225
require "open-uri"
226-
# for ruby 2.1-2.4
227-
URI.send(:open, path, "Accept" => "application/x-thor-template", &:read)
226+
URI.open(path, "Accept" => "application/x-thor-template", &:read)
228227
else
229228
File.open(path, &:read)
230229
end
@@ -285,7 +284,7 @@ def run(command, config = {})
285284
#
286285
def run_ruby_script(command, config = {})
287286
return unless behavior == :invoke
288-
run command, config.merge(:with => Thor::Util.ruby_command)
287+
run command, config.merge(with: Thor::Util.ruby_command)
289288
end
290289

291290
# Run a thor command. A hash of options can be given and it's converted to
@@ -316,15 +315,15 @@ def thor(command, *args)
316315
args.push Thor::Options.to_switches(config)
317316
command = args.join(" ").strip
318317

319-
run command, :with => :thor, :verbose => verbose, :pretend => pretend, :capture => capture
318+
run command, with: :thor, verbose: verbose, pretend: pretend, capture: capture
320319
end
321320

322321
protected
323322

324323
# Allow current root to be shared between invocations.
325324
#
326325
def _shared_configuration #:nodoc:
327-
super.merge!(:destination_root => destination_root)
326+
super.merge!(destination_root: destination_root)
328327
end
329328

330329
def _cleanup_options_and_set(options, key) #:nodoc:

lib/thor/actions/directory.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Directory < EmptyDirectory #:nodoc:
5858
def initialize(base, source, destination = nil, config = {}, &block)
5959
@source = File.expand_path(Dir[Util.escape_globs(base.find_in_source_paths(source.to_s))].first)
6060
@block = block
61-
super(base, destination, {:recursive => true}.merge(config))
61+
super(base, destination, {recursive: true}.merge(config))
6262
end
6363

6464
def invoke!

lib/thor/actions/empty_directory.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class EmptyDirectory #:nodoc:
3333
#
3434
def initialize(base, destination, config = {})
3535
@base = base
36-
@config = {:verbose => true}.merge(config)
36+
@config = {verbose: true}.merge(config)
3737
self.destination = destination
3838
end
3939

lib/thor/actions/file_manipulation.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,7 @@ def template(source, *args, &block)
123123
context = config.delete(:context) || instance_eval("binding")
124124

125125
create_file destination, nil, config do
126-
match = ERB.version.match(/(\d+\.\d+\.\d+)/)
127-
capturable_erb = if match && match[1] >= "2.2.0" # Ruby 2.6+
128-
CapturableERB.new(::File.binread(source), :trim_mode => "-", :eoutvar => "@output_buffer")
129-
else
130-
CapturableERB.new(::File.binread(source), nil, "-", "@output_buffer")
131-
end
126+
capturable_erb = CapturableERB.new(::File.binread(source), trim_mode: "-", eoutvar: "@output_buffer")
132127
content = capturable_erb.tap do |erb|
133128
erb.filename = source
134129
end.result(context)

0 commit comments

Comments
 (0)