braai 1.2.1 → 1.2.2
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/Gemfile.lock +2 -2
- data/README.md +1 -0
- data/lib/braai/matchers.rb +26 -18
- data/lib/braai/version.rb +1 -1
- data/spec/braai/matchers_spec.rb +14 -2
- metadata +3 -3
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
braai (1.2.
|
4
|
+
braai (1.2.2)
|
5
5
|
activesupport
|
6
6
|
|
7
7
|
GEM
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
multi_json (~> 1.0)
|
13
13
|
diff-lcs (1.1.3)
|
14
14
|
i18n (0.6.1)
|
15
|
-
multi_json (1.
|
15
|
+
multi_json (1.5.0)
|
16
16
|
rspec (2.11.0)
|
17
17
|
rspec-core (~> 2.11.0)
|
18
18
|
rspec-expectations (~> 2.11.0)
|
data/README.md
CHANGED
data/lib/braai/matchers.rb
CHANGED
@@ -17,24 +17,32 @@ module Braai::Matchers
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def reset!
|
20
|
-
@matchers = {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
20
|
+
@matchers = {}
|
21
|
+
set_defaults
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_defaults
|
25
|
+
@matchers ||= {}
|
26
|
+
|
27
|
+
@matchers[/({{\s*for (\w+) in (\w+)\s*}}(.+?){{\s*\/for\s*}})/im] = ->(template, key, matches) {
|
28
|
+
res = []
|
29
|
+
template.attributes[matches[2]].each do |val|
|
30
|
+
res << Braai::Context.new(matches[3], template.matchers, template.attributes.merge(matches[1] => val)).render
|
31
|
+
end
|
32
|
+
res.join("\n")
|
33
|
+
}
|
34
|
+
|
35
|
+
@matchers[/({{\s*([\w]+)\.([\w]+)\s*}})/i] = ->(template, key, matches) {
|
36
|
+
attr = template.attributes[matches[1]]
|
37
|
+
attr ? attr.send(matches[2]) : nil
|
38
|
+
}
|
39
|
+
|
40
|
+
@matchers[/({{\s*([\w]+)\s*}})/i] = ->(template, key, matches) {
|
41
|
+
attr = template.attributes[matches.last]
|
42
|
+
attr ? attr.to_s : nil
|
36
43
|
}
|
37
|
-
|
44
|
+
|
45
|
+
@matchers
|
38
46
|
end
|
39
47
|
|
40
|
-
end
|
48
|
+
end
|
data/lib/braai/version.rb
CHANGED
data/spec/braai/matchers_spec.rb
CHANGED
@@ -41,7 +41,7 @@ describe Braai::Matchers do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe 'reset!' do
|
44
|
-
|
44
|
+
|
45
45
|
it "resets the matchers to their original state" do
|
46
46
|
matchers.should have(3).matchers
|
47
47
|
map("foo") {}
|
@@ -52,4 +52,16 @@ describe Braai::Matchers do
|
|
52
52
|
|
53
53
|
end
|
54
54
|
|
55
|
-
|
55
|
+
describe 'set_defaults' do
|
56
|
+
|
57
|
+
it "installs the three base matchers" do
|
58
|
+
clear!
|
59
|
+
map("foo") {}
|
60
|
+
matchers.should have(1).matchers
|
61
|
+
set_defaults
|
62
|
+
matchers.should have(4).matchers
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: braai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
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-12-
|
12
|
+
date: 2012-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
74
|
rubyforge_project:
|
75
|
-
rubygems_version: 1.8.
|
75
|
+
rubygems_version: 1.8.23
|
76
76
|
signing_key:
|
77
77
|
specification_version: 3
|
78
78
|
summary: Fully extensible templating system.
|