confuse 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/confuse/config_item.rb +4 -4
- data/lib/confuse/config_mixin.rb +1 -1
- data/lib/confuse/configurable.rb +1 -1
- data/lib/confuse/dsl.rb +1 -1
- data/lib/confuse/namespace.rb +8 -3
- data/lib/confuse/version.rb +1 -1
- metadata +4 -4
data/lib/confuse/config_item.rb
CHANGED
@@ -20,13 +20,13 @@ module Confuse
|
|
20
20
|
@type
|
21
21
|
end
|
22
22
|
|
23
|
-
def default(
|
24
|
-
@
|
25
|
-
@
|
23
|
+
def default(value = nil, &block)
|
24
|
+
@default_value = value unless value.nil?
|
25
|
+
@default_value = block unless block.nil?
|
26
26
|
end
|
27
27
|
|
28
28
|
def value
|
29
|
-
@value || @
|
29
|
+
@value || @default_value
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
data/lib/confuse/config_mixin.rb
CHANGED
data/lib/confuse/configurable.rb
CHANGED
data/lib/confuse/dsl.rb
CHANGED
data/lib/confuse/namespace.rb
CHANGED
@@ -26,8 +26,13 @@ module Confuse
|
|
26
26
|
@strict_flag = true
|
27
27
|
end
|
28
28
|
|
29
|
-
def [](key)
|
30
|
-
(i = get_item(key)) && i.value
|
29
|
+
def [](key, config = nil)
|
30
|
+
value = (i = get_item(key)) && i.value
|
31
|
+
if value.respond_to?(:call) && !config.nil?
|
32
|
+
value.call(config)
|
33
|
+
else
|
34
|
+
value
|
35
|
+
end
|
31
36
|
end
|
32
37
|
|
33
38
|
def []=(key, value)
|
@@ -39,7 +44,7 @@ module Confuse
|
|
39
44
|
if @supress_warnings_flag
|
40
45
|
puts "Warning: config includes unknown option '#{key}'"
|
41
46
|
end
|
42
|
-
@items[key] = ConfigItem.new(key, &
|
47
|
+
@items[key] = ConfigItem.new(key, &nil) unless @strict_flag
|
43
48
|
end
|
44
49
|
|
45
50
|
def get_item(key)
|
data/lib/confuse/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confuse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tom Chipchase
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-10-
|
18
|
+
date: 2013-10-02 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: inifile
|