Class: Executo::Command
- Inherits:
-
Object
- Object
- Executo::Command
- Includes:
- CommandDsl, TaggedLogger
- Defined in:
- lib/executo/command.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#executo_id ⇒ Object
readonly
Returns the value of attribute executo_id.
-
#exitstatus ⇒ Object
readonly
Returns the value of attribute exitstatus.
-
#parameter_values ⇒ Object
readonly
Returns the value of attribute parameter_values.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(*args) ⇒ Command
constructor
A new instance of Command.
- #process_results(results) ⇒ Object
- #setup_logger(id) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Command
Returns a new instance of Command.
10 11 12 13 14 15 |
# File 'lib/executo/command.rb', line 10 def initialize(*args) @executo_id = args.first&.delete(:id) || SecureRandom.uuid @errors = ActiveModel::Errors.new(self) @parameter_values = args.first&.delete(:parameter_values) || {} super(*args) end |
Instance Attribute Details
#executo_id ⇒ Object (readonly)
Returns the value of attribute executo_id.
8 9 10 |
# File 'lib/executo/command.rb', line 8 def executo_id @executo_id end |
#exitstatus ⇒ Object (readonly)
Returns the value of attribute exitstatus.
8 9 10 |
# File 'lib/executo/command.rb', line 8 def exitstatus @exitstatus end |
#parameter_values ⇒ Object (readonly)
Returns the value of attribute parameter_values.
8 9 10 |
# File 'lib/executo/command.rb', line 8 def parameter_values @parameter_values end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/executo/command.rb', line 8 def status @status end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
8 9 10 |
# File 'lib/executo/command.rb', line 8 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
8 9 10 |
# File 'lib/executo/command.rb', line 8 def stdout @stdout end |
Class Method Details
.process_feedback(feedback, results) ⇒ Object
49 50 51 52 53 |
# File 'lib/executo/command.rb', line 49 def process_feedback(feedback, results) cmd = new(feedback['arguments'].merge(id: feedback['id'])) cmd.setup_logger(feedback['id']) cmd.process_results(results.symbolize_keys) end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 |
# File 'lib/executo/command.rb', line 17 def call raise 'missing target' unless target perform end |
#process_results(results) ⇒ Object
23 24 25 26 27 |
# File 'lib/executo/command.rb', line 23 def process_results(results) state = results[:state] logger.debug("Processing #{state} results") public_send(state.to_sym, results) if respond_to?(state.to_sym) end |
#setup_logger(id) ⇒ Object
29 30 31 32 |
# File 'lib/executo/command.rb', line 29 def setup_logger(id) logger_add_tag(self.class.name) logger_add_tag(id) end |