Class: Factor::Commands::RunCommand
- Defined in:
- lib/commands/run_command.rb
Constant Summary
Constants inherited from Command
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
-
#initialize ⇒ RunCommand
constructor
A new instance of RunCommand.
- #run(args, options) ⇒ Object
Methods inherited from Command
Constructor Details
#initialize ⇒ RunCommand
Returns a new instance of RunCommand.
13 14 15 16 |
# File 'lib/commands/run_command.rb', line 13 def initialize @workflows = {} super end |
Instance Method Details
#run(args, options) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/commands/run_command.rb', line 18 def run(args, ) config_settings = {} config_settings[:credentials] = .credentials config_settings[:connectors] = .connectors load_config(config_settings) connector_settings = configatron.connectors.to_hash credential_settings = configatron.credentials.to_hash runtime = Factor::Runtime::Workflow.new(connector_settings, credential_settings, logger: logger) begin params = JSON.parse(args[1] || '{}') rescue => ex logger.error "'#{args[1]}' can't be parsed as JSON" end if params EM.run do runtime.run(args[0],params) do |response_info| data = response_info.is_a?(Array) ? response_info.map {|i| i.marshal_dump} : response_info.marshal_dump JSON.pretty_generate(data).split("\n").each do |line| logger.info line end EM.stop end.on_fail do EM.stop end end logger.info 'Good bye!' end end |