dbhijacker 0.6.1 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Gemfile.lock +17 -17
  2. data/hijacker.gemspec +2 -2
  3. data/lib/hijacker.rb +12 -7
  4. metadata +4 -4
data/Gemfile.lock CHANGED
@@ -1,22 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dbhijacker (0.6.1)
5
- rails (~> 2.3.14)
4
+ dbhijacker (0.7.1)
5
+ rails (>= 2.3.14)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionmailer (2.3.14)
11
- actionpack (= 2.3.14)
12
- actionpack (2.3.14)
13
- activesupport (= 2.3.14)
10
+ actionmailer (2.3.18)
11
+ actionpack (= 2.3.18)
12
+ actionpack (2.3.18)
13
+ activesupport (= 2.3.18)
14
14
  rack (~> 1.1.0)
15
- activerecord (2.3.14)
16
- activesupport (= 2.3.14)
17
- activeresource (2.3.14)
18
- activesupport (= 2.3.14)
19
- activesupport (2.3.14)
15
+ activerecord (2.3.18)
16
+ activesupport (= 2.3.18)
17
+ activeresource (2.3.18)
18
+ activesupport (= 2.3.18)
19
+ activesupport (2.3.18)
20
20
  columnize (0.3.6)
21
21
  diff-lcs (1.1.3)
22
22
  linecache (0.46)
@@ -24,12 +24,12 @@ GEM
24
24
  rack (1.1.3)
25
25
  rack-test (0.6.1)
26
26
  rack (>= 1.0)
27
- rails (2.3.14)
28
- actionmailer (= 2.3.14)
29
- actionpack (= 2.3.14)
30
- activerecord (= 2.3.14)
31
- activeresource (= 2.3.14)
32
- activesupport (= 2.3.14)
27
+ rails (2.3.18)
28
+ actionmailer (= 2.3.18)
29
+ actionpack (= 2.3.18)
30
+ activerecord (= 2.3.18)
31
+ activeresource (= 2.3.18)
32
+ activesupport (= 2.3.18)
33
33
  rake (>= 0.8.3)
34
34
  rake (0.9.2.2)
35
35
  rbx-require-relative (0.0.5)
data/hijacker.gemspec CHANGED
@@ -3,14 +3,14 @@
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{dbhijacker}
5
5
  s.homepage = "https://github.com/crystalcommerce/hijacker"
6
- s.version = "0.6.1"
6
+ s.version = "0.7.1"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.authors = ["Michael Xavier", "Donald Plummer", "Woody Peterson"]
10
10
  s.date = %q{2012-03-21}
11
11
  s.description = %q{Allows a single Rails appliation to access many different databases}
12
12
  s.email = %q{developers@crystalcommerce.com}
13
- s.add_dependency("rails", "~>2.3.14")
13
+ s.add_dependency("rails", ">= 2.3.14")
14
14
  s.add_development_dependency("rake", "~>0.9.2")
15
15
  s.add_development_dependency("rack-test", "~>0.6.1")
16
16
  s.add_development_dependency("rack", "~>1.1.0")
data/lib/hijacker.rb CHANGED
@@ -90,7 +90,8 @@ module Hijacker
90
90
  aliases = Hijacker::Alias.all(:select => :name).map(&:name)
91
91
 
92
92
  existing_dbs = Host.all.inject(Set.new(aliases)) do |acc, host|
93
- @host_connections[host.hostname] ||= Mysql2::Client.new(root_config.merge('host' => host.hostname))
93
+ @host_connections[host.hostname] ||= Mysql2::Client.new(root_config.merge('host' => host.hostname,
94
+ 'database' => nil))
94
95
  @host_connections[host.hostname].query("SHOW DATABASES").each do |row|
95
96
  acc << row['Database']
96
97
  end
@@ -165,23 +166,27 @@ module Hijacker
165
166
  end
166
167
 
167
168
  def self.root_config
168
- ActiveRecord::Base.configurations['root'].with_indifferent_access
169
+ database_configurations.fetch('root').with_indifferent_access
169
170
  end
170
-
171
+
172
+ def self.database_configurations
173
+ ActiveRecord::Base.configurations
174
+ end
175
+
171
176
  # this should establish a connection to a database containing the bare minimum
172
177
  # for loading the app, usually a sessions table if using sql-based sessions.
173
178
  def self.establish_root_connection
174
179
  ActiveRecord::Base.establish_connection('root')
175
180
  end
176
-
181
+
177
182
  def self.processing_sister_site?
178
183
  !sister.nil?
179
184
  end
180
-
185
+
181
186
  def self.master
182
- @master || ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || RAILS_ENV]['database']
187
+ @master || database_configurations.fetch(ENV['RAILS_ENV'] || RAILS_ENV)['database']
183
188
  end
184
-
189
+
185
190
  def self.current_client
186
191
  sister || master
187
192
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbhijacker
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 6
8
+ - 7
9
9
  - 1
10
- version: 0.6.1
10
+ version: 0.7.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Xavier
@@ -25,7 +25,7 @@ dependencies:
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
- - - ~>
28
+ - - ">="
29
29
  - !ruby/object:Gem::Version
30
30
  hash: 31
31
31
  segments: