multi-database-9000 0.3.1 → 0.3.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c941f8e97928fc6d86a81f4b07b552e2d832516f
|
|
4
|
+
data.tar.gz: 114253f571df29eb17201088b45451a20606f10d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ab393c65e0ce9ff0248fa8f58b8e1d608d9f91abf6de8c16f7a2c26f1de8bf4a487c9cda5cbc08ee2a725c863ea42192a68dac2cff16dc1e0781958534d1a89
|
|
7
|
+
data.tar.gz: d15b57dfe902c132efa8823add10f40aa3c1dbf83a411bf4703d92306246a3a00640f26ab8dc53ec9e3bb7e3308e1dba92865b9f598420d0eb71595f7720e526
|
|
@@ -14,42 +14,4 @@ module MultiDatabase9000
|
|
|
14
14
|
return nil unless database.present?
|
|
15
15
|
return ["db/#{database}_migrate"]
|
|
16
16
|
end
|
|
17
|
-
|
|
18
|
-
def database_connections(database: nil, rails_envs: nil)
|
|
19
|
-
connections = connections_for_environment(rails_envs)
|
|
20
|
-
if database.present?
|
|
21
|
-
connections.keep_if {|key, _| key.match Regexp.new(database)}
|
|
22
|
-
end
|
|
23
|
-
return connections
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def connections_for_environment(rails_envs)
|
|
27
|
-
rails_envs = Array(rails_envs)
|
|
28
|
-
matcher = ->(key, value){rails_envs.any?{|env| key.match Regexp.new(env)}}
|
|
29
|
-
return ActiveRecord::Base.configurations.keep_if &matcher
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def database_name(connection_key)
|
|
33
|
-
if connection_key.match /\w+_\w+/
|
|
34
|
-
return connection_key.split('_').first
|
|
35
|
-
else
|
|
36
|
-
return "default"
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def migration_directory(connection_key)
|
|
41
|
-
if ['test','development','staging','cucumber','production'].include? connection_key
|
|
42
|
-
return "db/migrate/"
|
|
43
|
-
else
|
|
44
|
-
return "db/#{database_name(connection_key)}_migrate/"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def schema_file_name(connection_key)
|
|
49
|
-
if ['test','development','staging','cucumber','production'].include? connection_key
|
|
50
|
-
return "schema.rb"
|
|
51
|
-
else
|
|
52
|
-
return "#{database_name(connection_key)}_schema.rb"
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
17
|
end
|
data/lib/multi-database-9000.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: multi-database-9000
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mark Weston
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2015-11-
|
|
13
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: bundler
|