module TrickBag::System

Convenience methods for dealing with Posix-compliant systems.

Public Instance Methods

command_available?(command) click to toggle source
# File lib/trick_bag/system.rb, line 21
def command_available?(command)
  raise "Cannot be called on a non-Posix operating system." unless OS.posix?
  system("which #{command} > /dev/null")
end
lsof(options = '') click to toggle source
Calls lsof to return information about all files *open by this process*.
Output returned is lsof's output, but after calling split("\n") to create
an array of the result strings.

@param options additional options to the lsof command line, if any, defaults to ''

# File lib/trick_bag/system.rb, line 14
def lsof(options = '')
  raise "Cannot be called on a non-Posix operating system." unless OS.posix?
  raise "lsof command not found" unless command_available?('lsof')
  `lsof #{options} -p #{Process.pid}`.split("\n")
end