Class: Devkitkat::Processor
- Inherits:
-
Object
- Object
- Devkitkat::Processor
- Defined in:
- lib/devkitkat/processor.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(services, command, config) ⇒ Processor
constructor
A new instance of Processor.
Constructor Details
#initialize(services, command, config) ⇒ Processor
Returns a new instance of Processor.
7 8 9 10 11 |
# File 'lib/devkitkat/processor.rb', line 7 def initialize(services, command, config) @services = services @command = command @config = config end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
5 6 7 |
# File 'lib/devkitkat/processor.rb', line 5 def command @command end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/devkitkat/processor.rb', line 5 def config @config end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
5 6 7 |
# File 'lib/devkitkat/processor.rb', line 5 def services @services end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/devkitkat/processor.rb', line 13 def execute results = [] print_log_paths if services.count == 1 # If the target is only one, it could be console access (TTY) # so we can't run in parallel. results << services.first.execute else results = Parallel.map(services, progress: 'Executing', in_processes: 8) do |service| service.execute.tap do |success| raise Parallel::Kill unless success end end end results&.all? { |result| result == true } || terminate_process_group! end |