3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/activerecord_url_connections.rb', line 3
def self.parse(str)
if str =~ %r{//}
config = URI.parse(str)
adapter = config.scheme
adapter = "postgresql" if adapter == "postgres"
spec = { :adapter => adapter,
:username => config.user,
:password => config.password,
:port => config.port,
:database => config.path.sub(%r{^/},""),
:host => config.host }
spec.reject!{ |key,value| value.nil? }
spec.merge!(split_query_options(config.query))
spec
else
str
end
rescue URI::InvalidURIError
return nil
end
|