[Rake-devel] ~/.rake file?
luislavena at gmail.com
Fri Aug 22 03:26:06 EDT 2008
On Fri, Aug 22, 2008 at 5:59 AM, Adam Salter <adam.q.salter at gmail.com> 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
> 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,
One-Click Ruby Installer:
ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mswin32]
ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mingw32]
ruby 1.8.6 (2008-04-22 rev 6555) [x86-jruby1.1.1]
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.
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.
More information about the Rake-devel