yasarg 0.0.1 → 0.0.2
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 +37 -0
- data/lib/yasarg.rb +2 -0
- metadata +2 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Yasarg
|
2
|
+
class Connection
|
3
|
+
class << self
|
4
|
+
def establish
|
5
|
+
require File.expand_path('../../yasarg/rails_fake_app', __FILE__)
|
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
|
+
configuration = Yasarg::RailsFakeApp.config.database_configuration[Rails.env]
|
17
|
+
end
|
18
|
+
|
19
|
+
configuration
|
20
|
+
end
|
21
|
+
|
22
|
+
def heroku_configuration
|
23
|
+
require "uri"
|
24
|
+
db = URI.parse(ENV['DATABASE_URL'])
|
25
|
+
{
|
26
|
+
:adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme,
|
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
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/yasarg.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "rails"
|
3
|
+
require "active_record"
|
3
4
|
|
4
5
|
lib = File.expand_path("../", __FILE__)
|
5
6
|
$:.unshift lib unless $:.include?(lib)
|
@@ -8,3 +9,4 @@ APP_PATH = File.expand_path("#{lib}/yasarg/rails_fake_app", __FILE__)
|
|
8
9
|
|
9
10
|
require "yasarg/rails_fake_app"
|
10
11
|
require "yasarg/tasks"
|
12
|
+
require "yasarg/connection"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yasarg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- VERSION
|
62
62
|
- bin/yasarg
|
63
63
|
- lib/yasarg.rb
|
64
|
+
- lib/yasarg/connection.rb
|
64
65
|
- lib/yasarg/rails_fake_app.rb
|
65
66
|
- lib/yasarg/tasks.rb
|
66
67
|
- yasarg.gemspec
|