DbCharmerEnvUrls
DbCharmerEnvUrls extracts database urls from the environment and adds them to ActiveRecord::Base.configurations in a format expected by DbCharmer.
Installation
Add this line to your application's Gemfile:
gem 'db_charmer_env_urls'
And then execute:
$ bundle
Or install it yourself as:
$ gem install db_charmer_env_urls
Usage
DbCharmerEnvUrls parses env variables and adds them to the environment's configuration hash. ENV variables appended with _DATABASE_URL (eg. SLAVE_DATABASE_URL) will be added to the configurations.
[1] pry(main)> ENV
=> {}
[2] pry(main)> ActiveRecord::Base.configurations
{
"production" => {
"adapter" => "postgres",
"database" => "my_database"
}
}
[1] pry(main)> ENV
=> {"SLAVE_DATABASE_URL"=>"postgres://localhost:5432/name?encoding=UTF-8"}
[2] pry(main)> ActiveRecord::Base.configurations
{
"production" => {
"adapter" => "postgres",
"database" => "my_database",
"slave" => {
"adapter" => "postgres",
"host" => "localhost",
"port" => 5432,
"database" => "name",
"encoding" => "UTF-8"
}
}
}
Contributing
- Fork it ( https://github.com/[my-github-username]/db_charmer_env_urls/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request