configlet 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ === 2.1.0 / 2010-12-14
2
+
3
+ * Make config prefix optional, default to class name (ish).
4
+
1
5
  === 2.0.0 / 2010-09-28
2
6
 
3
7
  * Remove deprecated features.
data/lib/configlet.rb CHANGED
@@ -13,7 +13,7 @@ module Configlet
13
13
 
14
14
  # Duh.
15
15
 
16
- VERSION = "2.0.0"
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
- def config prefix, &block
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
@@ -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
- - 0
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-09-28 00:00:00 -07:00
17
+ date: 2010-12-14 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency