Class: Rscons::Command
- Inherits:
-
Object
- Object
- Rscons::Command
- Defined in:
- lib/rscons/command.rb
Overview
Class to keep track of system commands that builders need to execute. Rscons will manage scheduling these commands to be run in separate threads.
Instance Attribute Summary collapse
-
#builder ⇒ Builder
readonly
Builder executing this command.
-
#command ⇒ Array<String>
readonly
The command to execute.
-
#status ⇒ nil, ...
True if the command gives zero exit status.
-
#system_env ⇒ Hash
readonly
Environment Hash to pass to Kernel#system.
-
#system_options ⇒ Hash
readonly
Options Hash to pass to Kernel#system.
-
#thread ⇒ Thread
readonly
The thread waiting on this command to terminate.
Instance Method Summary collapse
-
#initialize(command, builder, options = {}) ⇒ Command
constructor
Create a ThreadedCommand object.
-
#run ⇒ Thread
Start a thread to run the command.
Constructor Details
#initialize(command, builder, options = {}) ⇒ Command
Create a ThreadedCommand object.
44 45 46 47 48 49 |
# File 'lib/rscons/command.rb', line 44 def initialize(command, builder, = {}) @command = command @builder = builder @system_env = [:system_env] @system_options = [:system_options] end |
Instance Attribute Details
#builder ⇒ Builder (readonly)
Returns Builder executing this command.
8 9 10 |
# File 'lib/rscons/command.rb', line 8 def builder @builder end |
#command ⇒ Array<String> (readonly)
Returns The command to execute.
12 13 14 |
# File 'lib/rscons/command.rb', line 12 def command @command end |
#status ⇒ nil, ...
Returns true if the command gives zero exit status. false if the command gives non-zero exit status. nil if command execution fails.
18 19 20 |
# File 'lib/rscons/command.rb', line 18 def status @status end |
#system_env ⇒ Hash (readonly)
Returns Environment Hash to pass to Kernel#system.
22 23 24 |
# File 'lib/rscons/command.rb', line 22 def system_env @system_env end |
#system_options ⇒ Hash (readonly)
Returns Options Hash to pass to Kernel#system.
26 27 28 |
# File 'lib/rscons/command.rb', line 26 def @system_options end |
#thread ⇒ Thread (readonly)
Returns The thread waiting on this command to terminate.
30 31 32 |
# File 'lib/rscons/command.rb', line 30 def thread @thread end |
Instance Method Details
#run ⇒ Thread
Start a thread to run the command.
55 56 57 58 59 60 61 62 63 |
# File 'lib/rscons/command.rb', line 55 def run env_args = @system_env ? [@system_env] : [] = @system_options ? [@system_options] : [] system_args = [*env_args, *Rscons.command_executer, *@command, *] @thread = Thread.new do system(*system_args) end end |