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, #output_stream, #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, #report, #run, #set_env, #spawn_process, #spin_off, #string_format, #succeeds?, #verbose
Constructor Details
#initialize ⇒ CommandChain
Returns a new instance of CommandChain.
208 209 210 211 212 |
# File 'lib/mattock/command-line.rb', line 208 def initialize @commands = [] @command_environment = {} super(nil) end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
214 215 216 |
# File 'lib/mattock/command-line.rb', line 214 def commands @commands end |
Instance Method Details
#add(cmd) {|cmd| ... } ⇒ Object
216 217 218 219 220 |
# File 'lib/mattock/command-line.rb', line 216 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.
224 225 226 227 228 |
# File 'lib/mattock/command-line.rb', line 224 def command_environment @command_environment = @commands.reverse.inject(@command_environment) do |env, command| env.merge(command.command_environment) end end |
#name ⇒ Object
230 231 232 |
# File 'lib/mattock/command-line.rb', line 230 def name @name || @commands.last.name end |