Class: Caliph::CommandChain
- Inherits:
-
CommandLine
- Object
- CommandLine
- Caliph::CommandChain
- Includes:
- DefineOp
- Defined in:
- lib/caliph/command-chain.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, #verbose
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
- #valid? ⇒ Boolean
Methods included from DefineOp
Methods inherited from CommandLine
#command, #copy_stream_to, emit_recording, #execute, execute, #must_succeed!, #options_composition, #original_execute, #redirect_both, #redirect_from, #redirect_stderr, #redirect_stdin, #redirect_stdout, #redirect_to, #run, #run_as_replacement, #run_detached, #run_in_background, #set_env, #string_format, #succeeds?
Constructor Details
#initialize ⇒ CommandChain
Returns a new instance of CommandChain.
7 8 9 10 11 |
# File 'lib/caliph/command-chain.rb', line 7 def initialize @commands = [] @command_environment = {} super(nil) end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
13 14 15 |
# File 'lib/caliph/command-chain.rb', line 13 def commands @commands end |
Instance Method Details
#add(cmd) {|cmd| ... } ⇒ Object
19 20 21 22 23 |
# File 'lib/caliph/command-chain.rb', line 19 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.
27 28 29 30 31 |
# File 'lib/caliph/command-chain.rb', line 27 def command_environment @command_environment = @commands.reverse.inject(@command_environment) do |env, command| env.merge(command.command_environment) end end |
#name ⇒ Object
33 34 35 |
# File 'lib/caliph/command-chain.rb', line 33 def name @name || @commands.last.name end |
#valid? ⇒ Boolean
15 16 17 |
# File 'lib/caliph/command-chain.rb', line 15 def valid? commands.all?{|cmd| cmd.valid?} end |