Class: Ohai::Application
- Inherits:
-
Object
- Object
- Ohai::Application
- Includes:
- Mixlib::CLI
- Defined in:
- lib/ohai/application.rb
Overview
The Application class is what is called by the Ohai CLI binary. It handles:
- CLI options and attribute arguments
- Collecting data via the Ohai::System class
- Printing the results returned via the Ohai::System class
Class Method Summary collapse
-
.exit!(msg, err = -1)) ⇒ Object
Log a debug message to the Logger and then exit the application.
-
.fatal!(msg, err = -1)) ⇒ Object
Log a fatal error message to both STDERR and the Logger, exit the application.
Instance Method Summary collapse
-
#configure_ohai ⇒ Object
parses the CLI options, loads the config file if present, and initializes logging.
-
#run ⇒ Object
the method called by the Ohai binary to actually run the whole application.
-
#run_application ⇒ Object
Passes config and attributes arguments to Ohai::System then prints the results.
Class Method Details
Instance Method Details
#configure_ohai ⇒ Object
parses the CLI options, loads the config file if present, and initializes logging
90 91 92 93 94 95 96 97 |
# File 'lib/ohai/application.rb', line 90 def configure_ohai @attributes = @attributes = nil if @attributes.empty? load_workstation_config Ohai::Log.init(Ohai.config[:log_location]) end |
#run ⇒ Object
the method called by the Ohai binary to actually run the whole application
79 80 81 82 83 84 85 |
# File 'lib/ohai/application.rb', line 79 def run elapsed = Benchmark.realtime do configure_ohai run_application end Ohai::Log.debug("Ohai took #{elapsed} total seconds to run.") end |
#run_application ⇒ Object
Passes config and attributes arguments to Ohai::System then prints the results. Called by the run method after config / logging have been initialized
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/ohai/application.rb', line 103 def run_application config[:invoked_from_cli] = true config[:logger] = Ohai::Log.with_child ohai = Ohai::System.new(config) ohai.all_plugins(@attributes) if @attributes @attributes.each do |a| puts ohai.attributes_print(a) end else puts ohai.json_pretty_print end end |