Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse ERB in database.yml #2

Merged
merged 1 commit into from
Apr 16, 2017
Merged

Conversation

ntaylor89
Copy link

Adds the ability to parse ERB nested in config/database.yml, and can
load any any ENV variables that might be declared in the rails ENV.

Basically, we can now understand statements like this:

  username: <% ENV['DB_USERNAME'] %>
  password: <% ENV['DB_PASSWORD'] %>

Adds the ability to parse ERB nested in `config/database.yml`, and can
load any any ENV variables that might be declared in the rails ENV.

Basically, we can now understand statements like this:

```
  username: <% ENV['DB_USERNAME'] %>
  password: <% ENV['DB_PASSWORD'] %>
```
@ntaylor89
Copy link
Author

ntaylor89 commented Apr 16, 2017

I wasn't sure if there's a better way to get the rails ENV than...

require_relative "#{Dir.pwd}/config/environment"

This also means that the command will only work from the root directory of a rails app (though I'm pretty sure that was already the case.

I'd like to add some tests to this in the future, but I'll need to do some brain-thinky-do on how to approach tests here.

require 'optparse'
require_relative "#{Dir.pwd}/config/environment"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if this was the best way to get the rails environment.

Also, I just realized this should probably be

require_relative File.join(Dir.pwd, 'config', 'environment')

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this would be the cleanest way. I'll go ahead and merge though since this PR handles the erb parsing (so it's already a drastic improvement). If you want to clean it up later, feel free to open a PR. Thanks Nate!

@johno
Copy link
Owner

johno commented Apr 16, 2017

Looking epic! 🍻 🎉

Honestly, I'm not too worried about implementing tests here since the scope of the project is still small and they will be lotsa work to set up.

@johno johno merged commit a92f1c9 into johno:master Apr 16, 2017
@johno
Copy link
Owner

johno commented Apr 16, 2017

Published to rubygems as version 0.3.0 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants