Module: Backticks

Defined in:
lib/backticks.rb,
lib/backticks/cli.rb,
lib/backticks/ext.rb,
lib/backticks/runner.rb,
lib/backticks/command.rb,
lib/backticks/version.rb

Defined Under Namespace

Modules: CLI, Ext Classes: Command, Runner

Constant Summary collapse

VERSION =
"0.3.1"

Class Method Summary collapse

Class Method Details

.new(cmd) ⇒ Backticks::Command

Run a command; return a Command object that can be used to interact with the running process.

Parameters:

  • cmd (String)

Returns:



13
14
15
# File 'lib/backticks.rb', line 13

def self.new(cmd)
  Backticks::Runner.new.command(cmd)
end

.run(cmd) ⇒ String

Run a command; return its stdout.

Parameters:

  • cmd (String)

Returns:

  • (String)

    the command’s output



21
22
23
24
25
# File 'lib/backticks.rb', line 21

def self.run(cmd)
  command = self.new(*cmd)
  command.join
  command.captured_output
end

.system(*cmd) ⇒ Boolean

Run a command; return its success or failure.

Parameters:

  • cmd (String)

Returns:

  • (Boolean)

    true if the command succeeded; false otherwise



31
32
33
34
35
# File 'lib/backticks.rb', line 31

def self.system(*cmd)
  command = self.new(*cmd)
  command.join
  $?.success?
end