shackles 1.0.10 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZWVlZWFiZGEwOTFjMDhmZTJiOWFhMWMyZTVhZGUzZmI5OWIxMzVjNw==
5
- data.tar.gz: !binary |-
6
- NGU0ZjEzYWI5OGZiZTk2ZWVlZDliYWMzNTY1Njg5OTI0NTU4YmZkMQ==
2
+ SHA1:
3
+ metadata.gz: 71107d30a7307374ffbf19d585bcfcfdc7be7cd2
4
+ data.tar.gz: eb3b93f08eb0aaad52dd3c790ad90e2c25bb7006
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MjdhNWRhZWQwOWM0MDUzOTE2OGYyOTU4Yjc0NWZkMmM0ZDEzMTAzMzA3Zjdm
10
- NDZiYTIxY2JiMzc2NWU2MGRiODMwYzExMzBjNzNmMmY1YWI0Y2QzNmFiMjFl
11
- YTYzYjM3MDYyZjE2ZDRjNWJkMGM4ZDE5MmNjOTIxNzM5OWQ2YWU=
12
- data.tar.gz: !binary |-
13
- NDUyNjcwYjJjOTExM2U4MTM4Zjc4NGY5NWJlNzY1ODJkMTdmNGFlMzlmY2Zm
14
- NDMzNWY2ODRkODhhMjg5Y2ZkNTA3MTZlZjdiMTNhZDBlNmJhNWVhNTVhODk3
15
- MTM4NDQ0MTQ4OTM4MmFjZjZiMmU2M2MxMjY0ZGZiYzYwMzcyNjc=
6
+ metadata.gz: af803e0e4278db28f9c00ebfdd06218262ab048e1a44cd56dbb227adef84d9fd29036dd4b48627e5f611329a3258564d55b2ee1eae35e35e8e61769949cc3dd7
7
+ data.tar.gz: 8ce9c41baa33ea174084017662d9f87549bcae1a46d34caa5ffae54c81fa51e7cd86192c69aad912417dc7980321aacf23e110a7ef35db75c37a77e2439415d7
data/lib/shackles.rb CHANGED
@@ -22,9 +22,8 @@ module Shackles
22
22
 
23
23
  activated_environments << Shackles.environment
24
24
 
25
- ActiveRecord::ConnectionAdapters::ConnectionHandler.send(:include, ConnectionHandler)
26
- klass = Rails.version < '4' ? ActiveRecord::Base : ActiveRecord::ConnectionAdapters
27
- klass::ConnectionSpecification.send(:include, ConnectionSpecification)
25
+ ActiveRecord::ConnectionAdapters::ConnectionHandler.prepend(ConnectionHandler)
26
+ ActiveRecord::ConnectionAdapters::ConnectionSpecification.prepend(ConnectionSpecification)
28
27
  end
29
28
 
30
29
  def global_config_sequence
@@ -89,15 +88,9 @@ module Shackles
89
88
  new_handler = @connection_handlers[environment]
90
89
  if !new_handler
91
90
  new_handler = @connection_handlers[environment] = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
92
- pools = if Rails.version < '3.0'
93
- ActiveRecord::Base.connection_handler.instance_variable_get(:@connection_pools)
94
- elsif Rails.version < '4.0'
95
- ActiveRecord::Base.connection_handler.instance_variable_get(:@class_to_pool)
96
- else
97
- ActiveRecord::Base.connection_handler.send(:owner_to_pool)
98
- end
91
+ pools = ActiveRecord::Base.connection_handler.send(:owner_to_pool)
99
92
  pools.each_pair do |model, pool|
100
- model = model.constantize if Rails.version >= '4'
93
+ model = model.constantize
101
94
  new_handler.establish_connection(model, pool.spec)
102
95
  end
103
96
  end
@@ -1,16 +1,13 @@
1
1
  module Shackles
2
2
  module ConnectionHandler
3
- def self.included(klass)
4
- %w{clear_active_connections clear_reloadable_connections
5
- clear_all_connections verify_active_connections }.each do |method|
6
- next unless klass.instance_methods.include?("#{method}!".to_sym)
7
- klass.class_eval(<<EOS, __FILE__, __LINE__ + 1)
8
- def #{method}_with_multiple_environments!
9
- ::Shackles.connection_handlers.values.each(&:#{method}_without_multiple_environments!)
10
- end
11
- EOS
12
- klass.alias_method_chain "#{method}!".to_sym, :multiple_environments
13
- end
3
+ %w{clear_active_connections clear_reloadable_connections
4
+ clear_all_connections verify_active_connections }.each do |method|
5
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
6
+ def #{method}!(super_method: false)
7
+ return super() if super_method
8
+ ::Shackles.connection_handlers.values.each { |handler| handler.#{method}!(super_method: true) }
9
+ end
10
+ RUBY
14
11
  end
15
12
  end
16
13
  end
@@ -31,13 +31,8 @@ module Shackles
31
31
  end
32
32
  end
33
33
 
34
- def self.included(klass)
35
- klass.send(:remove_method, :config)
36
- klass.alias_method_chain :initialize, :deep_symbolize
37
- end
38
-
39
- def initialize_with_deep_symbolize(config, adapter_method)
40
- initialize_without_deep_symbolize(config.deep_symbolize_keys, adapter_method)
34
+ def initialize(config, adapter_method)
35
+ super(config.deep_symbolize_keys, adapter_method)
41
36
  end
42
37
 
43
38
  def config
@@ -1,3 +1,3 @@
1
1
  module Shackles
2
- VERSION = "1.0.10"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'active_record'
2
+ require 'byebug'
2
3
  require 'rails'
3
4
  require 'shackles'
4
5
 
@@ -10,9 +11,7 @@ RSpec.configure do |config|
10
11
  end
11
12
 
12
13
  describe Shackles do
13
- ConnectionSpecification = Rails.version < '4' ?
14
- ActiveRecord::Base::ConnectionSpecification :
15
- ActiveRecord::ConnectionAdapters::ConnectionSpecification
14
+ ConnectionSpecification = ActiveRecord::ConnectionAdapters::ConnectionSpecification
16
15
 
17
16
  it "should allow changing environments" do
18
17
  conf = {
metadata CHANGED
@@ -1,61 +1,103 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shackles
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-29 00:00:00.000000000 Z
11
+ date: 2016-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
20
- - - <
19
+ version: '4.0'
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '4.3'
22
+ version: '5.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ! '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '3.2'
30
- - - <
29
+ version: '4.0'
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '4.3'
32
+ version: '5.1'
33
+ - !ruby/object:Gem::Dependency
34
+ name: appraisal
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: byebug
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
33
61
  - !ruby/object:Gem::Dependency
34
62
  name: mocha
35
63
  requirement: !ruby/object:Gem::Requirement
36
64
  requirements:
37
- - - ! '>='
65
+ - - ">="
38
66
  - !ruby/object:Gem::Version
39
67
  version: '0'
40
68
  type: :development
41
69
  prerelease: false
42
70
  version_requirements: !ruby/object:Gem::Requirement
43
71
  requirements:
44
- - - ! '>='
72
+ - - ">="
45
73
  - !ruby/object:Gem::Version
46
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '2.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '2.0'
47
89
  - !ruby/object:Gem::Dependency
48
90
  name: sqlite3
49
91
  requirement: !ruby/object:Gem::Requirement
50
92
  requirements:
51
- - - ! '>='
93
+ - - ">="
52
94
  - !ruby/object:Gem::Version
53
95
  version: '0'
54
96
  type: :development
55
97
  prerelease: false
56
98
  version_requirements: !ruby/object:Gem::Requirement
57
99
  requirements:
58
- - - ! '>='
100
+ - - ">="
59
101
  - !ruby/object:Gem::Version
60
102
  version: '0'
61
103
  description: Allows multiple environments in database.yml, and dynamically switching
@@ -84,17 +126,17 @@ require_paths:
84
126
  - lib
85
127
  required_ruby_version: !ruby/object:Gem::Requirement
86
128
  requirements:
87
- - - ! '>='
129
+ - - ">="
88
130
  - !ruby/object:Gem::Version
89
- version: '0'
131
+ version: '2.0'
90
132
  required_rubygems_version: !ruby/object:Gem::Requirement
91
133
  requirements:
92
- - - ! '>='
134
+ - - ">="
93
135
  - !ruby/object:Gem::Version
94
136
  version: '0'
95
137
  requirements: []
96
138
  rubyforge_project:
97
- rubygems_version: 2.4.5
139
+ rubygems_version: 2.5.1
98
140
  signing_key:
99
141
  specification_version: 4
100
142
  summary: ActiveRecord database environment switching for slaves and least-privilege