Class: SousVide::Outputs::JsonFile
- Inherits:
-
Object
- Object
- SousVide::Outputs::JsonFile
- Defined in:
- lib/sous_vide/outputs/json_file.rb
Overview
Saves the report to a JSON file. The file will be saved to chef cache directory.
Default file name is “sous-vide-report.json”.
Instance Method Summary collapse
-
#call(run_data:, node_data:, resources_data:) ⇒ Object
Saves report to file.
-
#initialize(logger: nil, file_name: "sous-vide-report.json") ⇒ JsonFile
constructor
A new instance of JsonFile.
Constructor Details
#initialize(logger: nil, file_name: "sous-vide-report.json") ⇒ JsonFile
Returns a new instance of JsonFile.
11 12 13 14 |
# File 'lib/sous_vide/outputs/json_file.rb', line 11 def initialize(logger: nil, file_name: "sous-vide-report.json") @logger = logger @file_name = file_name end |
Instance Method Details
#call(run_data:, node_data:, resources_data:) ⇒ Object
Saves report to file.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sous_vide/outputs/json_file.rb', line 17 def call(run_data:, node_data:, resources_data:) log "=============== #{self.class.name} ===============" log "" log "Processing #{resources_data.size} resources." json_data = resources_data.map do |tracked| tracked.to_h.merge(node_data).merge(run_data) end ::Chef::FileCache.store(@file_name, ::Chef::JSONCompat.to_json_pretty(json_data)) log "The report is in #{Chef::Config[:file_cache_path]}/#{@file_name} file." log "" end |