yasarg 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/yasarg/connection.rb +1 -25
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/yasarg/connection.rb
CHANGED
@@ -4,33 +4,9 @@ module Yasarg
|
|
4
4
|
def establish
|
5
5
|
require File.expand_path('../../yasarg/rails_fake_app', __FILE__)
|
6
6
|
if !ActiveRecord::Base.connected?
|
7
|
-
ActiveRecord::Base.establish_connection(configuration)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def configuration
|
12
|
-
configuration = {}
|
13
|
-
if ENV["DATABASE_URL"]# heroku
|
14
|
-
configuration = heroku_configuration
|
15
|
-
else
|
16
7
|
configuration = Yasarg::RailsFakeApp.config.database_configuration[Rails.env]
|
8
|
+
ActiveRecord::Base.establish_connection(configuration)
|
17
9
|
end
|
18
|
-
|
19
|
-
configuration
|
20
|
-
end
|
21
|
-
|
22
|
-
def heroku_configuration
|
23
|
-
require "uri"
|
24
|
-
db = URI.parse(ENV['DATABASE_URL'])
|
25
|
-
{
|
26
|
-
:adapter => 'postgresql',
|
27
|
-
:host => db.host,
|
28
|
-
:port => db.port,
|
29
|
-
:username => db.user,
|
30
|
-
:password => db.password,
|
31
|
-
:database => db.path[1..-1],
|
32
|
-
:encoding => 'utf8'
|
33
|
-
}
|
34
10
|
end
|
35
11
|
end
|
36
12
|
end
|