Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/facter/facter_dot_d.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ def json_parser(file)
retry if require 'rubygems'
raise
end

JSON.parse(File.read(file)).each_pair do |f, v|
# Call ::JSON to ensure it references the JSON library from Ruby’s standard library
# instead of a random JSON namespace that might be in scope due to user code.
::JSON.parse(File.read(file)).each_pair do |f, v|
Facter.add(f) do
setcode { v }
end
Expand Down
5 changes: 4 additions & 1 deletion lib/puppet/functions/to_json_pretty.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'json'

# @summary
# Convert data structure and output to pretty JSON
#
Expand Down Expand Up @@ -72,6 +73,8 @@ def to_json_pretty(data, skip_undef = false, opts = nil)
data = data.reject { |_, value| value.nil? }
end
end
JSON.pretty_generate(data, opts) << "\n"
# Call ::JSON to ensure it references the JSON library from Ruby’s standard library
# instead of a random JSON namespace that might be in scope due to user code.
::JSON.pretty_generate(data, opts) << "\n"
end
end