dim 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MDkyMTNkMjcyOTcyMTBiMmI5MTVlMDgwMDEwNGMxZWJkYmMxN2MzOA==
5
+ data.tar.gz: !binary |-
6
+ OWZhZjY2MDhjYjc1MjMzZDgxYjRmZjMxM2RmNWNhZTExYzFlMTEwYg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NzZlNmQzMzhkYzg2ZWZjNTVjYjhjYTI1MDRkNTU0MzMxMjJjNWFhZjdiMmQx
10
+ N2I4OTMzYTdiOGE5ZDUyNjBhNDRjNjdjNzE1Y2MyNGE0ZjBiYzY4YThhY2I2
11
+ ODQ5MTlkZjE2ZGFiNDhhY2M3ZmI3MWMxOWU4ZDlmOTk3MzkyYmY=
12
+ data.tar.gz: !binary |-
13
+ N2E2NDYzYTY2NmJiODVhOWUyMWYxMTZlNGNlMjAxZDJiZTc3YjE0YmI3ODIz
14
+ ZThjMTJhZTY3Yzc0Njg1YjRlMWQ2YmFiOTczNjI3NDViYmIxZDc0OTAyNTY4
15
+ ODQyMTJlMzI2ODYxMjAwNjYyMzliZGMyODIzNzcwNTZhYzVmZjU=
@@ -0,0 +1 @@
1
+ ruby-1.9.3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dim (1.2.2)
4
+ dim (1.2.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/dim.rb CHANGED
@@ -68,15 +68,17 @@ module Dim
68
68
  end
69
69
  end
70
70
 
71
- # Lookup a service from ENV variables; fall back to searching the container and its parents for a default value
72
- def register_env(name)
71
+ # 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
+ def register_env(name,default = nil)
73
73
  if value = ENV[name.to_s.upcase]
74
74
  register(name) { value }
75
+ elsif default
76
+ register(name) { default }
75
77
  else
76
78
  begin
77
79
  @parent.service_block(name)
78
80
  rescue MissingServiceError
79
- raise EnvironmentVariableNotFound, "Could not find an ENV variable named #{name.to_s.upcase} nor could we find a service named #{name} in the parent container"
81
+ raise EnvironmentVariableNotFound, "Could not find an ENV variable named '#{name.to_s.upcase}' nor could we find a service named #{name} in the parent container"
80
82
  end
81
83
  end
82
84
  end
@@ -1,3 +1,3 @@
1
1
  module Dim
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  end
@@ -177,7 +177,7 @@ describe Dim::Container do
177
177
  Then { container.shaz.should == "bot" }
178
178
  end
179
179
 
180
- Scenario "which exist in optional hash" do
180
+ Scenario "which only exist in parent" do
181
181
  Given(:parent) { container }
182
182
  Given { parent.register(:foo) { "bar" } }
183
183
  Given(:child) { Dim::Container.new(parent) }
@@ -187,6 +187,11 @@ describe Dim::Container do
187
187
  Then { container.foo.should == "bar" }
188
188
  end
189
189
 
190
+ Scenario "which don't exist in ENV but have a default" do
191
+ Given { container.register_env(:abc,"123") }
192
+ Then { container.abc.should == "123" }
193
+ end
194
+
190
195
  Scenario "which don't exist in optional hash" do
191
196
  Then {
192
197
  lambda {
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dim
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
5
- prerelease:
4
+ version: 1.2.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jim Weirich
@@ -10,12 +9,11 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-01-18 00:00:00.000000000 Z
12
+ date: 2013-07-30 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rspec
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ! '>='
21
19
  - !ruby/object:Gem::Version
@@ -23,7 +21,6 @@ dependencies:
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ! '>='
29
26
  - !ruby/object:Gem::Version
@@ -31,7 +28,6 @@ dependencies:
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rspec-given
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
32
  - - ! '>='
37
33
  - !ruby/object:Gem::Version
@@ -39,7 +35,6 @@ dependencies:
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
39
  - - ! '>='
45
40
  - !ruby/object:Gem::Version
@@ -54,7 +49,7 @@ extra_rdoc_files:
54
49
  files:
55
50
  - .gitignore
56
51
  - .rspec
57
- - .rvmrc
52
+ - .ruby-version
58
53
  - Gemfile
59
54
  - Gemfile.lock
60
55
  - LICENSE
@@ -67,28 +62,28 @@ files:
67
62
  homepage: http://github.com/subelsky/dim
68
63
  licenses:
69
64
  - MIT
65
+ metadata: {}
70
66
  post_install_message:
71
67
  rdoc_options:
72
68
  - --charset=UTF-8
73
69
  require_paths:
74
70
  - lib
75
71
  required_ruby_version: !ruby/object:Gem::Requirement
76
- none: false
77
72
  requirements:
78
73
  - - ! '>='
79
74
  - !ruby/object:Gem::Version
80
75
  version: '0'
81
76
  required_rubygems_version: !ruby/object:Gem::Requirement
82
- none: false
83
77
  requirements:
84
78
  - - ! '>='
85
79
  - !ruby/object:Gem::Version
86
80
  version: '0'
87
81
  requirements: []
88
82
  rubyforge_project:
89
- rubygems_version: 1.8.24
83
+ rubygems_version: 2.0.6
90
84
  signing_key:
91
- specification_version: 3
85
+ specification_version: 4
92
86
  summary: Minimalistic dependency injection framework
93
87
  test_files:
94
88
  - spec/dim_spec.rb
89
+ has_rdoc:
data/.rvmrc DELETED
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
- # development environment upon cd'ing into the directory
5
-
6
- # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
- # Only full ruby name is supported here, for short names use:
8
- # echo "rvm use 1.9.3" > .rvmrc
9
- environment_id="ruby-1.9.3-p194"
10
-
11
- # Uncomment the following lines if you want to verify rvm version per project
12
- # rvmrc_rvm_version="1.13.4 ()" # 1.10.1 seams as a safe start
13
- # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
- # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
- # return 1
16
- # }
17
-
18
- # First we attempt to load the desired environment directly from the environment
19
- # file. This is very fast and efficient compared to running through the entire
20
- # CLI and selector. If you want feedback on which environment was used then
21
- # insert the word 'use' after --create as this triggers verbose mode.
22
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
- then
25
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
- [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
- \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
- else
29
- # If the environment file has not yet been created, use the RVM CLI to select.
30
- rvm --create "$environment_id" || {
31
- echo "Failed to create RVM environment '${environment_id}'."
32
- return 1
33
- }
34
- fi