The OS gem allows for some easy telling if you’re on windows or not. as well as some other helper utilities
Latest commit ccbe5f0 Jul 21, 2016 @rdp committed on GitHub Merge pull request #21 from emrekutlu/master
adds freebsd? method
Failed to load latest commit information.
lib adds freebsd? method Feb 12, 2015
spec adds freebsd? method Feb 12, 2015
.autotest autotest: default config. May 14, 2011
.gitignore Fix CRLF May 14, 2011
ChangeLog new version with consistent version number Jul 21, 2016
Gemfile fix dependencies, possible jeweler bug Aug 11, 2011
README.rdoc add space to not confuse Sep 14, 2012
Rakefile Update Rakefile Sep 14, 2012
VERSION new version with consistent version number Jul 21, 2016
os.gemspec new version with consistent version number Jul 21, 2016


The OS gem allows for some easy telling if you're on windows or not.

  require 'os'

  => true   # or OS.doze?

  >> OS.bits
  => 32

  => true # if you're running in jruby.  Also OS.jruby?

  >> OS.ruby_bin
  => "c:\ruby18\bin\ruby.exe" # or "/usr/local/bin/ruby" or what not

  >> OS.posix?
  => false # true for linux, os x, cygwin

  >> OS.mac? # or OS.osx? or OS.x?
  => false

  >> OS.dev_null
  => "NUL" # or "/dev/null" depending on which platform

  >> OS.rss_bytes
  => 12300033 # number of rss bytes this process is using currently.  Basically "total in memory footprint" (doesn't include RAM used by the process that's in swap/page file)

  >> puts
  ==> # a yaml report of helpful values
  arch: x86_64-darwin10.6.0
  target_os: darwin10.6.0
  target_vendor: apple
  target_cpu: x86_64
  target: x86_64-apple-darwin10.6.0
  host_os: darwin10.6.0
  host_vendor: apple
  host_cpu: i386
  host: i386-apple-darwin10.6.0
  RUBY_PLATFORM: x86_64-darwin10.6.0

 >> OS.cpu_count  
 => 2 # number of cores, doesn't include hyper-threaded cores.

>> OS.open_file_command
=> "start" # or open on mac, or xdg-open on linux (all designed to open a file)

=> true # true for cygwin or MRI, whereas is false for cygwin

>> OS::Underlying.bsd?
=> true # true for OS X

If there are any other features you'd like, let me know, I'll do what I can to add them :) for feedback et al

Related projects:


The reason Gem::Platform.local felt wrong to me is that it treated cygwin as windows--which for most build environments, is wrong.  Hence the creation of this gem.

the facets gem (has a class similar to rubygems, above)

require 'facets/platform'

the “platform” gem, itself (a different gem)


License: MIT (see LICENSE file)