lite_config 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ ### Version 0.0.3
2
+
3
+ * Fix error on missing config (thanks RKushnir)
4
+
5
+ ### Version 0.0.2
6
+
7
+ * Don't crash on empty files
8
+ * Don't crash on missing environment keys
9
+
10
+ ### Version 0.0.1
11
+
12
+ * Initial release
@@ -1,3 +1,3 @@
1
1
  module LiteConfig
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/lite_config.rb CHANGED
@@ -7,6 +7,7 @@ require 'yaml'
7
7
 
8
8
  module LiteConfig
9
9
  class ImmutableError < StandardError; end
10
+ class NotFoundError < StandardError; end
10
11
 
11
12
  extend self
12
13
 
@@ -35,7 +36,11 @@ module LiteConfig
35
36
  private
36
37
 
37
38
  def load(name)
38
- config = load_single(config_filename(name))
39
+ if File.exist?(config_filename(name))
40
+ config = load_single(config_filename(name))
41
+ else
42
+ raise NotFoundError, "No config found for #{name}"
43
+ end
39
44
 
40
45
  if File.exist?(local_config_filename(name))
41
46
  local_config = load_single(local_config_filename(name))
@@ -43,8 +48,6 @@ module LiteConfig
43
48
  config.deep_merge!(local_config) if local_config
44
49
  end
45
50
 
46
- raise "Oops, no #{app_env} config found for #{name} in #{filename}" unless config
47
-
48
51
  config
49
52
  end
50
53
 
@@ -123,4 +123,10 @@ describe LiteConfig do
123
123
  @config[:red].must_equal 'fish'
124
124
  end
125
125
  end
126
+
127
+ describe "config not present" do
128
+ it "should raise exception" do
129
+ lambda{ LiteConfig(:not_even_a_real_config) }.must_raise LiteConfig::NotFoundError
130
+ end
131
+ end
126
132
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-18 00:00:00.000000000 Z
12
+ date: 2014-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -102,6 +102,7 @@ extra_rdoc_files: []
102
102
  files:
103
103
  - .gitignore
104
104
  - .travis.yml
105
+ - CHANGELOG.md
105
106
  - Gemfile
106
107
  - LICENSE.txt
107
108
  - README.md