dns_guru 0.1.2 → 0.1.3
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/Rakefile +1 -1
- data/lib/dns_guru/matcher.rb +6 -1
- data/test/dns_guru/test_matcher.rb +9 -4
- metadata +2 -2
data/Rakefile
CHANGED
data/lib/dns_guru/matcher.rb
CHANGED
@@ -20,7 +20,12 @@ module DnsGuru
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def rewrite(string, options = {})
|
23
|
-
|
23
|
+
params = match(string)
|
24
|
+
if params
|
25
|
+
generate(match(string).merge(options))
|
26
|
+
else
|
27
|
+
string
|
28
|
+
end
|
24
29
|
end
|
25
30
|
|
26
31
|
def pattern(pattern_string, params = {})
|
@@ -32,16 +32,16 @@ module DnsGuru
|
|
32
32
|
|
33
33
|
def test_generate_no_hit
|
34
34
|
hash = { :str => "mygenerate_here" }
|
35
|
-
|
36
|
-
|
35
|
+
matcher = Matcher.new([m1 = MockPattern.new, m2 = MockPattern.new])
|
36
|
+
matcher.generate(hash)
|
37
37
|
assert_equal hash, m1.got_generate, "First Pattern wasn't checked"
|
38
38
|
assert_equal hash, m2.got_generate, "Second Pattern wasn't checked"
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_generate_hit
|
42
42
|
hash = { :str => "mygenerate_here" }
|
43
|
-
|
44
|
-
|
43
|
+
matcher = Matcher.new([m1 = MockPattern.new(true), m2 = MockPattern.new])
|
44
|
+
matcher.generate(hash)
|
45
45
|
assert_equal hash, m1.got_generate, "First Pattern wasn't checked"
|
46
46
|
assert_equal nil, m2.got_generate, "Second Pattern should not have been checked"
|
47
47
|
end
|
@@ -70,6 +70,11 @@ module DnsGuru
|
|
70
70
|
assert_equal "www.mmp.com", matcher.generate
|
71
71
|
end
|
72
72
|
|
73
|
+
def test_rewrite_no_hit
|
74
|
+
matcher = Matcher.new
|
75
|
+
assert_equal "asdfasdf", matcher.rewrite("asdfasdf",:anything => :else)
|
76
|
+
end
|
77
|
+
|
73
78
|
end
|
74
79
|
|
75
80
|
class MockPattern
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dns_guru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dns Guru
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|