How to get operating system type info

Hi Guys,

I’m writing a software building script in Ruby for Unix and Windows.

I want to know the type of the platform that my script is running on -
whether it’s Windows, Linux or MacOSX. I need to do something special
for different os.

Is there any way to get this without hacking by myself? Google gave me
nothing useful.

Thanks,
D

Dao Shi wrote:

Thanks,
D

The RUBY_PLATFORM constant is what you want.

irb(main):001:0> RUBY_PLATFORM
=> “i386-mswin32”

Ken

Dao Shi wrote:

Hi Guys,

I’m writing a software building script in Ruby for Unix and Windows.

I want to know the type of the platform that my script is running on -
whether it’s Windows, Linux or MacOSX. I need to do something special
for different os.

Is there any way to get this without hacking by myself? Google gave me
nothing useful.

puts RUBY_PLATFORM

Thanks Ken and Paul!

This is exactly what I need.

BTW I think this might be helpful for others as well.

And is this a bug here?

rdoc/options.rb line 536 :

Check that the right version of ‘dot’ is available.

Unfortuately this doesn’t work correctly under Windows NT,

so we’ll bypass the test under Windows

def check_diagram
return if RUBY_PLATFORM =~ /win/

darwin will match this too…

On Dec 3, 2006, at 12:00 , Dao Shi wrote:

rdoc/options.rb line 536 :

Check that the right version of ‘dot’ is available.

Unfortuately this doesn’t work correctly under Windows NT,

so we’ll bypass the test under Windows

def check_diagram
return if RUBY_PLATFORM =~ /win/

Yes, should be /mswin/.

Please file a bug:

http://rubyforge.org/tracker/?func=add&group_id=627&atid=2472


Eric H. - [email protected] - http://blog.segment7.net

I LIT YOUR GEM ON FIRE!