From: Robert Klemme Date: 2005-06-29T21:45:41+09:00 Subject: Re: Smart(er) platform detection Matt Mower wrote: > Hi folks, > > I recently got bitten by some code which uses an idiom like: > > if RUBY_PLATFORM =~ /win/i > # windows stuff here > end > > which is fine until you try it on a machine (like my shiny new > PowerBook) whose platform string is: > > powerpc-darwin-8.1.0 > > I looked around and couldn't find a systematic solution to getting > useful information from RUBY_PLATFORM so I quickly hacked something > together which you can find described at: > > http://matt.blogs.it/2005/06/29.html#a1882 > > at the moment it's a single require to get definitions of: > > Platform::OS (e.g. :unix or :win32) > Platform::IMPL (e.g. :macosx or :mingw) > Platform::ARCH (e.g. :powerpc or :x86) > > or :unknown if it can't figure your platform out. > > I'd be very grateful if everyone on the list would please take a > moment download the 'platform.rb' code and run it as 'ruby > platform.rb' and check that it prints out sensible values for ::OS, >>> IMPL, and ::ARCH. > > If not please either reply here or in a comment to the post including > the output of > > ruby -e 'puts RUBY_PLATFORM' > > and what you would expect ::OS, ::IMPL, and ::ARCH to be for your > platform. > > I'd like to get as comprehensive coverage as possible and then release > this as a library that people can depend upon for detecting platform > differences. 14:40:33 [cg-tsp-hq]: cmd /c ver Microsoft Windows 2000 [Version 5.00.2195] 14:40:58 [cg-tsp-hq]: uname -a CYGWIN_NT-5.0 bond 1.5.17(0.129/4/2) 2005-05-25 19:38 i686 unknown unknown Cygwin 14:41:00 [cg-tsp-hq]: ruby /c/temp/ruby/platform.rb Platform OS=unix, IMPL=cygwin, ARCH=x86 14:41:04 [cg-tsp-hq]: Looks pretty much ok IMHO. Does anybody think cygwin should not be reported as "unix"? Kind regards robert