config-factory 0.0.1 → 0.0.2

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: 1c37c92cb2e03fac96a921680f19865fa0caceb0
4
- data.tar.gz: 1df74e155e1c9b087595ce54d495b7718daf4045
3
+ metadata.gz: 5d5038da1c70870d65c32c8248c705cfe4e6a039
4
+ data.tar.gz: 7c2a3b6ff820e82e4b7865fee30ce032d9d34c70
5
5
  SHA512:
6
- metadata.gz: e0616e9f0628f6cfc0fb6fe26b6594cf760225203998eb72225d85b8ef14584778e49960c9ef41b363a2b5c13194f4b0421ca494186d685667c87fa449cce954
7
- data.tar.gz: 25b40edecf4cd5d8eb4e82de174f69bc230de9d4818fd66c3bf3a442e296d8141abfa2fc507f31621b440e2941e65456bb54bd424306d471cf8623f8cd702778
6
+ metadata.gz: d21a5a42dd50543084d31288f66996624c9c06e851065cd04f8d2c31ef8e4f3a648a84a04e066f315041e23d2346158700b6ed3bfe0f755b71654f7eae0379e3
7
+ data.tar.gz: f329a4fec0d2a1f26c364a3c9515018ad8fcc9a2dda3541f425162a7aa979061cb5e17491801d47b20928dad3feac3f5b27afafeb4dc4cffb60dcadf07c09a1e
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 The Regents of the University of California
3
+ Copyright (c) 2016 The Regents of the University of California
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -6,7 +6,7 @@ module Config
6
6
 
7
7
  def initialize(name:, configs:)
8
8
  self.name = name
9
- @configs = configs
9
+ self.configs = configs
10
10
  end
11
11
 
12
12
  def args_for(config_name)
@@ -30,6 +30,11 @@ module Config
30
30
  @name = v
31
31
  end
32
32
 
33
+ def configs=(v)
34
+ fail ArgumentError, 'Configs must be a hash' unless v && v.respond_to?(:[])
35
+ @configs = v
36
+ end
37
+
33
38
  end
34
39
  end
35
40
  end
@@ -4,7 +4,7 @@ module Config
4
4
  NAME = 'config-factory'
5
5
 
6
6
  # The version of this gem
7
- VERSION = '0.0.1'
7
+ VERSION = '0.0.2'
8
8
 
9
9
  # The copyright notice for this gem
10
10
  COPYRIGHT = 'Copyright (c) 2015 The Regents of the University of California'
@@ -22,6 +22,12 @@ module Config
22
22
  expect(env.args_for(key)).to eq(yaml_hash[key])
23
23
  end
24
24
  end
25
+ it 'requires configs' do
26
+ expect { Environment.new(name: :name, configs: nil) }.to raise_error(ArgumentError)
27
+ end
28
+ it 'requires configs to be hash-like' do
29
+ expect { Environment.new(name: :name, configs: false) }.to raise_error(ArgumentError)
30
+ end
25
31
  end
26
32
 
27
33
  describe '#load_file' do
@@ -30,6 +36,17 @@ module Config
30
36
  expect(env).to be_an(Environment)
31
37
  expect(env.name).to eq(Environments::DEFAULT_ENVIRONMENT)
32
38
  end
39
+
40
+ it 'raises an error for malformed files' do
41
+ bad_yaml = "\t"
42
+ Dir.mktmpdir do |tmpdir|
43
+ bad_yaml_path = "#{tmpdir}/config.yml"
44
+ File.open(bad_yaml_path, 'w') do |f|
45
+ f.write(bad_yaml)
46
+ end
47
+ expect { Environment.load_file(bad_yaml_path) }.to raise_error(Psych::SyntaxError)
48
+ end
49
+ end
33
50
  end
34
51
  end
35
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config-factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles