Module: Os
- Defined in:
- lib/specs.rb
Overview
Get the basic operating system name reliably, even in JRuby Useful for OS-contextual command line instructions.
E.g., ‘C:Program Files (x86)Mozilla Firefoxfirefox –version’ in Windows vs
'/Applications/Firefox.app/Contents/MacOS/firefox --version' in Mac vs
'firefox --version' in Unix
Class Method Summary collapse
- .haiku? ⇒ Boolean
- .linux? ⇒ Boolean
- .mac? ⇒ Boolean
- .mingw? ⇒ Boolean
- .os_name ⇒ Object
- .raw ⇒ Object
- .unix? ⇒ Boolean
- .windows? ⇒ Boolean
- .x86? ⇒ Boolean
- .x86_64? ⇒ Boolean
Class Method Details
.haiku? ⇒ Boolean
79 80 81 |
# File 'lib/specs.rb', line 79 def self.haiku? raw =~ /haiku/ end |
.linux? ⇒ Boolean
84 85 86 |
# File 'lib/specs.rb', line 84 def self.linux? self.unix? && !(self.mac? || self.haiku?) end |
.mac? ⇒ Boolean
69 70 71 |
# File 'lib/specs.rb', line 69 def self.mac? raw =~ /darwin/ end |
.mingw? ⇒ Boolean
64 65 66 |
# File 'lib/specs.rb', line 64 def self.mingw? raw =~ /cygwin|mingw/ end |
.os_name ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/specs.rb', line 99 def self.os_name if self.windows? :windows elsif self.mac? :mac elsif self.linux? :linux elsif self.haiku? :haiku else :unix end end |
.raw ⇒ Object
50 51 52 53 |
# File 'lib/specs.rb', line 50 def self.raw # Config deprecated in Ruby 1.9 RbConfig::CONFIG['host_os'] end |
.unix? ⇒ Boolean
74 75 76 |
# File 'lib/specs.rb', line 74 def self.unix? !self.windows? end |
.windows? ⇒ Boolean
59 60 61 |
# File 'lib/specs.rb', line 59 def self.windows? raw =~ /cygwin|mswin|mingw|bccwin|wince|emx/ end |
.x86? ⇒ Boolean
94 95 96 |
# File 'lib/specs.rb', line 94 def self.x86? !self.x86_64? end |
.x86_64? ⇒ Boolean
89 90 91 |
# File 'lib/specs.rb', line 89 def self.x86_64? RbConfig::CONFIG['arch'] =~ /64/ end |