Sha256: 13156f76a8610fd9d43a6a943458e5fe8ca88e9a4daeaab643a02e341bbd1cce

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'rbconfig'

module Tennpipes
  ##
  # This method return the correct location of tennpipes bin or
  # exec it using Kernel#system with the given args.
  #
  # @param [Array] args
  #   command or commands to execute
  #
  # @return [Boolean]
  #
  # @example
  #   Tennpipes.bin('start', '-e production')
  #
  def self.bin(*args)
    @_tennpipes_bin ||= [self.ruby_command, File.expand_path("../../../bin/tennpipes", __FILE__)]
    args.empty? ? @_tennpipes_bin : system(args.unshift(@_tennpipes_bin).join(" "))
  end

  ##
  # Return the path to the ruby interpreter taking into account multiple
  # installations and windows extensions.
  #
  # @return [String]
  #   path to ruby bin executable
  #
  def self.ruby_command
    @ruby_command ||= begin
      ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
      ruby << RbConfig::CONFIG['EXEEXT']

      # escape string in case path to ruby executable contain spaces.
      ruby.sub!(/.*\s.*/m, '"\&"')
      ruby
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tennpipes-base-3.6.6 lib/tennpipes-base/command.rb