dim 1.2.4 → 1.2.5
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 +8 -8
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/lib/dim.rb +6 -2
- data/lib/version.rb +1 -1
- data/spec/dim_spec.rb +6 -0
- metadata +2 -3
- data/Gemfile.lock +0 -27
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjkxNzk1YWJkYzEwNzUxZmI5NTM3YzViYzJiYjdkYTdmZmNjYmY1Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmNkOWVjZjc4OWI2NThjNzVjZDkwMjMzNjNjMDE3ZjUwMGZmOTBhMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWMyZmE0ZDA1ZWQyNDFiNTY0MTA3NmQ1YmUxNDE4NWViMjllZjQ0NjM5ZTg0
|
10
|
+
OGM4MDgxZTg0OTc5NDdmZWZiZWE2NDcyMDFlODNlNzkwMmUwNWZkODZiYjJj
|
11
|
+
MzQ2ODhiNjI3ZTgxMDM5ZWIyN2UyNzBhNTIxNzE3OTIwNDM3ZjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTk4NDRmZTYzZDEwYzg5MWM1YzdkM2YzYzYzNTVkMGY4ZjY0YTFlOTQyYWNj
|
14
|
+
MGM1NTA3ZDIxYmEzOTU2YTA4NDEzNDE2M2Y1ZDk2YmY5OTA1NzNjODBiMzFj
|
15
|
+
MzAzMDNhMzQ0NTYzNWFkODhjYjcyMzQ3NGU4ZGFiYzA3MzA4ZGI=
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/lib/dim.rb
CHANGED
@@ -57,8 +57,8 @@ module Dim
|
|
57
57
|
# Register a service named +name+. The +block+ will be used to
|
58
58
|
# create the service on demand. It is recommended that symbols be
|
59
59
|
# used as the name of a service.
|
60
|
-
def register(name,
|
61
|
-
if @services[name]
|
60
|
+
def register(name,raise_error_on_duplicate = true,&block)
|
61
|
+
if @services[name] && raise_error_on_duplicate
|
62
62
|
fail DuplicateServiceError, "Duplicate Service Name '#{name}'"
|
63
63
|
end
|
64
64
|
@services[name] = block
|
@@ -68,6 +68,10 @@ module Dim
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def override(name,&block)
|
72
|
+
register(name,false,&block)
|
73
|
+
end
|
74
|
+
|
71
75
|
# Lookup a service from ENV variables, or use a default if given; fall back to searching the container and its parents for a default value
|
72
76
|
def register_env(name,default = nil)
|
73
77
|
if value = ENV[name.to_s.upcase]
|
data/lib/version.rb
CHANGED
data/spec/dim_spec.rb
CHANGED
@@ -39,6 +39,12 @@ describe Dim::Container do
|
|
39
39
|
Then { container.app.should be(app) }
|
40
40
|
end
|
41
41
|
|
42
|
+
Scenario "overriding previously-registered objects" do
|
43
|
+
Given { container.register(:some_value) { "A" } }
|
44
|
+
Given { container.override(:some_value) { "B" } }
|
45
|
+
Then { container.some_value.should == "B" }
|
46
|
+
end
|
47
|
+
|
42
48
|
it "clears cache explicitly" do
|
43
49
|
container.register(:app) { App.new }
|
44
50
|
app_before = container.app
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Weirich
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -51,7 +51,6 @@ files:
|
|
51
51
|
- .rspec
|
52
52
|
- .ruby-version
|
53
53
|
- Gemfile
|
54
|
-
- Gemfile.lock
|
55
54
|
- LICENSE
|
56
55
|
- README.markdown
|
57
56
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
dim (1.2.3)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.1.2)
|
10
|
-
rspec (2.5.0)
|
11
|
-
rspec-core (~> 2.5.0)
|
12
|
-
rspec-expectations (~> 2.5.0)
|
13
|
-
rspec-mocks (~> 2.5.0)
|
14
|
-
rspec-core (2.5.1)
|
15
|
-
rspec-expectations (2.5.0)
|
16
|
-
diff-lcs (~> 1.1.2)
|
17
|
-
rspec-given (1.3.1)
|
18
|
-
rspec (~> 2.0)
|
19
|
-
rspec-mocks (2.5.0)
|
20
|
-
|
21
|
-
PLATFORMS
|
22
|
-
ruby
|
23
|
-
|
24
|
-
DEPENDENCIES
|
25
|
-
dim!
|
26
|
-
rspec
|
27
|
-
rspec-given
|