Class: ForemanMaintain::Cli::ReportCommand

Inherits:
Base
  • Object
show all
Extended by:
ForemanMaintain::Concerns::Finders
Defined in:
lib/foreman_maintain/cli/report_command.rb

Instance Attribute Summary

Attributes inherited from Base

#runner

Instance Method Summary collapse

Methods included from ForemanMaintain::Concerns::Finders

check, detector, feature, find_all_scenarios, find_procedures, find_scenarios, procedure

Methods inherited from Base

#available_checks, #available_procedures, available_tags, #available_tags, completion_map, completion_types, dashize, #dashize, delete_duplicate_assumeyes_if_any, interactive_option, label_option, #label_string, option, #option_wrapper, parameter, #print_check_info, #reporter, #run_scenario, #run_scenarios_and_exit, service_options, subcommand, #tag_string, tags_option, #underscorize

Methods included from ForemanMaintain::Concerns::Logger

#logger

Instance Method Details

#generate_reportObject



6
7
8
9
10
11
12
13
# File 'lib/foreman_maintain/cli/report_command.rb', line 6

def generate_report
  scenario = run_scenario(Scenarios::Report::Generate.new({}, [:reports])).first

  # description can be used too
  report_data = scenario.steps.map(&:data).compact.reduce(&:merge).transform_keys(&:to_s)
  report_data['version'] = 1
  report_data
end

#save_report(report, file) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/foreman_maintain/cli/report_command.rb', line 15

def save_report(report, file)
  if file
    File.write(file, report)
  else
    puts report
  end
end