Sha256: 787e16da1191b61a8b21e91c5e5afdd48a44c4f943fe606225aabac6e7a0d95a

Contents?: true

Size: 1.53 KB

Versions: 10

Compression:

Stored size: 1.53 KB

Contents

require_relative 'backticks/version'
require_relative 'backticks/cli'
require_relative 'backticks/command'
require_relative 'backticks/runner'
require_relative 'backticks/ext'

module Backticks
  # Run a command with default invocation options; return a Command object that
  # can be used to interact with the running process.
  #
  # @param [Array] sugar list of command words and options
  # @return [Backticks::Command] a running command
  # @see Backticks::Runner#run for a better description of sugar
  # @see Backticks::Runner for more control over process invocation
  def self.new(*sugar)
    Backticks::Runner.new.run(*sugar)
  end

  # Run a command with default invocation options; wait for to exit, then return
  # its output. Populate $? with the command's status before returning.
  #
  # @param [Array] sugar list of command words and options
  # @return [String] the command's output
  # @see Backticks::Runner#run for a better description of sugar
  # @see Backticks::Runner for more control over process invocation
  def self.run(*sugar)
    command = self.new(*sugar)
    command.join
    command.captured_output
  end

  # Run a command; return whether it succeeded or failed.
  #
  # @param [Array] sugar list of command words and options
  # @return [Boolean] true if the command succeeded; false otherwise
  # @see Backticks::Runner#run for a better description of sugar
  # @see Backticks::Runner for more control over process invocation
  def self.system(*sugar)
    command = self.new(*sugar)
    command.join
    $?.success?
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
backticks-1.0.5 lib/backticks.rb
backticks-1.0.4 lib/backticks.rb
backticks-1.0.3 lib/backticks.rb
backticks-1.0.2 lib/backticks.rb
backticks-1.0.1 lib/backticks.rb
backticks-1.0.0 lib/backticks.rb
backticks-1.0.0rc2 lib/backticks.rb
backticks-1.0.0rc1 lib/backticks.rb
backticks-0.5.0 lib/backticks.rb
backticks-0.4.0 lib/backticks.rb