Class: Chef::Compliance::Reporter::JsonFile
- Inherits:
-
Object
- Object
- Chef::Compliance::Reporter::JsonFile
- Defined in:
- lib/chef/compliance/reporter/json_file.rb
Instance Method Summary collapse
-
#initialize(opts) ⇒ JsonFile
constructor
A new instance of JsonFile.
- #send_report(report) ⇒ Object
- #validate_config! ⇒ Object
Constructor Details
#initialize(opts) ⇒ JsonFile
Returns a new instance of JsonFile.
8 9 10 |
# File 'lib/chef/compliance/reporter/json_file.rb', line 8 def initialize(opts) @path = opts.fetch(:file) end |
Instance Method Details
#send_report(report) ⇒ Object
12 13 14 15 16 |
# File 'lib/chef/compliance/reporter/json_file.rb', line 12 def send_report(report) Chef::Log.info "Writing compliance report to #{@path}" FileUtils.mkdir_p(File.dirname(@path), mode: 0700) File.write(@path, Chef::JSONCompat.to_json(report)) end |
#validate_config! ⇒ Object
18 19 20 21 22 |
# File 'lib/chef/compliance/reporter/json_file.rb', line 18 def validate_config! if @path.nil? || @path.class != String || @path.empty? raise "CMPL009: json_file reporter: node['audit']['json_file']['location'] must contain a file path" end end |