1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

tool/generic_erb.rb: check ERB version

instead of Ruby's.

When older ERB is installed but Ruby is still 2.6.0, this may cause
error like:

```
Traceback (most recent call last):
    5: from ../src/tool/generic_erb.rb:36:in `<main>'
    4: from ../src/tool/generic_erb.rb:36:in `map'
    3: from ../src/tool/generic_erb.rb:43:in `block in <main>'
    2: from ../src/tool/generic_erb.rb:43:in `block (2 levels) in <main>'
    1: from /opt/local/lib/ruby/2.6.0/erb.rb:873:in `result'
/opt/local/lib/ruby/2.6.0/erb.rb:869:in `block in result': no implicit conversion of Hash into Integer (TypeError)
```

For safety, I changed this to check ERB's version. See also: r62529.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
k0kubun 2018-02-22 15:03:08 +00:00
parent 171c496e50
commit 8038bb2f96

View file

@ -34,7 +34,8 @@ unchanged = color.pass("unchanged")
updated = color.fail("updated") updated = color.fail("updated")
result = templates.map do |template| result = templates.map do |template|
if RUBY_VERSION >= '2.6' match = ERB.version.match(/\Aerb\.rb \[(?<version>[^ ]+) /)
if match && match[:version] >= '2.2.0' # Ruby 2.6+
erb = ERB.new(File.read(template), trim_mode: '%-') erb = ERB.new(File.read(template), trim_mode: '%-')
else else
erb = ERB.new(File.read(template), nil, '%-') erb = ERB.new(File.read(template), nil, '%-')