erbse 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES.md +4 -0
- data/lib/erbse/parser.rb +1 -1
- data/lib/erbse/version.rb +1 -1
- data/test/erbse_test.rb +34 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a7fbd1dec8733c0729e2deca42168eb95696704b85c0b0d9c37a1d14e64587ba
|
4
|
+
data.tar.gz: 0fbe06409ad39912f9b4e81183426c54a7f05be522ccc16f395640f304611280
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 512cfadfb79da8590ed0f19cd1f0f69eaf157cbef7004b6e0b6053c14df5cb95cd3980157e2cc98b4d51a60e47452fc838330da997eaa1c7e3308ba65f8aec0e
|
7
|
+
data.tar.gz: f8bfa636d35d4cbff380b7c9926a8b2ae520ac6441f61b156379c90dc29904e993d97738b113ab5dde68aa5652723e482935e2c66d9d898c9a98dd4ed8df1bc0
|
data/CHANGES.md
CHANGED
data/lib/erbse/parser.rb
CHANGED
data/lib/erbse/version.rb
CHANGED
data/test/erbse_test.rb
CHANGED
@@ -16,19 +16,22 @@ Text
|
|
16
16
|
|
17
17
|
it "what" do
|
18
18
|
Erbse::Parser.new.(str).must_equal [:multi,
|
19
|
+
[:static, "\n"],
|
19
20
|
[:dynamic, " true "], [:newline],
|
20
21
|
[:static, "Text\n"],
|
21
22
|
[:erb, :block, " form_for do ", [:multi,
|
22
23
|
[:dynamic, " 1 "],
|
23
24
|
[:code, " 2 "], [:newline],
|
25
|
+
[:static, " "],
|
24
26
|
[:erb, :block, " nested do ", [:multi, [:newline],
|
27
|
+
[:static, " "],
|
25
28
|
[:dynamic, " this "], [:newline],
|
26
29
|
[:static, " <a/>\n "],
|
27
30
|
]], [:newline]]]]
|
28
31
|
end
|
29
32
|
|
30
33
|
it "generates ruby" do
|
31
|
-
code = %{_buf = []; _buf << ( true ); @; _buf << ("Text@@".freeze); _erbse_blockfilter1 = form_for do ; _erbse_blockfilter2 = ''; _erbse_blockfilter2 << (( 1 ).to_s); 2 ; @; _erbse_blockfilter3 = nested do ; _erbse_blockfilter4 = ''; @; _erbse_blockfilter4 << (( this ).to_s); @; _erbse_blockfilter4 << (" <a/>@@ ".freeze); _erbse_blockfilter4; end; _erbse_blockfilter2 << ((_erbse_blockfilter3).to_s); @; _erbse_blockfilter2; end; _buf << (_erbse_blockfilter1); _buf = _buf.join("".freeze)}
|
34
|
+
code = %{_buf = []; _buf << ("@@".freeze); _buf << ( true ); @; _buf << ("Text@@".freeze); _erbse_blockfilter1 = form_for do ; _erbse_blockfilter2 = ''; _erbse_blockfilter2 << (( 1 ).to_s); 2 ; @; _erbse_blockfilter2 << (" ".freeze); _erbse_blockfilter3 = nested do ; _erbse_blockfilter4 = ''; @; _erbse_blockfilter4 << (" ".freeze); _erbse_blockfilter4 << (( this ).to_s); @; _erbse_blockfilter4 << (" <a/>@@ ".freeze); _erbse_blockfilter4; end; _erbse_blockfilter2 << ((_erbse_blockfilter3).to_s); @; _erbse_blockfilter2; end; _buf << (_erbse_blockfilter1); _buf = _buf.join("".freeze)}
|
32
35
|
ruby = Erbse::Engine.new.(str).gsub("\n", "@").gsub('\n', "@@")
|
33
36
|
# puts ruby
|
34
37
|
ruby.must_equal code
|
@@ -36,39 +39,38 @@ Text
|
|
36
39
|
|
37
40
|
describe "<% %>" do
|
38
41
|
let (:str) { %{
|
39
|
-
<% self %>
|
40
42
|
<% 2.times do |i| %>
|
41
43
|
<%= i+1 %>
|
42
44
|
<% puts %>
|
43
45
|
<% end %>
|
44
46
|
|
45
|
-
<% if 1 %>
|
47
|
+
<% if 1 == 1 %>
|
46
48
|
Hello
|
47
49
|
<% end %>
|
48
50
|
}
|
49
51
|
}
|
50
52
|
it "what" do
|
51
53
|
Erbse::Parser.new.(str).must_equal [:multi,
|
52
|
-
[:
|
53
|
-
[:block, " 2.times do |i| ", [:multi,
|
54
|
-
[:
|
54
|
+
[:static, "\n"],
|
55
|
+
[:block, " 2.times do |i| ", [:multi,
|
56
|
+
[:newline],
|
57
|
+
[:static, " "],
|
58
|
+
[:dynamic, " i+1 "], [:newline], [:static, " "],
|
55
59
|
[:code, " puts "], [:newline]]], [:newline],
|
56
|
-
[:block, " if 1 ", [:multi, [:newline],
|
57
|
-
[:static, " Hello
|
58
|
-
"]]], [:newline]]
|
60
|
+
[:block, " if 1 == 1 ", [:multi, [:newline],
|
61
|
+
[:static, " Hello\n"]]], [:newline]]
|
59
62
|
end
|
60
63
|
|
61
64
|
it do
|
62
65
|
ruby = Erbse::Engine.new.(str)
|
63
66
|
ruby = ruby.gsub("\n", "@")
|
64
|
-
|
65
67
|
# ruby.must_equal %{_buf = []; self ; 2.times do |i| ; _buf << ( i+1 ); puts ; end; _buf = _buf.join(\"\".freeze)}
|
66
|
-
ruby.must_equal '_buf = [];
|
68
|
+
ruby.must_equal '_buf = []; _buf << ("\n".freeze); 2.times do |i| ; @; _buf << (" ".freeze); _buf << ( i+1 ); @; _buf << (" ".freeze); puts ; @; end; @; if 1 == 1 ; @; _buf << (" Hello\n".freeze); end; @; _buf = _buf.join("".freeze)'
|
67
69
|
end
|
68
70
|
|
69
71
|
it do
|
70
72
|
ruby = Erbse::Engine.new.(str)
|
71
|
-
eval(ruby).must_equal "
|
73
|
+
eval(ruby).must_equal "\n 1 2 Hello\n"
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
@@ -166,6 +168,26 @@ blubb</b>} }
|
|
166
168
|
it { Erbse::Parser.new.(%{<% form do |i| %>1<% end %>}).must_equal [:multi, [:block, " form do |i| ", [:multi, [:static, "1"]]]] }
|
167
169
|
end
|
168
170
|
|
171
|
+
describe "quoted conditional" do
|
172
|
+
let (:str2) { %{
|
173
|
+
<%= form_for do %>
|
174
|
+
<%= link_to "string", path, "v-if" => "trigger" %>
|
175
|
+
<% end %>}
|
176
|
+
}
|
177
|
+
|
178
|
+
it "parses quoted conditionals correctly" do
|
179
|
+
Erbse::Parser.new.(str2).must_equal [:multi,
|
180
|
+
[:static, "\n "],
|
181
|
+
[:erb, :block, " form_for do ", [:multi,
|
182
|
+
[:newline],
|
183
|
+
[:static, " "],
|
184
|
+
[:dynamic, " link_to \"string\", path, \"v-if\" => \"trigger\" "],
|
185
|
+
[:newline],
|
186
|
+
[:static, " "]
|
187
|
+
]]]
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
169
191
|
describe "<%@ %>" do
|
170
192
|
let (:str) { %{<%@ content = capture do %>
|
171
193
|
Yo!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erbse
|
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
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: temple
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
101
|
+
rubygems_version: 2.7.3
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Updated Erubis.
|