Environment Variables, the Ruby way

Use Nenv for clean access to the environment

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!

--

--

CTO at MuniRent. Sharing my love of code

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