configatron 3.0.0.rc1 → 3.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.rvmrc +1 -0
- data/.travis.yml +1 -4
- data/README.md +13 -1
- data/lib/configatron/store.rb +9 -2
- data/lib/configatron/version.rb +1 -1
- data/test/configatron/store_test.rb +14 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58b13f3efe20c962da4a356583a33d255d6e1cb2
|
4
|
+
data.tar.gz: a5f2477c20973a184814694b94fb6a7792f87f20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f88215c2cbdc91fb1b14060abd3fa089044e6e78c29be56a19316c592f1d87f57dfe561f2203725dc399e7e82a0d50a40187f1bf00dbebc85aa28008afd3627b
|
7
|
+
data.tar.gz: 7a1ad89abf14100fdfeb45db8f084e29b7273942224229ffc2a9c1e3f52e6a44aaada82a93f29f635a6fdcf3d5af9ee4b552c356bd80dae6ba9e0a6bbce0310f
|
data/.gitignore
CHANGED
File without changes
|
data/.rvmrc
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Configatron
|
2
|
+
[![Build Status](https://travis-ci.org/markbates/configatron.png)](https://travis-ci.org/markbates/configatron) [![Code Climate](https://codeclimate.com/github/markbates/configatron.png)](https://codeclimate.com/github/markbates/configatron)
|
2
3
|
|
3
4
|
Configatron makes configuring your applications and scripts incredibly easy. No longer is a there a need to use constants or global variables. Now you can use a simple and painless system to configure your life. And, because it's all Ruby, you can do any crazy thing you would like to!
|
4
5
|
|
@@ -158,6 +159,17 @@ You can use `.has_key?` to determine if a key already exists.
|
|
158
159
|
configatron.i.dont.has_key?(:exist) # => false
|
159
160
|
```
|
160
161
|
|
162
|
+
#### (key)!
|
163
|
+
|
164
|
+
You can also append a `!` to the end of any key. If the key exists it will return it, otherwise it will raise a `Configatron::UndefinedKeyError`.
|
165
|
+
|
166
|
+
``` ruby
|
167
|
+
configatron.a.b = 'B'
|
168
|
+
configatron.a.b # => 'B'
|
169
|
+
configatron.a.b! # => 'B'
|
170
|
+
configatron.a.b.c! # => raise Configratron::UndefinedKeyError
|
171
|
+
```
|
172
|
+
|
161
173
|
### Kernel
|
162
174
|
|
163
175
|
The `configatron` "helper" method is store in the `Kernel` module. Some people didn't like that in the V2 of Configatron, so in V3, while that hasn't changed, you don't have to use it.
|
@@ -249,4 +261,4 @@ configatron.to_h # => {:letters=>{:a=>"A", :b=>"BB", :c=>"C"}}
|
|
249
261
|
* joe miller
|
250
262
|
* Brandon Dimcheff
|
251
263
|
* Dan Pickett
|
252
|
-
* Josh Nichols
|
264
|
+
* Josh Nichols
|
data/lib/configatron/store.rb
CHANGED
@@ -48,7 +48,7 @@ class Configatron
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def has_key?(key)
|
51
|
-
val = self[key]
|
51
|
+
val = self[key.to_sym]
|
52
52
|
!val.is_a?(Configatron::Store)
|
53
53
|
end
|
54
54
|
|
@@ -75,6 +75,13 @@ class Configatron
|
|
75
75
|
name = name.to_s
|
76
76
|
if /(.+)=$/.match(name)
|
77
77
|
return store($1, args[0])
|
78
|
+
elsif /(.+)!/.match(name)
|
79
|
+
key = $1
|
80
|
+
if self.has_key?(key)
|
81
|
+
return self[key]
|
82
|
+
else
|
83
|
+
raise Configatron::UndefinedKeyError.new($1)
|
84
|
+
end
|
78
85
|
else
|
79
86
|
return self[name]
|
80
87
|
end
|
@@ -97,4 +104,4 @@ class Configatron
|
|
97
104
|
# def_delegator :$stdout, :puts
|
98
105
|
|
99
106
|
end
|
100
|
-
end
|
107
|
+
end
|
data/lib/configatron/version.rb
CHANGED
@@ -110,6 +110,19 @@ describe Configatron::Store do
|
|
110
110
|
store.a.b.c.d.must_equal "DD"
|
111
111
|
end
|
112
112
|
|
113
|
+
context 'with bang' do
|
114
|
+
|
115
|
+
it "raises an exception if the key doesn't exist" do
|
116
|
+
lambda {store.a.b!}.must_raise Configatron::UndefinedKeyError
|
117
|
+
end
|
118
|
+
|
119
|
+
it "returns the value" do
|
120
|
+
store.a.b = 'B'
|
121
|
+
store.a.b!.must_equal 'B'
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
113
126
|
end
|
114
127
|
|
115
128
|
context "lock!" do
|
@@ -188,4 +201,4 @@ describe Configatron::Store do
|
|
188
201
|
|
189
202
|
end
|
190
203
|
|
191
|
-
end
|
204
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configatron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.
|
4
|
+
version: 3.0.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Bates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07
|
11
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|