# Smart(er) platform detection

**URL:** <https://rubytalk.org/t/smart-er-platform-detection/19244>\
**Category:** ruby-talk\
**Created:** [29 June 2005 13:54 UTC](https://rubytalk.org/t/smart-er-platform-detection/19244 "2005-06-29T13:54:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Berger\_Daniel1](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@Berger\_Daniel1](https://rubytalk.org/u/Berger_Daniel1)\
**Post date:** [29 June 2005 13:54 UTC](https://rubytalk.org/t/smart-er-platform-detection/19244/1 "2005-06-29T13:54:11Z")

</div>

Please see sys-uname.

Regards,

Dan

> **···**
>
> > -----Original Message-----  
> > From: Matt Mower [mailto:matt.mower@gmail.com]  
> > Sent: Wednesday, June 29, 2005 4:16 AM  
> > To: ruby-talk ML  
> > Subject: Smart(er) platform detection
> > 
> > Hi folks,
> > 
> > I recently got bitten by some code which uses an idiom like:
> > 
> > if RUBY\_PLATFORM =~ /win/i  
> > &nbsp;&nbsp;# windows stuff here  
> > end
> > 
> > which is fine until you try it on a machine (like my shiny new  
> > PowerBook) whose platform string is:
> > 
> > &nbsp;&nbsp;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:

---

<div class="post-metadata">

**Author:** ![Matt\_Mower](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Matt\_Mower](https://rubytalk.org/u/Matt_Mower)\
**Post date:** [29 June 2005 14:02 UTC](https://rubytalk.org/t/smart-er-platform-detection/19244/2 "2005-06-29T14:02:25Z")

</div>

Hi Dan,

> Please see sys-uname.

Thanks for the pointer. I did actually look for a library by you  
because someone mentioned in IRC that you'd done something along these  
lines.

It seems like this provides a lot better information than I can get  
from RUBY\_PLATFORM but is in the form of a C extension which doesn't  
suit me. It might be exactly right for some other folks though.

Regards,

Matt

> **···**
>
> On 6/29/05, Berger, Daniel \<Daniel.Berger@qwest.com\> wrote:
> 
> --  
> Matt Mower :: [http://matt.blogs.it/](http://matt.blogs.it/)

---

<div class="post-metadata">

**Author:** ![Berger\_Daniel1](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@Berger\_Daniel1](https://rubytalk.org/u/Berger_Daniel1)\
**Post date:** [29 June 2005 14:05 UTC](https://rubytalk.org/t/smart-er-platform-detection/19244/3 "2005-06-29T14:05:10Z")

</div>

Matt Mower wrote:

> Hi Dan,
> 
> > Please see sys-uname.
> 
> Thanks for the pointer. I did actually look for a library by you  
> because someone mentioned in IRC that you'd done something along these  
> lines.
> 
> It seems like this provides a lot better information than I can get  
> from RUBY\_PLATFORM but is in the form of a C extension which doesn't  
> suit me. It might be exactly right for some other folks though.
> 
> Regards,
> 
> Matt

If it helps soothe your mind, the Win32 version is pure Ruby. 🙂

Regards,

Dan

PS - I updated the description of sys-uname on the RAA, so hopefully folks will discover it a little easier in the future.

> **···**
>
> > On 6/29/05, Berger, Daniel \<Daniel.Berger@qwest.com\> wrote:

---

<div class="post-metadata">

**Author:** ![BG\_Ben\_Armstrong](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@BG\_Ben\_Armstrong](https://rubytalk.org/u/BG_Ben_Armstrong)\
**Post date:** [29 June 2005 14:25 UTC](https://rubytalk.org/t/smart-er-platform-detection/19244/4 "2005-06-29T14:25:45Z")

</div>

But that fact doesn't help the VMS port, since the Win32 version depends  
on OLE.

Ben

> **···**
>
> On Wed, 2005-06-29 at 23:05 +0900, Daniel Berger wrote:
> 
> > If it helps soothe your mind, the Win32 version is pure Ruby. 🙂

---

<div class="post-metadata">

**Author:** ![Matt\_Mower](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Matt\_Mower](https://rubytalk.org/u/Matt_Mower)\
**Post date:** [29 June 2005 14:49 UTC](https://rubytalk.org/t/smart-er-platform-detection/19244/5 "2005-06-29T14:49:21Z")

</div>

> \> It seems like this provides a lot better information than I can get  
> \> from RUBY\_PLATFORM but is in the form of a C extension which doesn't  
> \> suit me. It might be exactly right for some other folks though.  
> \>  
> If it helps soothe your mind, the Win32 version is pure Ruby. 🙂

I'm not clear what this means. Can it be distributed as a gem for use  
on Windows ,Unix, and other platforms?

> PS - I updated the description of sys-uname on the RAA, so hopefully  
> folks will discover it a little easier in the future.

That's a good idea.

M

> **···**
>
> On 6/29/05, Daniel Berger \<Daniel.Berger@qwest.com\> wrote:
> 
> --  
> Matt Mower :: [http://matt.blogs.it/](http://matt.blogs.it/)
