configatron 3.0.0.rc1 → 3.0.0.rc2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 726b6ffdc130933ec1a38572f833537dd560c343
4
- data.tar.gz: 2e905aedd57354e7bbda54a5e450d2288ac00493
3
+ metadata.gz: 58b13f3efe20c962da4a356583a33d255d6e1cb2
4
+ data.tar.gz: a5f2477c20973a184814694b94fb6a7792f87f20
5
5
  SHA512:
6
- metadata.gz: 19ec11d3152a002763a48ce31ad2eaf63b1413c991d4e50116d60298ca042e870065f86118266c6def811cbe2554dda330ca269cf4637eaa39f938c93fe098fb
7
- data.tar.gz: f4dddffa04bbad1beb942302ca9366e47b6db9f7fbe53e96b402aa01bdcd6b1e0dfe6e29574c7da3e15223d200fcbcec1e4ae99477db8fe36da216171a23fda2
6
+ metadata.gz: f88215c2cbdc91fb1b14060abd3fa089044e6e78c29be56a19316c592f1d87f57dfe561f2203725dc399e7e82a0d50a40187f1bf00dbebc85aa28008afd3627b
7
+ data.tar.gz: 7a1ad89abf14100fdfeb45db8f084e29b7273942224229ffc2a9c1e3f52e6a44aaada82a93f29f635a6fdcf3d5af9ee4b552c356bd80dae6ba9e0a6bbce0310f
data/.gitignore CHANGED
File without changes
data/.rvmrc CHANGED
@@ -1 +1,2 @@
1
+ # rvm use ruby-2.0.0-preview1
1
2
  rvm use 2.0.0
@@ -1,9 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.2
4
3
  - 1.9.3
5
- - jruby-19mode
6
- - rbx-19mode
7
- - ruby-head
4
+ - 2.0.0
8
5
 
9
6
  script: bundle exec rake
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  class Configatron
2
- VERSION = "3.0.0.rc1"
2
+ VERSION = "3.0.0.rc2"
3
3
  end
@@ -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.rc1
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-01 00:00:00.000000000 Z
11
+ date: 2013-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake