On Fri, Aug 22, 2008 at 5:59 AM, Adam Salter <[EMAIL PROTECTED]> wrote: > > On 16/08/2008, at 1:54 AM, Berger, Daniel wrote: > >> Don't do this: >> >> PLATFORM =~ /win32/ >> >> First, PLATFORM is deprecated instead of RUBY_PLATFORM. But, with the >> advent of alternative implementations like Jruby and IronRuby, >> RUBY_PLATFORM is no longer a wise approach. Jruby, for example, will >> return 'java' for the RUBY_PLATFORM, even if you're on Windows. >> >> Use rbconfig + host_os instead: >> >> require 'rbconfig' >> >> if Config::CONFIG['host_os'] =~ /mswin/I >> ... > > > Can someone please confirm that this is the "absolute" best way to check for > Windows? There was some discussion that there would be different reports for > MinGW... > > Pending confirmation I'm going to use this method. >
Let's make it simple, shall we? D:\Users\Luis>ruby -rrbconfig -ve "puts RUBY_PLATFORM, RbConfig::CONFIG['host_os']" One-Click Ruby Installer: ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mswin32] i386-mswin32 mswin32 MinGW build: ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mingw32] i386-mingw32 mingw32 jRuby: ruby 1.8.6 (2008-04-22 rev 6555) [x86-jruby1.1.1] java mswin32 So: RUBY_PLATFORM is almost the same than host_os, except for jRuby. To clear up: the regular expression for Ruby on Windows will be: /mswin|mingw/ Use RbConfig::CONFIG['host_os'] to collect that information. > Thanks, > -Adam HTH, -- Luis Lavena AREA 17 - Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. Douglas Adams _______________________________________________ Rake-devel mailing list [email protected] http://rubyforge.org/mailman/listinfo/rake-devel
