Environment Variables, the Ruby way

Use Nenv for clean access to the environment

Julien Vanier
Jan 17, 2015 · 1 min read

Ruby is a beautiful language. Programs written in Ruby are expressive and easy to read.

So when it comes time to use environment variables in Ruby, it looks like the program is screaming at you with all caps. Add the fact that there everybody handles boolean environment variables differently — should you compare to ‘true’, ‘TRUE’, ‘yes’, ‘1' or all of them—and you will see that there is room for improvements.

What if the env var is set to ‘TRUE’?

A new gem called Nenv makes it all go away. It provides several Ruby-isms for dealing with environment variables.

It makes checking boolean environment variables expressive and beautiful.

Doesn’t matter if it’s ‘1', ‘TRUE’ or ‘yes’

It makes configuring packages from the environment pretty by adding the concept of namespaces to groups of variables that share the same prefix.

Get that clean feeling!

So go ahead, make your code beautiful and add Nenv to your Gemfile today!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store