conf_loader 0.2.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a10bbb4fbd9c6709fadc4ea0f27ac86d2517a90
4
- data.tar.gz: 1caf978351e72410f0c442ba1132c86bc0dffa12
3
+ metadata.gz: 2064ef2962ea950a910ed91b16ed6eeb56d7d7fe
4
+ data.tar.gz: fd311e0300ab0ffda09ac077a55bcf34943e36da
5
5
  SHA512:
6
- metadata.gz: ec0620fa2f0c7e6645dd47ef0c9b9dc6d6e28ebcf6d00848b0d901ede03afe9a6e4a31a81a6ef8d8bdcb51bd0f21ba5ce6dbdf3d31b3e9969d0afa48a78d5335
7
- data.tar.gz: fbbb5f5c701717c369dd5a37839310a92316b94f42bb2fe25c14d2048ec2dc15685f9838f62423dd10d19d9f6d4057c684891fc78490637a2f99aa6249301b47
6
+ metadata.gz: 2779d36c5c7e8cd49520eaf8e45e7bd31f78d61611c52588ddf0918d9e57f0b3837da8c4d83c7108f721866da93331a4d404d75d2e3d22e9b430044a6cd3db68
7
+ data.tar.gz: 755c887c78d21691415198cf8a6a6f81f0200dd4f45b33d4a4b7e92d62231eae1d5189f3a064ba7009c83e49ec188d666207b67d253ed31741e1a4d93435c528
@@ -1,3 +1,3 @@
1
1
  class ConfLoader
2
- VERSION = '0.2.2'
2
+ VERSION = '1.0.0'
3
3
  end
data/lib/conf_loader.rb CHANGED
@@ -24,10 +24,19 @@ class ConfLoader
24
24
 
25
25
  if environments.has_key?(env)
26
26
  hash = environments[env]
27
- Symbolizer.symbolize(hash)
27
+ guarantee_key_presence(Symbolizer.symbolize(hash))
28
28
  else
29
29
  raise EnvironmentNotFoundError,
30
30
  "Configuration for `#{env}` not found at path #{path}"
31
31
  end
32
32
  end
33
+
34
+ def self.guarantee_key_presence(hash)
35
+ hash.default_proc = proc do |h, k|
36
+ raise KeyError, "#{k} not defined"
37
+ end
38
+ hash
39
+ end
40
+
41
+ private_class_method :guarantee_key_presence
33
42
  end
@@ -11,6 +11,14 @@ describe ConfLoader do
11
11
  end
12
12
  end
13
13
 
14
+ context 'when accessed key not defined' do
15
+ let(:conf) { described_class.load(path, 'office') }
16
+
17
+ it 'raises KeyError' do
18
+ expect{conf[:some_undefined_key]}.to raise_error(KeyError)
19
+ end
20
+ end
21
+
14
22
  context 'conf loaded with production deployment setting' do
15
23
 
16
24
  let(:conf) { described_class.load(path, 'production') }
@@ -41,10 +49,6 @@ describe ConfLoader do
41
49
  expect(conf[:foo]).to eq('foo-value')
42
50
  end
43
51
 
44
- it 'exposes undefined ENV values as nil' do
45
- expect(conf[:undefined_val]).to be_nil
46
- end
47
-
48
52
  it 'exposes default value when ENV value not supplied' do
49
53
  expect(conf[:var_with_default_not_in_env]).to eq('default_value')
50
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conf_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indrek Juhkam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-01 00:00:00.000000000 Z
11
+ date: 2016-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: symbolizer
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  version: '0'
67
67
  requirements: []
68
68
  rubyforge_project:
69
- rubygems_version: 2.4.5.1
69
+ rubygems_version: 2.5.1
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: Helps to load conf files in SaleMove ecosystem