config-factory 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b31bc2f2074a9f1e66efe1d58e5e224b254e4820
4
- data.tar.gz: 5afe13b48946fdcbf269d10d7a57399e354b6afe
3
+ metadata.gz: 85d51fce96572d3dba52936c624787dfc7318cbc
4
+ data.tar.gz: ee7cdc6973f8918992858021eabde2d92d272f2d
5
5
  SHA512:
6
- metadata.gz: 33047cf037e5d3d3443b31839dd3ea79831bee2cf57782fd863b820c721069c47bfb01e8d026e040ab366e5df14ea2a8d652fa857b0e931b1abf31bc6fff9627
7
- data.tar.gz: a41e560799880666b8de8859b481bdab1c9d520a1d24320504b42d89c178151b0c01b4ff504c89c7ed533979e1a02443566a6110c7a92c5a6f18bc97843ea921
6
+ metadata.gz: 74c6acb13ffe5a9892e6430b91452ca3819b149cd8d3bacb62159d2fd60ad1ea872c1043918b753279433a4e444c8d08a27c082111d2bd2963af7d4f2e8306d2
7
+ data.tar.gz: e7d2d643473f1de988680e736f8bbfae5e78df564259d6550d17e9409de7d5c75237e2d6d44aeae2b02858885ad6bfdd9abc71be99e631ce327c32a19e6ca3f2
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.6 (16 March 2016)
2
+
3
+ - Better error messages for missing keys, configs, etc.
4
+
1
5
  ## 0.0.5 (2 March 2016)
2
6
 
3
7
  - Add `AbstractFactory#from_file`
@@ -17,6 +17,7 @@ module Config
17
17
 
18
18
  def for_environment(env, config_name)
19
19
  arg_hash = env.args_for(config_name)
20
+ fail ArgumentError, "no #{self} arguments found for config #{config_name} in environment #{env}" unless arg_hash
20
21
  build_from(arg_hash)
21
22
  end
22
23
 
@@ -26,7 +27,9 @@ module Config
26
27
  end
27
28
 
28
29
  def build_from(arg_hash)
30
+ fail ArgumentError, "nil argument hash passed to #{self}.build_from" unless arg_hash
29
31
  args = deep_symbolize_keys(arg_hash)
32
+ fail ArgumentError, "product key #{product_key} not found in argument hash #{args}" unless args.key?(product_key)
30
33
  key_value = args.delete(product_key)
31
34
  product_class = products[key_value]
32
35
  fail ArgumentError, "No #{name} product class found for #{product_key}: #{key_value}" unless product_class
@@ -24,6 +24,10 @@ module Config
24
24
  Environment.new(name: Environments::DEFAULT_ENVIRONMENT, configs: hash)
25
25
  end
26
26
 
27
+ def to_s
28
+ "#{self.class}: name = #{@name}, configs = #{@configs})"
29
+ end
30
+
27
31
  private
28
32
 
29
33
  def name=(v)
@@ -4,7 +4,7 @@ module Config
4
4
  NAME = 'config-factory'
5
5
 
6
6
  # The version of this gem
7
- VERSION = '0.0.5'
7
+ VERSION = '0.0.6'
8
8
 
9
9
  # The copyright notice for this gem
10
10
  COPYRIGHT = 'Copyright (c) 2016 The Regents of the University of California'
@@ -48,6 +48,44 @@ module Config
48
48
  end
49
49
  end
50
50
  end
51
+
52
+ describe '#to_s' do
53
+ it 'includes the name' do
54
+ env = Environment.load_file('spec/data/single-environment.yml')
55
+ expect(env.to_s).to include(Environments::DEFAULT_ENVIRONMENT.to_s)
56
+ end
57
+
58
+ it 'includes the hash' do
59
+ h = {
60
+ 'db' =>
61
+ {
62
+ 'adapter' => 'mysql2',
63
+ 'encoding' => 'utf8',
64
+ 'pool' => 5,
65
+ 'database' => 'example_pord',
66
+ 'host' => 'mysql-dev.example.org',
67
+ 'port' => 3306
68
+ },
69
+ 'source' => {
70
+ 'protocol' => 'OAI',
71
+ 'oai_base_url' => 'http://oai.example.org/oai',
72
+ 'metadata_prefix' => 'some_prefix',
73
+ 'set' => 'some_set',
74
+ 'seconds_granularity' => true
75
+ },
76
+ 'index' => {
77
+ 'adapter' => 'solr',
78
+ 'url' => 'http://solr.example.org/',
79
+ 'proxy' => 'http://foo:bar@proxy.example.com/',
80
+ 'open_timeout' => 120,
81
+ 'read_timeout' => 300
82
+ }
83
+ }
84
+ env = Environment.load_hash(h)
85
+ expect(env.to_s).to include(h.to_s)
86
+ end
87
+ end
88
+
51
89
  end
52
90
  end
53
91
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config-factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler