rux 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/rux/parser.rb +4 -1
- data/lib/rux/version.rb +1 -1
- data/spec/parser_spec.rb +50 -33
- data/spec/render_spec.rb +29 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8b60a8c9f9753af9e86862c0f907f726d5c853e2e7c96613d681ea36f6859ac
|
4
|
+
data.tar.gz: 4ed1a4772678e181f7fa67ccdd4814e726a2731145e0c8a419261c2b40ad4f36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f70d67e41488c9dc648d4f05692813fe7b00ee86fc3ce34511ab75ad27de888578558775cb075f29b32df3876d0fbc7dfad78be43bdda5c198c52be8a05e5707
|
7
|
+
data.tar.gz: c43ab2dbbeeb1ae8ec17b68cb2b24df38e167787b85004bc6085669fb5963180e7f41712f4b41a5697190e851494e575927a21ed01b3800705b721f399eb76fa
|
data/CHANGELOG.md
CHANGED
data/lib/rux/parser.rb
CHANGED
@@ -188,7 +188,10 @@ module Rux
|
|
188
188
|
end
|
189
189
|
|
190
190
|
def squeeze_lit(lit)
|
191
|
-
lit
|
191
|
+
lit
|
192
|
+
.sub(/\A\s+/) { |s| s.match?(/[\r\n]/) ? "" : s }
|
193
|
+
.sub(/\s+\z/) { |s| s.match?(/[\r\n]/) ? "" : s }
|
194
|
+
.gsub(/\s+/, " ")
|
192
195
|
end
|
193
196
|
|
194
197
|
def literal_ruby_code
|
data/lib/rux/version.rb
CHANGED
data/spec/parser_spec.rb
CHANGED
@@ -136,18 +136,14 @@ describe Rux::Parser do
|
|
136
136
|
|
137
137
|
expect(compile(rux_code)).to eq(<<~RUBY.strip)
|
138
138
|
render(Outer.new) {
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
_rux_buf_ << @thing
|
146
|
-
}.to_s
|
147
|
-
}
|
139
|
+
5.times.map {
|
140
|
+
render(Inner.new) {
|
141
|
+
Rux.create_buffer.tap { |_rux_buf_|
|
142
|
+
_rux_buf_ << "What a "
|
143
|
+
_rux_buf_ << @thing
|
144
|
+
}.to_s
|
148
145
|
}
|
149
|
-
|
150
|
-
}.to_s
|
146
|
+
}
|
151
147
|
}
|
152
148
|
RUBY
|
153
149
|
end
|
@@ -163,18 +159,14 @@ describe Rux::Parser do
|
|
163
159
|
|
164
160
|
expect(compile(rux_code)).to eq(<<~RUBY.strip)
|
165
161
|
Rux.tag("div") {
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
_rux_buf_ << @thing
|
173
|
-
}.to_s
|
174
|
-
}
|
162
|
+
5.times.map {
|
163
|
+
Rux.tag("p") {
|
164
|
+
Rux.create_buffer.tap { |_rux_buf_|
|
165
|
+
_rux_buf_ << "What a "
|
166
|
+
_rux_buf_ << @thing
|
167
|
+
}.to_s
|
175
168
|
}
|
176
|
-
|
177
|
-
}.to_s
|
169
|
+
}
|
178
170
|
}
|
179
171
|
RUBY
|
180
172
|
end
|
@@ -198,18 +190,14 @@ describe Rux::Parser do
|
|
198
190
|
|
199
191
|
expect(compile(rux_code)).to eq(<<~RUBY.strip)
|
200
192
|
render(Outer.new) {
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
_rux_buf_ << @cool
|
208
|
-
}.to_s
|
209
|
-
}
|
193
|
+
5.times.map {
|
194
|
+
Rux.tag("div") {
|
195
|
+
Rux.create_buffer.tap { |_rux_buf_|
|
196
|
+
_rux_buf_ << "So "
|
197
|
+
_rux_buf_ << @cool
|
198
|
+
}.to_s
|
210
199
|
}
|
211
|
-
|
212
|
-
}.to_s
|
200
|
+
}
|
213
201
|
}
|
214
202
|
RUBY
|
215
203
|
end
|
@@ -253,4 +241,33 @@ describe Rux::Parser do
|
|
253
241
|
}
|
254
242
|
RUBY
|
255
243
|
end
|
244
|
+
|
245
|
+
it 'does not emit spaces for newlines or indentation' do
|
246
|
+
code = <<~RUX
|
247
|
+
<Hello>
|
248
|
+
<Hola>{first} {second}</Hola>
|
249
|
+
<Hola>{first} {second}</Hola>
|
250
|
+
</Hello>
|
251
|
+
RUX
|
252
|
+
expect(compile(code)).to eq(<<~RUBY.strip)
|
253
|
+
render(Hello.new) {
|
254
|
+
Rux.create_buffer.tap { |_rux_buf_|
|
255
|
+
_rux_buf_ << render(Hola.new) {
|
256
|
+
Rux.create_buffer.tap { |_rux_buf_|
|
257
|
+
_rux_buf_ << first
|
258
|
+
_rux_buf_ << " "
|
259
|
+
_rux_buf_ << second
|
260
|
+
}.to_s
|
261
|
+
}
|
262
|
+
_rux_buf_ << render(Hola.new) {
|
263
|
+
Rux.create_buffer.tap { |_rux_buf_|
|
264
|
+
_rux_buf_ << first
|
265
|
+
_rux_buf_ << " "
|
266
|
+
_rux_buf_ << second
|
267
|
+
}.to_s
|
268
|
+
}
|
269
|
+
}.to_s
|
270
|
+
}
|
271
|
+
RUBY
|
272
|
+
end
|
256
273
|
end
|
data/spec/render_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe Rux do
|
|
15
15
|
</div>
|
16
16
|
RUBY
|
17
17
|
|
18
|
-
expect(result).to eq("<div
|
18
|
+
expect(result).to eq("<div><p>Welcome!</p><p>Welcome!</p><p>Welcome!</p></div>")
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'handles rux tags inside ruby code' do
|
@@ -27,7 +27,7 @@ describe Rux do
|
|
27
27
|
</div>
|
28
28
|
RUBY
|
29
29
|
|
30
|
-
expect(result).to eq("<div
|
30
|
+
expect(result).to eq("<div><p>Welcome!</p><p>Welcome!</p><p>Welcome!</p></div>")
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'correctly handles keyword arguments (ruby 3)' do
|
@@ -37,4 +37,30 @@ describe Rux do
|
|
37
37
|
|
38
38
|
expect(result).to eq("<p>a and b</p>")
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
|
+
it 'removes whitespace between elements and text' do
|
42
|
+
result = render(<<~RUBY)
|
43
|
+
<div>
|
44
|
+
<p>Hello World</p>
|
45
|
+
|
46
|
+
<p>
|
47
|
+
Hello World
|
48
|
+
</p>
|
49
|
+
|
50
|
+
<p>
|
51
|
+
Hello
|
52
|
+
World
|
53
|
+
</p>
|
54
|
+
|
55
|
+
<p>
|
56
|
+
|
57
|
+
Hello World
|
58
|
+
</p>
|
59
|
+
</div>
|
60
|
+
RUBY
|
61
|
+
|
62
|
+
expect(result).to eq(
|
63
|
+
"<div><p>Hello World</p><p>Hello World</p><p>Hello World</p><p>Hello World</p></div>"
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
100
|
+
rubygems_version: 3.2.22
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: A jsx-inspired way to write view components.
|