Open Source ProjectsCode that Might be Useful to You

Talks I've GivenOn Technologies and Ideas

ThoughtsWhere I Sometimes Write Things

Resume If You Believe In Those

Follow Me On

GitHubIf coding is your thing

TwitterIf you tweet

Spelunking your Ruby install's configuration with RbConfig

Let me tell you, there is this thing called RbConfig, and it has a treasure trove of information about the configuration of your Ruby installation. Even better is that it comes as part of a stock Ruby installation, so no addition gems are required.

Here’s a quick example: I need to know the operating system my ruby code is running, and react accordingly.

require 'rbconfig'

# snip my otherwise flawless code
if RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin/i
  # insert hacks for windows
# snip more otherwise flawless code

For a complete list of configuration details it contains, I’d suggest busting out an irb, and poking around.

I’d love to go into further detail, but alas, all my past attempts at digging up more information have failed. I only came across it by chance while trying to figure out how to detect if I was on Windows for jeweler, but even then, it was only code examples that I came across.

What I do know, is that it contains information gathered at the time that you configure and build Ruby.

comments powered by Disqus