Skip to content

Instantly share code, notes, and snippets.

@noriaki
Created April 13, 2013 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noriaki/5378344 to your computer and use it in GitHub Desktop.
Save noriaki/5378344 to your computer and use it in GitHub Desktop.
#!/bin/env ruby
# -*- coding: utf-8; mode: ruby; -*-
require "yaml"
if ARGV.size == 1
config = {}
database_url = ARGV.shift
params = database_url.split("/")
username = params[3]
host = params[2].split("@")[1]
database = username
password = params[2].split("@")[0].split(":")[1]
config["production"] = {
"encoding" => "unicode",
"adapter" => "postgresql",
"username" => username,
"port" => 5432,
"host" => host,
"database" => database,
"password" => password
}
puts config.to_yaml
else
puts "[USAGE] #{__FILE__} SHARED_DATABASE_URL"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment