Module: TrickBag::System
- Defined in:
- lib/trick_bag/system.rb
Overview
Convenience methods for dealing with Posix-compliant systems.
Class Method Summary collapse
- .command_available?(command) ⇒ Boolean
-
.lsof(options = '') ⇒ Object
Calls lsof to return information about all files *open by this process*.
Class Method Details
.command_available?(command) ⇒ Boolean
21 22 23 24 |
# 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 = '') ⇒ Object
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.
14 15 16 17 18 |
# File 'lib/trick_bag/system.rb', line 14 def lsof( = '') raise "Cannot be called on a non-Posix operating system." unless OS.posix? raise "lsof command not found" unless command_available?('lsof') `lsof #{} -p #{Process.pid}`.split("\n") end |