Skip to content

Commit

Permalink
Merge pull request #117 from voxik/introspection-to-detect-kwargs
Browse files Browse the repository at this point in the history
Use introspection to detect usage of kwargs/positional args.
  • Loading branch information
voxik authored Aug 4, 2022
2 parents c027e10 + f02f035 commit 195a45f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/gem2rpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ def self.convert(fname, template, out = $stdout, nongem = true, local = false,
end
end

erb = if RUBY_VERSION >= '2.6'
# Check if keyword arguments are used. The condition could let go as soon
# as only Ruby 2.6+ is supported.
kwargs = !(ERB.new("").method(:initialize).parameters & [[:key, :trim_mode]]).empty?
erb = if kwargs
ERB.new(template.read, trim_mode: '-')
else
ERB.new(template.read, 0, '-')
Expand Down

0 comments on commit 195a45f

Please sign in to comment.