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 =
"1.0.5"

Class Method Summary collapse

Class Method Details

.new(*sugar) ⇒ Backticks::Command

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

Parameters:

  • sugar (Array)

    list of command words and options

Returns:

See Also:



15
16
17
# File 'lib/backticks.rb', line 15

def self.new(*sugar)
  Backticks::Runner.new.run(*sugar)
end

.run(*sugar) ⇒ String

Run a command with default invocation options; wait for to exit, then return its output. Populate $? with the command’s status before returning.

Parameters:

  • sugar (Array)

    list of command words and options

Returns:

  • (String)

    the command’s output

See Also:



26
27
28
29
30
# File 'lib/backticks.rb', line 26

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

.system(*sugar) ⇒ Boolean

Run a command; return whether it succeeded or failed.

Parameters:

  • sugar (Array)

    list of command words and options

Returns:

  • (Boolean)

    true if the command succeeded; false otherwise

See Also:



38
39
40
41
42
# File 'lib/backticks.rb', line 38

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