ratatouille 1.2.4 → 1.2.5
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/README.md +1 -1
- data/lib/ratatouille/hash.rb +2 -2
- data/lib/ratatouille/version.rb +1 -1
- data/spec/lib/ratatouille/hash_spec.rb +8 -0
- metadata +3 -3
data/README.md
CHANGED
@@ -163,7 +163,7 @@ Used to ensure that the list of keys exist in the Hash.
|
|
163
163
|
Used to ensure given key exists in the Hash.
|
164
164
|
|
165
165
|
* Eliminates the need to perform "given\_key" methods within a "required\_keys" block.
|
166
|
-
*
|
166
|
+
* Evaluates an optional block in context of key value (same as given\_key)
|
167
167
|
|
168
168
|
|
169
169
|
#### Syntax
|
data/lib/ratatouille/hash.rb
CHANGED
@@ -85,7 +85,7 @@ module Ratatouille
|
|
85
85
|
#
|
86
86
|
# @param [String,Symbol] req_key Required Key
|
87
87
|
# @return [void]
|
88
|
-
def required_key(req_key, &block)
|
88
|
+
def required_key(req_key, options={}, &block)
|
89
89
|
if req_key.nil?
|
90
90
|
validation_error("required_key needs key argument")
|
91
91
|
return
|
@@ -101,7 +101,7 @@ module Ratatouille
|
|
101
101
|
return
|
102
102
|
end
|
103
103
|
|
104
|
-
|
104
|
+
given_key(req_key, options, &block) if block_given?
|
105
105
|
rescue Exception => e
|
106
106
|
validation_error("#{e.message}")
|
107
107
|
end
|
data/lib/ratatouille/version.rb
CHANGED
@@ -79,6 +79,14 @@ describe "Ratatouille::HashMethods" do
|
|
79
79
|
end
|
80
80
|
f.should be_false
|
81
81
|
end
|
82
|
+
|
83
|
+
it "should change the scope name to default to the key if no name passed as option" do
|
84
|
+
n = ""
|
85
|
+
RatifierTest.new({:foo => "bar"}) do
|
86
|
+
required_key(:foo) { n = name }
|
87
|
+
end
|
88
|
+
n.should == ":foo"
|
89
|
+
end
|
82
90
|
end
|
83
91
|
|
84
92
|
describe "given_key" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ratatouille
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 5
|
10
|
+
version: 1.2.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Johnson
|