configlet 2.0.0 → 2.1.0
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/CHANGELOG.rdoc +4 -0
- data/lib/configlet.rb +10 -4
- data/test/test_configlet.rb +7 -0
- metadata +3 -3
data/CHANGELOG.rdoc
CHANGED
data/lib/configlet.rb
CHANGED
|
@@ -13,7 +13,7 @@ module Configlet
|
|
|
13
13
|
|
|
14
14
|
# Duh.
|
|
15
15
|
|
|
16
|
-
VERSION = "2.
|
|
16
|
+
VERSION = "2.1.0"
|
|
17
17
|
|
|
18
18
|
I = lambda { |v| v } #:nodoc:
|
|
19
19
|
|
|
@@ -82,10 +82,16 @@ module Configlet
|
|
|
82
82
|
# default "email.from" => "noreply@myapp.com"
|
|
83
83
|
# default :host => "myapp.local"
|
|
84
84
|
# end
|
|
85
|
+
#
|
|
86
|
+
# If +prefix+ isn't specified, a downcased version of the current
|
|
87
|
+
# class' name will be used.
|
|
88
|
+
|
|
89
|
+
def config prefix = nil, &block
|
|
90
|
+
self.prefix = prefix ||
|
|
91
|
+
(Class === self ? self : self.class).
|
|
92
|
+
name.split("::").last.downcase.to_sym
|
|
85
93
|
|
|
86
|
-
|
|
87
|
-
self.prefix = prefix
|
|
88
|
-
instance_eval(&block)
|
|
94
|
+
instance_eval(&block) if block_given?
|
|
89
95
|
end
|
|
90
96
|
|
|
91
97
|
# Mess with a value when it's retrieved. Useful for turning untyped
|
data/test/test_configlet.rb
CHANGED
|
@@ -27,6 +27,13 @@ class TestConfiglet < MiniTest::Unit::TestCase
|
|
|
27
27
|
assert_equal "baz", @cfg[:bar]
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def test_config_auto_prefix
|
|
31
|
+
|
|
32
|
+
ENV["STUB_FOO"] = "bar"
|
|
33
|
+
@cfg.config
|
|
34
|
+
assert_equal "bar", @cfg[:foo]
|
|
35
|
+
end
|
|
36
|
+
|
|
30
37
|
def test_default
|
|
31
38
|
assert_nil @cfg["foo"]
|
|
32
39
|
|
metadata
CHANGED
|
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
|
4
4
|
prerelease: false
|
|
5
5
|
segments:
|
|
6
6
|
- 2
|
|
7
|
+
- 1
|
|
7
8
|
- 0
|
|
8
|
-
|
|
9
|
-
version: 2.0.0
|
|
9
|
+
version: 2.1.0
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- John Barnette
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-
|
|
17
|
+
date: 2010-12-14 00:00:00 -08:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|