Class: Rubu::ShellCommand
Overview
Shell based command.
Instance Attribute Summary
Attributes inherited from Move
#errmsg, #output, #status, #subs
Instance Method Summary collapse
-
#initialize(cmd) ⇒ ShellCommand
constructor
A new instance of ShellCommand.
-
#run ⇒ Object
Execution content.
Methods inherited from Move
#display, #error, #host, #host_in, #host_out, #use, #warn
Constructor Details
#initialize(cmd) ⇒ ShellCommand
Returns a new instance of ShellCommand
128 129 130 131 |
# File 'lib/rubu.rb', line 128 def initialize( cmd ) super() @cmd = cmd end |
Instance Method Details
#run ⇒ Object
Execution content.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/rubu.rb', line 134 def run begin stdout, stderr, status = Open3.capture3( @cmd ) if Order[ :verbose ] STDOUT.puts @cmd end if status.exitstatus == 0 if Order[ :sh_warn ] && not( stderr.empty? ) warn( stderr ) end @status = :success else @status = :error error( stderr ) end rescue error( "Invalid command: \"#{@cmd}\"..." ) @status = :error end self end |