Class: Mattock::CommandChain
- Inherits:
-
CommandLine
- Object
- CommandLine
- Mattock::CommandChain
- Defined in:
- lib/mattock/command-line.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
Attributes inherited from CommandLine
#env, #executable, #options, #redirections
Instance Method Summary collapse
- #add(cmd) {|cmd| ... } ⇒ Object
-
#command_environment ⇒ Object
Honestly this is sub-optimal - biggest driver for considering the mini-shell approach here.
-
#initialize ⇒ CommandChain
constructor
A new instance of CommandChain.
- #name ⇒ Object
Methods inherited from CommandLine
#background, #collect_result, #command, #complete, #copy_stream_to, define_chain_op, define_op, emit_recording, #execute, execute, #kill_process, #must_succeed!, #options_composition, #original_execute, #redirect_from, #redirect_stderr, #redirect_stdin, #redirect_stdout, #redirect_to, #replace_us, #run, #set_env, #spawn_process, #spin_off, #string_format, #succeeds?, #verbose
Constructor Details
#initialize ⇒ CommandChain
Returns a new instance of CommandChain.
199 200 201 202 203 |
# File 'lib/mattock/command-line.rb', line 199 def initialize @commands = [] @command_environment = {} super(nil) end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
205 206 207 |
# File 'lib/mattock/command-line.rb', line 205 def commands @commands end |
Instance Method Details
#add(cmd) {|cmd| ... } ⇒ Object
207 208 209 210 211 |
# File 'lib/mattock/command-line.rb', line 207 def add(cmd) yield cmd if block_given? @commands << cmd self end |
#command_environment ⇒ Object
Honestly this is sub-optimal - biggest driver for considering the mini-shell approach here.
215 216 217 218 219 |
# File 'lib/mattock/command-line.rb', line 215 def command_environment @command_environment = @commands.reverse.inject(@command_environment) do |env, command| env.merge(command.command_environment) end end |
#name ⇒ Object
221 222 223 |
# File 'lib/mattock/command-line.rb', line 221 def name @name || @commands.last.name end |