configured 1.0.1 → 1.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.
@@ -4,14 +4,14 @@ module Configured
4
4
  # Filename can be passed as parameter.
5
5
  def in_yaml(filename = "config/database.yml")
6
6
  begin
7
- $config_initters ||= {}
8
- $config_initters[filename] ||=
7
+ @@config_initters ||= {}
8
+ @@config_initters[filename] ||=
9
9
  begin
10
10
  data = YAML::load(File.open filename)
11
11
  Settings.new(data)
12
12
  end
13
13
  rescue
14
- raise "Can't find \"#{filename}\" configuration file."
14
+ raise Errno::ENOENT, "Can't find \"#{filename}\" configuration file."
15
15
  end
16
16
  end
17
17
  end
@@ -1,4 +1,4 @@
1
- module Configured
1
+ module Configured
2
2
  class Settings
3
3
  # Initialize using required configuration data (YAML::load result, for example).
4
4
  def initialize(configuration_data)
@@ -14,8 +14,13 @@ module Configured
14
14
  settings.each_key { |key| settings_hash[key.intern] = settings[key]}
15
15
  settings_hash
16
16
  rescue
17
- raise "Can't find \"#{environment}\" section in config."
17
+ raise NoEnvironmentError, "Can't find \"#{environment}\" section in config."
18
18
  end
19
19
  end
20
+
21
+ # Error for situation when we can't find the required environment section
22
+ # in configuration file.
23
+ class NoEnvironmentError < StandardError
24
+ end
20
25
  end
21
26
  end
@@ -2,7 +2,7 @@ module Configured # :nodoc:
2
2
  module Version # :nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -19,7 +19,7 @@ describe Configured do
19
19
  2.times { Configured.in_yaml some_config }
20
20
  end
21
21
 
22
- it "should raise an exception if there is no such configuration file." do
22
+ it "should raise an exception if there is no such configuration file" do
23
23
  lambda { Configured.in_yaml "bad_file" }.should raise_error
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configured
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
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: 2011-09-12 00:00:00.000000000Z
12
+ date: 2011-09-20 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: configured. Use your database.yaml in rails initters. For redis, redis-store
15
15
  and e.t.c.
@@ -46,8 +46,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
46
  version: '0'
47
47
  requirements: []
48
48
  rubyforge_project:
49
- rubygems_version: 1.8.6
49
+ rubygems_version: 1.8.10
50
50
  signing_key:
51
51
  specification_version: 3
52
- summary: configured 1.0.1
52
+ summary: configured 1.0.2
53
53
  test_files: []