shackles 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2NhN2Y5OTQ2OTQwNWZjY2EzMWZmMjkwYTY2YzdiYjU5MTk4NmU3YQ==
4
+ MGZlYjI5ZDg0YmU2MDQ0MmI4YmRlYTc1ODQxODU3Zjg4NzBlNDhlOA==
5
5
  data.tar.gz: !binary |-
6
- YWE3ZDY1NGM0MDA2ZjhjZGUxMzc5NDE4ODk1N2ZmMDE4MDgyOWM5Nw==
6
+ ODdmYzI1NGFhN2ZjNDZjNDdhY2VhMzJkN2VlNjJhZjg0OTBhOTEwNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWYxYzhjZTI2NDQzYjMwNjIxMzExNjZjZGUzODdmZTBjZDdmYjJlOTE5MTQ5
10
- ODY0NzFmMGRlZjY1ZTc0MjM0YTc0ZjYwNzdhY2VkN2FiZWU5ZGIwZDU1MmZm
11
- YTk5NmJjNWMzOTJiNDg3NzMzMWQwYmZlMGQxYjFiOGFjYWYxNzY=
9
+ Y2E0ZWMwY2M1ZmVlNzNmNjI3YTA1NDM4YTVlZGVlNDcwMmExMDIxNGE4ZTgw
10
+ MDczNjgwNGJkMDhmYTRhMjk4YjIxZjIyMDY2NTZiYzBjNWYyZmQ2ZWE5ZTQ5
11
+ MDcxMjYwZDYxZjAwMzg1OWQwYWJkOWRlN2YzMDY0YzZkYTFmNTg=
12
12
  data.tar.gz: !binary |-
13
- MzdhZjY4MGVlYWRiZDNjZmJjYzVlMWI0M2VmN2Q5OThhOGUwNTlhNmZhMDdm
14
- MTc4ODRlOTVmNDI3YWM1NWE2ODVlM2IwMzEzMjU3YzAzOTQwMmQyMWU0ZmVm
15
- MzQ4MTdlMmM3MWYwYWJiNTkwMWNjNDA0YzcwNGVhYjAzMWNmNmU=
13
+ ZDA0ZDJiYmFhZTEwYzA5ZGI0NDkzYzYwMDU3YmUzNTQwNjA0ZjVkMTQ3NWQw
14
+ YWNmNzk4YWJlZjdkYWUyZmVkM2IxYzdmMTc3YTBiZWYxZDQwN2Y2MGI3YjBl
15
+ MTIxYTYzZjk5YmVmNmIyYjRhNTNlOTYyNDcyNWFhYmJjZDUxNzE=
@@ -1,3 +1,3 @@
1
1
  module Shackles
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.7"
3
3
  end
data/lib/shackles.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'set'
2
+
1
3
  module Shackles
2
4
  class << self
3
5
  def environment
@@ -8,11 +10,17 @@ module Shackles
8
10
  @global_config ||= {}
9
11
  end
10
12
 
13
+ def activated_environments
14
+ @activated_environments ||= Set.new()
15
+ end
16
+
11
17
  # semi-private
12
18
  def initialize!
13
19
  require 'shackles/connection_handler'
14
20
  require 'shackles/connection_specification'
15
21
 
22
+ activated_environments << Shackles.environment
23
+
16
24
  ActiveRecord::ConnectionAdapters::ConnectionHandler.send(:include, ConnectionHandler)
17
25
  klass = Rails.version < '4' ? ActiveRecord::Base : ActiveRecord::ConnectionAdapters
18
26
  klass::ConnectionSpecification.send(:include, ConnectionSpecification)
@@ -52,6 +60,7 @@ module Shackles
52
60
  return yield if environment == self.environment
53
61
  begin
54
62
  old_environment = activate!(environment)
63
+ activated_environments << environment
55
64
  yield
56
65
  ensure
57
66
  @environment = old_environment
@@ -112,6 +112,13 @@ describe Shackles do
112
112
  ActiveRecord::Base.connection.should == conn
113
113
  end
114
114
 
115
+ it "should track all activated environments" do
116
+ Shackles.activate(:slave) {}
117
+ Shackles.activate(:custom) {}
118
+ expected = Set.new([:master, :slave, :custom])
119
+ (Shackles.activated_environments & expected).should == expected
120
+ end
121
+
115
122
  context "non-transactional" do
116
123
  it "should really disconnect all envs" do
117
124
  ActiveRecord::Base.connection
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shackles
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2014-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
- version: '2.3'
19
+ version: '3.2'
20
20
  - - <
21
21
  - !ruby/object:Gem::Version
22
22
  version: '4.2'
@@ -26,24 +26,10 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: '2.3'
29
+ version: '3.2'
30
30
  - - <
31
31
  - !ruby/object:Gem::Version
32
32
  version: '4.2'
33
- - !ruby/object:Gem::Dependency
34
- name: debugger
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
33
  - !ruby/object:Gem::Dependency
48
34
  name: mocha
49
35
  requirement: !ruby/object:Gem::Requirement
@@ -107,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
93
  version: '0'
108
94
  requirements: []
109
95
  rubyforge_project:
110
- rubygems_version: 2.2.0
96
+ rubygems_version: 2.3.0
111
97
  signing_key:
112
98
  specification_version: 4
113
99
  summary: ActiveRecord database environment switching for slaves and least-privilege