ruby-changes:50415
From: k0kubun <ko1@a...>
Date: Fri, 23 Feb 2018 00:03:14 +0900 (JST)
Subject: [ruby-changes:50415] k0kubun:r62531 (trunk): tool/generic_erb.rb: check ERB version
k0kubun 2018-02-23 00:03:08 +0900 (Fri, 23 Feb 2018) New Revision: 62531 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62531 Log: 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. Modified files: trunk/tool/generic_erb.rb Index: tool/generic_erb.rb =================================================================== --- tool/generic_erb.rb (revision 62530) +++ tool/generic_erb.rb (revision 62531) @@ -34,7 +34,8 @@ unchanged = color.pass("unchanged") https://github.com/ruby/ruby/blob/trunk/tool/generic_erb.rb#L34 updated = color.fail("updated") 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: '%-') else erb = ERB.new(File.read(template), nil, '%-') -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/