grape-activerecord 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17f781a322a34e75dbc4b239f9e0da0b1ccd2764
|
4
|
+
data.tar.gz: 3a95a2017201685364d5d1bee8da528d469c84e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bb3ec6e7c643cc2ec118e5cb690525020ae8654009457b5d6f31c9bfd8e3de1ca4222820e92587fb409ed5479795e7f6f946aefe70b133c81d88ba0a3af6a92
|
7
|
+
data.tar.gz: 5c641bf5f8224c59afc03d5c1b2e1166fa5d12b55515b137382eb368fc2fb49b97388c3c05511aee9ffaaa0866941875b7a84a2c2f22204b5ed75aed73ac9869
|
@@ -13,14 +13,11 @@ module Grape
|
|
13
13
|
attr_accessor :seed_file
|
14
14
|
end
|
15
15
|
|
16
|
-
# The current Rack environment
|
17
|
-
RACK_ENV = (ENV['RACK_ENV'] || 'development').to_sym
|
18
|
-
|
19
16
|
# Connect to database with a Hash. Example:
|
20
17
|
# {adapter: 'postgresql', host: 'localhost', database: 'db', username: 'user', password: 'pass', encoding: 'utf8', pool: 10, timeout: 5000}
|
21
18
|
def self.database=(spec)
|
22
|
-
::ActiveRecord::Base.configurations = {
|
23
|
-
::ActiveRecord::Base.establish_connection(
|
19
|
+
::ActiveRecord::Base.configurations = {rack_env => spec}.stringify_keys
|
20
|
+
::ActiveRecord::Base.establish_connection(rack_env)
|
24
21
|
end
|
25
22
|
|
26
23
|
# Connect to database with a DB URL. Example: "postgres://user:pass@localhost/db"
|
@@ -32,7 +29,12 @@ module Grape
|
|
32
29
|
def self.database_file=(path)
|
33
30
|
raise "#{path} does not exist!" unless File.file? path
|
34
31
|
::ActiveRecord::Base.configurations = YAML.load(ERB.new(File.read(path)).result) || {}
|
35
|
-
::ActiveRecord::Base.establish_connection(
|
32
|
+
::ActiveRecord::Base.establish_connection(rack_env)
|
33
|
+
end
|
34
|
+
|
35
|
+
# The current Rack environment
|
36
|
+
def self.rack_env
|
37
|
+
(ENV['RACK_ENV'] || 'development').to_sym
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
@@ -4,7 +4,7 @@ Rake::Task.define_task('db:_load_config') do
|
|
4
4
|
|
5
5
|
ActiveRecord::Tasks::DatabaseTasks.tap do |config|
|
6
6
|
config.root = Rake.application.original_dir
|
7
|
-
config.env = Grape::ActiveRecord
|
7
|
+
config.env = Grape::ActiveRecord.rack_env.to_s
|
8
8
|
config.db_dir = Grape::ActiveRecord.db_dir
|
9
9
|
config.migrations_paths = Array(Grape::ActiveRecord.migrations_paths)
|
10
10
|
config.fixtures_path = Grape::ActiveRecord.fixtures_path
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|