Skip to content

Commit 3f714b6

Browse files
authored
Drop Ruby 2.6 support (#555)
* Remove all Ruby 2.6 support * Drop Ruby 2.6 specific testing conditions * Only run Ruby 2.7+ on CI * Bump Ruby requirement to 2.7+
1 parent 198e839 commit 3f714b6

File tree

16 files changed

+32
-143
lines changed

16 files changed

+32
-143
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
1212
with:
1313
engine: cruby-truffleruby
14-
min_version: 2.6
14+
min_version: 2.7
1515

1616
irb:
1717
needs: ruby-versions
@@ -48,7 +48,6 @@ jobs:
4848
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
4949
with_latest_reline: [true, false]
5050
exclude:
51-
- ruby: 2.6
5251
- ruby: truffleruby
5352
- ruby: truffleruby-head
5453
fail-fast: false

irb.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
3939
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
4040
spec.require_paths = ["lib"]
4141

42-
spec.required_ruby_version = Gem::Requirement.new(">= 2.6")
42+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7")
4343

4444
spec.add_dependency "reline", ">= 0.3.0"
4545
end

lib/irb.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,6 @@ def eval_input
560560
@scanner.each_top_level_statement do |line, line_no|
561561
signal_status(:IN_EVAL) do
562562
begin
563-
line.untaint if RUBY_VERSION < '2.7'
564563
if IRB.conf[:MEASURE] && IRB.conf[:MEASURE_CALLBACKS].empty?
565564
IRB.set_measure_callback
566565
end

lib/irb/cmd/nop.rb

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,11 @@ def string_literal?(args)
3030
end
3131
end
3232

33-
if RUBY_VERSION >= "2.7.0"
34-
def self.execute(conf, *opts, **kwargs, &block)
35-
command = new(conf)
36-
command.execute(*opts, **kwargs, &block)
37-
rescue CommandArgumentError => e
38-
puts e.message
39-
end
40-
else
41-
def self.execute(conf, *opts, &block)
42-
command = new(conf)
43-
command.execute(*opts, &block)
44-
rescue CommandArgumentError => e
45-
puts e.message
46-
end
33+
def self.execute(conf, *opts, **kwargs, &block)
34+
command = new(conf)
35+
command.execute(*opts, **kwargs, &block)
36+
rescue CommandArgumentError => e
37+
puts e.message
4738
end
4839

4940
def initialize(conf)

lib/irb/cmd/show_source.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def find_source(str, irb_context)
2727
when /\A[A-Z]\w*(::[A-Z]\w*)*\z/ # Const::Name
2828
eval(str, irb_context.workspace.binding) # trigger autoload
2929
base = irb_context.workspace.binding.receiver.yield_self { |r| r.is_a?(Module) ? r : Object }
30-
file, line = base.const_source_location(str) if base.respond_to?(:const_source_location) # Ruby 2.7+
30+
file, line = base.const_source_location(str)
3131
when /\A(?<owner>[A-Z]\w*(::[A-Z]\w*)*)#(?<method>[^ :.]+)\z/ # Class#method
3232
owner = eval(Regexp.last_match[:owner], irb_context.workspace.binding)
3333
method = Regexp.last_match[:method]

lib/irb/color.rb

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,9 @@ def scan(code, allow_last_error:)
197197
end
198198
end
199199

200-
if lexer.respond_to?(:scan) # Ruby 2.7+
201-
lexer.scan.each do |elem|
202-
next if allow_last_error and /meets end of file|unexpected end-of-input/ =~ elem.message
203-
on_scan.call(elem)
204-
end
205-
else
206-
lexer.parse.sort_by(&:pos).each do |elem|
207-
on_scan.call(elem)
208-
end
200+
lexer.scan.each do |elem|
201+
next if allow_last_error and /meets end of file|unexpected end-of-input/ =~ elem.message
202+
on_scan.call(elem)
209203
end
210204
# yield uncolorable DATA section
211205
yield(nil, inner_code.byteslice(byte_pos...inner_code.bytesize), nil) if byte_pos < inner_code.bytesize

lib/irb/completion.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,11 @@ def defined? do
5858

5959
BASIC_WORD_BREAK_CHARACTERS = " \t\n`><=;|&{("
6060

61-
def self.absolute_path?(p) # TODO Remove this method after 2.6 EOL.
62-
if File.respond_to?(:absolute_path?)
63-
File.absolute_path?(p)
64-
else
65-
File.absolute_path(p) == p
66-
end
67-
end
68-
6961
GEM_PATHS =
7062
if defined?(Gem::Specification)
7163
Gem::Specification.latest_specs(true).map { |s|
7264
s.require_paths.map { |p|
73-
if absolute_path?(p)
65+
if File.absolute_path?(p)
7466
p
7567
else
7668
File.join(s.full_gem_path, p)

lib/irb/ext/loader.rb

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,8 @@ def irb_load(fn, priv = nil)
2424
load_file(path, priv)
2525
end
2626

27-
if File.respond_to?(:absolute_path?)
28-
def absolute_path?(path)
29-
File.absolute_path?(path)
30-
end
31-
else
32-
separator =
33-
if File::ALT_SEPARATOR
34-
"[#{Regexp.quote(File::SEPARATOR + File::ALT_SEPARATOR)}]"
35-
else
36-
File::SEPARATOR
37-
end
38-
ABSOLUTE_PATH_PATTERN = # :nodoc:
39-
case Dir.pwd
40-
when /\A\w:/, /\A#{separator}{2}/
41-
/\A(?:\w:|#{separator})#{separator}/
42-
else
43-
/\A#{separator}/
44-
end
45-
def absolute_path?(path)
46-
ABSOLUTE_PATH_PATTERN =~ path
47-
end
48-
end
49-
5027
def search_file_from_ruby_path(fn) # :nodoc:
51-
if absolute_path?(fn)
28+
if File.absolute_path?(fn)
5229
return fn if File.exist?(fn)
5330
return nil
5431
end

lib/irb/extend-command.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,12 @@ def self.def_extend_command(cmd_name, cmd_class, load_file = nil, *aliases)
256256
end
257257

258258
if load_file
259-
kwargs = ", **kwargs" if RUBY_VERSION >= "2.7.0"
260259
line = __LINE__; eval %[
261-
def #{cmd_name}(*opts#{kwargs}, &b)
260+
def #{cmd_name}(*opts, **kwargs, &b)
262261
Kernel.require_relative "#{load_file}"
263262
arity = ::IRB::ExtendCommand::#{cmd_class}.instance_method(:execute).arity
264263
args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
265-
args << "*opts#{kwargs}" if arity < 0
264+
args << "*opts, **kwargs" if arity < 0
266265
args << "&block"
267266
args = args.join(", ")
268267
line = __LINE__; eval %[
@@ -273,7 +272,7 @@ def self.#{cmd_name}_(\#{args})
273272
end
274273
end
275274
], nil, __FILE__, line
276-
__send__ :#{cmd_name}_, *opts#{kwargs}, &b
275+
__send__ :#{cmd_name}_, *opts, **kwargs, &b
277276
end
278277
], nil, __FILE__, line
279278
else

lib/irb/inspector.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ def inspect_value(v)
9898
puts "An error occurred when inspecting the object: #{e.inspect}"
9999

100100
begin
101-
# TODO: change this to bind_call when we drop support for Ruby 2.6
102-
puts "Result of Kernel#inspect: #{KERNEL_INSPECT.bind(v).call}"
101+
puts "Result of Kernel#inspect: #{KERNEL_INSPECT.bind_call(v)}"
103102
''
104103
rescue => e
105104
puts "An error occurred when running Kernel#inspect: #{e.inspect}"

0 commit comments

Comments
 (0)