otr-activerecord 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/otr-activerecord/activerecord.rb +14 -11
- data/lib/otr-activerecord/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd820c260dab9b0cbef1548223fd8c7173c5cf2995e133e32db0ce2c90c3c427
|
4
|
+
data.tar.gz: 2a170bd9fcaee46df1a0255180cc765eb4145d95fcb1ca7daf63a786cd43518d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c736dd5202985ab80f22318fbdab901c769e009ebc5dfb6b3de3c3be133f767e530222c231000bdef783c9fb3628cdbe69b5c1c3e9191bd1e3d1d5606debf198
|
7
|
+
data.tar.gz: 5e5bfb8062b5ab2508b5057a5b8e222a5f0034a96a3e0a9f632c74ae2e53ba05350c8d30bf84b2e47051deea66a3094dd62721afb6e4d6b731135d1491cea44b
|
@@ -57,18 +57,16 @@ module OTR
|
|
57
57
|
# Connect to database with a yml file. Example: "config/database.yml"
|
58
58
|
def self.configure_from_file!(path)
|
59
59
|
raise "#{path} does not exist!" unless File.file? path
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
if config.
|
64
|
-
|
65
|
-
|
66
|
-
config
|
67
|
-
a[dbname.to_sym] = {"migrations_paths" => ::OTR::ActiveRecord.migrations_paths}.merge subconfig
|
68
|
-
end
|
60
|
+
result =(YAML.safe_load(ERB.new(File.read(path)).result, [], [], true) || {})
|
61
|
+
::ActiveRecord::Base.configurations = begin
|
62
|
+
result.each do |_env, config|
|
63
|
+
if config.all? { |_, v| v.is_a?(Hash) }
|
64
|
+
config.each { |_, v| append_migration_path(v) }
|
65
|
+
else
|
66
|
+
append_migration_path(config)
|
69
67
|
end
|
70
|
-
|
71
|
-
|
68
|
+
end
|
69
|
+
end
|
72
70
|
end
|
73
71
|
|
74
72
|
# Establish a connection to the given db (defaults to current rack env)
|
@@ -76,6 +74,11 @@ module OTR
|
|
76
74
|
::ActiveRecord::Base.establish_connection(db)
|
77
75
|
end
|
78
76
|
|
77
|
+
def self.append_migration_path(config)
|
78
|
+
config['migrations_paths'] = ::OTR::ActiveRecord.migrations_paths unless config.key?('migrations_paths')
|
79
|
+
config
|
80
|
+
end
|
81
|
+
|
79
82
|
# The current Rack environment
|
80
83
|
def self.rack_env
|
81
84
|
(ENV['RACK_ENV'] || ENV['RAILS_ENV'] || ENV['APP_ENV'] || ENV['OTR_ENV'] || 'development').to_sym
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: otr-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|