module CmdExecutable

Command Executable

Usage:

require 'cmd_executable'

class Klass
  include CmdExecutable

  def instance_method
    executable?('ls')
  end
end

Constants

VERSION

Public Class Methods

executable?(command) click to toggle source
# File lib/cmd_executable.rb, line 49
def self.executable?(command)
  parsed = CmdExecutable::Parser.new(command)
  raise CmdExecutable::ParserError, parsed.raw unless parsed.validate?

  `type "#{parsed.command}" > /dev/null 2>&1`.yield_self do
    $CHILD_STATUS.success?
  end
end

Public Instance Methods

executable?(command) click to toggle source
# File lib/cmd_executable.rb, line 45
def executable?(command)
  CmdExecutable.executable?(command)
end