Coder Social home page Coder Social logo

emrekutlu / os Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rdp/os

0.0 2.0 0.0 165 KB

The OS gem allows for some easy telling if you’re on windows or not. OS.windows? as well as some other helper utilities

License: MIT License

Ruby 100.00%

os's Introduction

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

  require 'os'

  >> OS.windows?
  => true   # or OS.doze?

  >> OS.bits
  => 32

  >> OS.java?
  => 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 OS.report
  ==> # 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)

>> OS::Underlying.windows?
=> true # true for cygwin or MRI, whereas OS.windows? 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 :)

github.com/rdp/os for feedback et al

Related projects:

rubygems:

Gem::Platform.local
Gem.ruby
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'
Platform.local

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

FFI::Platform::OS

http://rubydoc.info/github/ffi/ffi/master/FFI/Platform

License: MIT (see LICENSE file)

os's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.