claus 0.1.0 → 0.2.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/lib/claus.rb +3 -2
- data/test/test_claus.rb +8 -0
- metadata +2 -2
data/lib/claus.rb
CHANGED
@@ -44,7 +44,7 @@ class Claus
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def match? value
|
47
|
-
ast == value
|
47
|
+
ast == '*' || ast == value
|
48
48
|
end
|
49
49
|
end # Node
|
50
50
|
|
@@ -62,8 +62,9 @@ class Claus
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def match? value
|
65
|
+
return false unless ::Hash === value
|
65
66
|
ast.each do |k, node|
|
66
|
-
return false unless
|
67
|
+
return false unless value.key?(k) && node.match?(value[k])
|
67
68
|
end
|
68
69
|
true
|
69
70
|
end
|
data/test/test_claus.rb
CHANGED
@@ -40,4 +40,12 @@ describe 'claus' do
|
|
40
40
|
assert_equal false, claus.match?(foo: 1, bar: {baz: 3})
|
41
41
|
assert_equal false, claus.match?(foo: 1)
|
42
42
|
end
|
43
|
+
|
44
|
+
it 'should match wildcards' do
|
45
|
+
claus = Claus.new(foo: 1, bar: '*')
|
46
|
+
|
47
|
+
assert_equal true, claus.match?(foo: 1, bar: 1)
|
48
|
+
assert_equal false, claus.match?(foo: 1)
|
49
|
+
assert_equal false, claus.match?(foo: 2)
|
50
|
+
end
|
43
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: claus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|