I noticed that the PLATFORM and RUBY_PLATFORM constants returns the same string when running from MRI as from IronRuby. Is there a standard Ruby constant or Kernel method or something that will indicate that the interpreter is IronRuby as opposed to MRI? While it is certainly true that the OS is the same when running from both environments, it would seem pretty useful to me to be able to distinguish, as JRuby does, so we can write libraries that can selectively do things like selectively take advantage of the .NET BCL if present. There are probably easy enough ways to work around this, like ''begin require System @platform="ir" rescue LoadError end'' but using PLATFORM directly feels like it would be more elegant. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091029/6292b500/attachment.html>
You can use this construct:>>> defined? RUBY_ENGINE and RUBY_ENGINE == "ironruby"=> true From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Nathan Stults Sent: Thursday, October 29, 2009 12:26 AM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] Platform I noticed that the PLATFORM and RUBY_PLATFORM constants returns the same string when running from MRI as from IronRuby. Is there a standard Ruby constant or Kernel method or something that will indicate that the interpreter is IronRuby as opposed to MRI? While it is certainly true that the OS is the same when running from both environments, it would seem pretty useful to me to be able to distinguish, as JRuby does, so we can write libraries that can selectively do things like selectively take advantage of the .NET BCL if present. There are probably easy enough ways to work around this, like ''begin require System @platform="ir" rescue LoadError end'' but using PLATFORM directly feels like it would be more elegant. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091029/385e423c/attachment.html>
I use IRONRUBY_VERSION require ''caricature/clr'' if defined?(IRONRUBY_VERSION) But we do need to find a way to "fix" the rbconfig file because it would be good to interrogate that sometimes. --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Thu, Oct 29, 2009 at 8:25 AM, Nathan Stults <Nathan_Stults at hsihealth.com>wrote:> I noticed that the PLATFORM and RUBY_PLATFORM constants returns the same > string when running from MRI as from IronRuby. Is there a standard Ruby > constant or Kernel method or something that will indicate that the > interpreter is IronRuby as opposed to MRI? While it is certainly true that > the OS is the same when running from both environments, it would seem pretty > useful to me to be able to distinguish, as JRuby does, so we can write > libraries that can selectively do things like selectively take advantage of > the .NET BCL if present. There are probably easy enough ways to work around > this, like ?begin require System @platform=?ir? rescue LoadError end? but > using PLATFORM directly feels like it would be more elegant. > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091029/7072c109/attachment.html>
Very nice, thank you From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Shri Borde Sent: Thursday, October 29, 2009 12:29 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Platform You can use this construct:>>> defined? RUBY_ENGINE and RUBY_ENGINE == "ironruby"=> true From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Nathan Stults Sent: Thursday, October 29, 2009 12:26 AM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] Platform I noticed that the PLATFORM and RUBY_PLATFORM constants returns the same string when running from MRI as from IronRuby. Is there a standard Ruby constant or Kernel method or something that will indicate that the interpreter is IronRuby as opposed to MRI? While it is certainly true that the OS is the same when running from both environments, it would seem pretty useful to me to be able to distinguish, as JRuby does, so we can write libraries that can selectively do things like selectively take advantage of the .NET BCL if present. There are probably easy enough ways to work around this, like ''begin require System @platform="ir" rescue LoadError end'' but using PLATFORM directly feels like it would be more elegant. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091029/7ebeb2b5/attachment.html>