climate_control 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS +3 -0
- data/lib/climate_control/environment.rb +16 -1
- data/lib/climate_control/version.rb +1 -1
- data/spec/acceptance/climate_control_spec.rb +13 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21d2f4ce1d74f8b2e4650cd7ab4efd3d40dac9d6
|
4
|
+
data.tar.gz: d14c7f5bc3b4ae309682f529c0ada07a9a874d9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c533460213a9e6a4285c3daa7fade227a4a5a5e4eb9a23e41d6bb06362c60468739476dd916be6b9ec3447b3e155dc1594e0fd89597ae58935acef27b850940
|
7
|
+
data.tar.gz: 1a9aefaad845f0cdcb147b77cd176e81c0004d28fa17979aab312d27fe1e5251653902bc6fe05581ccd1ecab49075f122b7d029953c708af350e6ad0809f575d
|
data/NEWS
CHANGED
@@ -7,10 +7,25 @@ module ClimateControl
|
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@semaphore = Mutex.new
|
10
|
+
@owner = nil
|
10
11
|
end
|
11
12
|
|
12
13
|
def_delegators :env, :[]=, :to_hash, :[], :delete
|
13
|
-
|
14
|
+
|
15
|
+
def synchronize
|
16
|
+
if @owner == Thread.current
|
17
|
+
return yield if block_given?
|
18
|
+
end
|
19
|
+
|
20
|
+
@semaphore.synchronize do
|
21
|
+
begin
|
22
|
+
@owner = Thread.current
|
23
|
+
yield if block_given?
|
24
|
+
ensure
|
25
|
+
@owner = nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
14
29
|
|
15
30
|
private
|
16
31
|
|
@@ -111,6 +111,19 @@ describe "Climate control" do
|
|
111
111
|
expect(ENV["BAZ"]).to be_nil
|
112
112
|
end
|
113
113
|
|
114
|
+
it "is re-entrant" do
|
115
|
+
ret = with_modified_env(FOO: "foo") do
|
116
|
+
with_modified_env(BAR: "bar") do
|
117
|
+
"bar"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
expect(ret).to eq("bar")
|
122
|
+
|
123
|
+
expect(ENV["FOO"]).to be_nil
|
124
|
+
expect(ENV["BAR"]).to be_nil
|
125
|
+
end
|
126
|
+
|
114
127
|
it "raises when the value cannot be assigned properly" do
|
115
128
|
Thing = Class.new
|
116
129
|
message = generate_type_error_for_object(Thing.new)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: climate_control
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Clayton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.5.2
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: Modify your ENV easily with ClimateControl
|