platform.rb

Path: sprout/lib/platform.rb
Last Update: Fri Aug 07 21:52:02 -0700 2009

platform.rb: naive platform detection for Ruby author: Matt Mower

Platform

Platform is a simple module which parses the Ruby constant RUBY_PLATFORM and works out the OS, it‘s implementation, and the architecture it‘s running on.

The motivation for writing this was coming across a case where

+if RUBY_PLATFORM =~ /win/+

didn‘t behave as expected (i.e. on powerpc-darwin-8.1.0)

It is hoped that providing a library for parsing the platform means that we can cover all the cases and have something which works reliably 99% of the time.

Please report any anomalies or new combinations to the author(s).

Use

require "platform"

defines

Platform::OS (:unix,:win32,:vms,:os2) Platform::impl (:macosx,:linux,:mswin) Platform::arch (:powerpc,:x86,:alpha)

if an unknown configuration is encountered any (or all) of these constant may have the value :unknown.

To display the combination for your setup run

ruby platform.rb

[Validate]