7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/pg_migrate/config_parser.rb', line 7
def self.rails(path, environment)
config = {}
rails_config = YAML.load_file(path)
if !rails_config.has_key?(environment)
raise "no environment #{environment} found in rails config file: #{path}"
end
rails_config = rails_config[environment]
if !rails_config.has_key?("database")
raise "no database key found in #{path} with environment #{environment}"
end
config[:dbname] = rails_config["database"]
if rails_config.has_key?("host")
config[:host] = rails_config["host"]
end
if rails_config.has_key?("port")
config[:port] = rails_config["port"]
end
if rails_config.has_key?("username")
config[:user] = rails_config["username"]
end
if rails_config.has_key?("password")
config[:password] = rails_config["password"]
end
return config
end
|