Class: Command::Runner::Backends::Backticks
- Defined in:
- lib/command/runner/backends/backticks.rb
Overview
A backend that uses ticks to do its bidding.
Class Method Summary collapse
-
.available?(_ = false) ⇒ Boolean
Returns whether or not this backend is avialable on this platform.
- .unsafe? ⇒ Boolean
Instance Method Summary collapse
-
#call(command, arguments, env = {}, options = {}) {|Message| ... } ⇒ Message, Object
Run the given command and arguments, in the given environment.
-
#initialize ⇒ Backticks
constructor
Initialize the fake backend.
Methods inherited from Fake
#ran?, #unsafe?, unsafe_execution?
Constructor Details
#initialize ⇒ Backticks
Initialize the fake backend.
21 22 23 |
# File 'lib/command/runner/backends/backticks.rb', line 21 def initialize super end |
Class Method Details
.available?(_ = false) ⇒ Boolean
Returns whether or not this backend is avialable on this platform.
12 13 14 |
# File 'lib/command/runner/backends/backticks.rb', line 12 def self.available?(_ = false) true end |
.unsafe? ⇒ Boolean
16 17 18 |
# File 'lib/command/runner/backends/backticks.rb', line 16 def self.unsafe? true end |
Instance Method Details
#call(command, arguments, env = {}, options = {}) {|Message| ... } ⇒ Message, Object
Run the given command and arguments, in the given environment.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/command/runner/backends/backticks.rb', line 37 def call(command, arguments, env = {}, = {}, &block) super output = "" start_time = nil end_time = nil if [:input] raise ArgumentError, "Cannot specify options[:input] - using incorrect backend" end with_modified_env(env) do start_time = Time.now output << `#{command} #{arguments.join(' ')}` end_time = Time.now end if $?.exitstatus == 127 raise NoCommandError end = Message.new :process_id => $?.pid, :exit_code => $?.exitstatus, :finished => true, :time => (end_time - start_time).abs, :env => env, :options => {}, :stdout => output, :line => [command, arguments].flatten.join(' '), :executed => true, :status => $? if block_given? block.call() else end end |