Skip to content

Commit

Permalink
Lint/ErbNewArguments
Browse files Browse the repository at this point in the history
In Ruby 2.6 and greater, passing trim_mode as the third argument of
ERB.new is deprecated.

This commit updates all instances of ERB.new to instead use trim_mode as
a keyword argument.
  • Loading branch information
mhashizume committed Jan 23, 2024
1 parent 8b9bd6a commit c30fd7b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions lib/docs/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ def format_facts(fact_hash)
scope = OpenStruct.new({
facts: fact_hash
})

erb = if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+
ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-')
else
ERB.new(File.read(PATH_TO_TEMPLATE), nil, '-')
end
erb = ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-')
erb.result(scope.instance_eval { binding })
end

Expand Down
2 changes: 1 addition & 1 deletion lib/facter/framework/cli/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def man(*args)
negate_options = %w[block cache custom_facts external_facts]

template = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'man.erb')
erb = ERB.new(File.read(template), nil, '-')
erb = ERB.new(File.read(template), trim_mode: '-')
erb.filename = template
puts erb.result(binding)
end
Expand Down

0 comments on commit c30fd7b

Please sign in to comment.