Quick-and-dirty substitute for OS gem.
Running on BSD Unix?
# File hack_os.rb, line 42 def self.bsd? host_os =~ /bsd/ end
Return the value of 'host_os' in the Ruby configuration.
# File hack_os.rb, line 7 def self.host_os RbConfig::CONFIG['host_os'] end
Running on Linux?
# File hack_os.rb, line 37 def self.linux? host_os =~ /linux/ end
Running on Mac Os?
# File hack_os.rb, line 32 def self.mac? host_os =~ /darwin/ end
Categorize the host OS as Windows, Mac, Linux, BSD, or unknown.
# File hack_os.rb, line 12 def self.os_category if OS.windows? then "Windows" elsif OS.mac? "Mac OS" elsif OS.linux? "Linux" elsif OS.bsd? "BSD Unix" else "UNKNOWN" end end
Running on a POSIX system?
# File hack_os.rb, line 47 def self.posix? OS::mac? or OS::linux? or OS::bsd? end
Running on Windows?
# File hack_os.rb, line 27 def self.windows? host_os =~ /mswin|mingw|cygwin|win32|dos|bccwin|wince|emx/ end