citrusbyte-settings 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.
- data/README.markdown +1 -1
- data/lib/settings_hash.rb +2 -2
- data/test/settings_test.rb +1 -1
- metadata +1 -1
data/README.markdown
CHANGED
@@ -13,7 +13,7 @@ New instances of `SettingsHash` are readonly -- any attempt to write to the
|
|
13
13
|
Hash after initialization will fail with a `TypeError`.
|
14
14
|
|
15
15
|
Any attempt to read a key which is not set will raise a
|
16
|
-
`SettingsHash::
|
16
|
+
`SettingsHash::SettingNotFound` error.
|
17
17
|
|
18
18
|
`SettingsHash` supports an optional namespace which can be used to define
|
19
19
|
multiple groups of settings within a single .yml file. For example, "test" and
|
data/lib/settings_hash.rb
CHANGED
@@ -2,7 +2,7 @@ require 'readonly_hash'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
class SettingsHash < ReadonlyHash
|
5
|
-
class
|
5
|
+
class SettingNotFound < StandardError;end;
|
6
6
|
|
7
7
|
def initialize(path, namespace=nil)
|
8
8
|
raise "No settings file found: #{path}" unless File.exists?(path)
|
@@ -17,7 +17,7 @@ class SettingsHash < ReadonlyHash
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def [](key)
|
20
|
-
raise
|
20
|
+
raise SettingNotFound.new("No setting found for #{key}") unless has_key?(key)
|
21
21
|
super
|
22
22
|
end
|
23
23
|
end
|
data/test/settings_test.rb
CHANGED