Skip to content

Commit

Permalink
Drop support for old ERB
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Mar 2, 2024
1 parent b997d62 commit 1167731
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions ext/etc/mkconstants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,11 @@ def each_name(pat)
}
end

erb_new = lambda do |src, safe, trim|
if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
ERB.new(src, trim_mode: trim)
else
ERB.new(src, safe, trim)
end
erb_new = lambda do |src, trim|
ERB.new(src, trim_mode: trim)
end

erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_decls")
% each_const {|name, default_value|
#if !defined(<%=name%>)
# if defined(HAVE_CONST_<%=name.upcase%>)
Expand All @@ -101,7 +97,7 @@ def each_name(pat)
% }
EOS

erb_new.call(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
erb_new.call(<<'EOS', '%').def_method(Object, "gen_const_defs")
% each_const {|name, default_value|
#if defined(<%=name%>)
% if comment = COMMENTS[name]
Expand All @@ -112,13 +108,13 @@ def each_name(pat)
% }
EOS

header_result = erb_new.call(<<'EOS', nil, '%').result(binding)
header_result = erb_new.call(<<'EOS', '%').result(binding)
/* autogenerated file */
<%= gen_const_decls %>
EOS

result = erb_new.call(<<'EOS', nil, '%').result(binding)
result = erb_new.call(<<'EOS', '%').result(binding)
/* autogenerated file */
#ifdef HAVE_LONG_LONG
Expand Down

0 comments on commit 1167731

Please sign in to comment.