mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Refactor ERB version checking for keyword arguments
Improving code like r62590. See r62529 for details. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
86d9071e0b
commit
3406c5d613
6 changed files with 7 additions and 9 deletions
|
@ -121,7 +121,7 @@ ENCS, ENC_DEPS = target_encodings
|
|||
ATRANS, TRANS = target_transcoders
|
||||
|
||||
if File.exist?(depend = File.join($srcdir, "depend"))
|
||||
if ERB.version[/\d+\.\d+/] >= '2.2'
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
erb = ERB.new(File.read(depend), trim_mode: '%')
|
||||
else
|
||||
erb = ERB.new(File.read(depend), nil, '%')
|
||||
|
@ -139,7 +139,7 @@ open(ARGV[0], 'wb') {|f|
|
|||
}
|
||||
if MODULE_TYPE == :static
|
||||
filename = "encinit.c.erb"
|
||||
if ERB.version[/\d+\.\d+/] >= '2.2'
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
erb = ERB.new(File.read(File.join($srcdir, filename)), trim_mode: '%-')
|
||||
else
|
||||
erb = ERB.new(File.read(File.join($srcdir, filename)), nil, '%-')
|
||||
|
|
|
@ -67,7 +67,7 @@ def each_name(pat)
|
|||
end
|
||||
|
||||
erb_new = lambda do |src, safe, trim|
|
||||
if RUBY_VERSION >= '2.6'
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
ERB.new(src, trim_mode: trim)
|
||||
else
|
||||
ERB.new(src, safe, trim)
|
||||
|
|
|
@ -74,7 +74,7 @@ def each_name(pat)
|
|||
end
|
||||
|
||||
erb_new = lambda do |src, safe, trim|
|
||||
if RUBY_VERSION >= '2.6'
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
ERB.new(src, trim_mode: trim)
|
||||
else
|
||||
ERB.new(src, safe, trim)
|
||||
|
|
|
@ -34,8 +34,7 @@ unchanged = color.pass("unchanged")
|
|||
updated = color.fail("updated")
|
||||
|
||||
result = templates.map do |template|
|
||||
match = ERB.version.match(/\Aerb\.rb \[(?<version>[^ ]+) /)
|
||||
if match && match[:version] >= '2.2.0' # Ruby 2.6+
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
erb = ERB.new(File.read(template), trim_mode: '%-')
|
||||
else
|
||||
erb = ERB.new(File.read(template), nil, '%-')
|
||||
|
|
|
@ -32,8 +32,7 @@ class RubyVM::Dumper
|
|||
rescue Errno::ENOENT
|
||||
raise "don't know how to generate #{path}"
|
||||
else
|
||||
match = ERB.version.match(/\Aerb\.rb \[(?<version>[^ ]+) /)
|
||||
if match && match[:version] >= '2.2.0' # Ruby 2.6+
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
erb = ERB.new(src, trim_mode: '%-')
|
||||
else
|
||||
erb = ERB.new(src, nil, '%-')
|
||||
|
|
|
@ -1078,7 +1078,7 @@ if __FILE__ == $0
|
|||
end
|
||||
|
||||
libs1 = $".dup
|
||||
if ERB.version[/\d+\.\d+/] >= '2.2'
|
||||
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
|
||||
erb = ERB.new(src, trim_mode: '%')
|
||||
else
|
||||
erb = ERB.new(src, nil, '%')
|
||||
|
|
Loading…
Reference in a new issue