Class: Puppi::Action
- Inherits:
-
Object
- Object
- Puppi::Action
- Defined in:
- lib/puppi/action.rb
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#puppi_module ⇒ Object
readonly
Returns the value of attribute puppi_module.
Instance Method Summary collapse
- #execute(action) ⇒ Object
-
#initialize(options) ⇒ Action
constructor
A new instance of Action.
Constructor Details
#initialize(options) ⇒ Action
Returns a new instance of Action.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/puppi/action.rb', line 5 def initialize () @loader = Puppi::Loader.new @actions = [ 'check', 'log', 'info' ] if [:puppi_module].nil? @puppi_module = nil else @puppi_module = [:puppi_module].to_s end if @actions.include? [:action].to_s execute [:action].to_s else raise "No Action Found" end end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
3 4 5 |
# File 'lib/puppi/action.rb', line 3 def output @output end |
#puppi_module ⇒ Object (readonly)
Returns the value of attribute puppi_module.
3 4 5 |
# File 'lib/puppi/action.rb', line 3 def puppi_module @puppi_module end |
Instance Method Details
#execute(action) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/puppi/action.rb', line 20 def execute action @datafiles = @loader.load_all('data', @puppi_module) @output = Array.new @datafiles.each do |datafile| @loaded_datafile = @loader.load_datafile(datafile) datafile_helper = datafile.split("_")[0] module_helper = datafile.split("_")[1] @helper_commands = @loader.load_helperfile datafile_helper, action return nil unless not @helper_commands.nil? @helper_commands.each do |command| @output << (run_command command, module_helper) end end end |