dim 1.2.4 → 1.2.5

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
- MDkyMTNkMjcyOTcyMTBiMmI5MTVlMDgwMDEwNGMxZWJkYmMxN2MzOA==
4
+ YjkxNzk1YWJkYzEwNzUxZmI5NTM3YzViYzJiYjdkYTdmZmNjYmY1Mg==
5
5
  data.tar.gz: !binary |-
6
- OWZhZjY2MDhjYjc1MjMzZDgxYjRmZjMxM2RmNWNhZTExYzFlMTEwYg==
6
+ YmNkOWVjZjc4OWI2NThjNzVjZDkwMjMzNjNjMDE3ZjUwMGZmOTBhMA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NzZlNmQzMzhkYzg2ZWZjNTVjYjhjYTI1MDRkNTU0MzMxMjJjNWFhZjdiMmQx
10
- N2I4OTMzYTdiOGE5ZDUyNjBhNDRjNjdjNzE1Y2MyNGE0ZjBiYzY4YThhY2I2
11
- ODQ5MTlkZjE2ZGFiNDhhY2M3ZmI3MWMxOWU4ZDlmOTk3MzkyYmY=
9
+ NWMyZmE0ZDA1ZWQyNDFiNTY0MTA3NmQ1YmUxNDE4NWViMjllZjQ0NjM5ZTg0
10
+ OGM4MDgxZTg0OTc5NDdmZWZiZWE2NDcyMDFlODNlNzkwMmUwNWZkODZiYjJj
11
+ MzQ2ODhiNjI3ZTgxMDM5ZWIyN2UyNzBhNTIxNzE3OTIwNDM3ZjY=
12
12
  data.tar.gz: !binary |-
13
- N2E2NDYzYTY2NmJiODVhOWUyMWYxMTZlNGNlMjAxZDJiZTc3YjE0YmI3ODIz
14
- ZThjMTJhZTY3Yzc0Njg1YjRlMWQ2YmFiOTczNjI3NDViYmIxZDc0OTAyNTY4
15
- ODQyMTJlMzI2ODYxMjAwNjYyMzliZGMyODIzNzcwNTZhYzVmZjU=
13
+ MTk4NDRmZTYzZDEwYzg5MWM1YzdkM2YzYzYzNTVkMGY4ZjY0YTFlOTQyYWNj
14
+ MGM1NTA3ZDIxYmEzOTU2YTA4NDEzNDE2M2Y1ZDk2YmY5OTA1NzNjODBiMzFj
15
+ MzAzMDNhMzQ0NTYzNWFkODhjYjcyMzQ3NGU4ZGFiYzA3MzA4ZGI=
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .project_env.rc
2
2
  .togglerc
3
3
  *.gem
4
+ Gemfile.lock
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in ..gemspec
4
4
  gemspec
5
+ gem "rspec-given", "< 3"
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, &block)
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]
@@ -1,3 +1,3 @@
1
1
  module Dim
2
- VERSION = "1.2.4"
2
+ VERSION = "1.2.5"
3
3
  end
@@ -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
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-30 00:00:00.000000000 Z
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
@@ -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