tumblargh 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +2 -14
- data/Gemfile.lock +18 -20
- data/Rakefile +0 -20
- data/examples/{confg.ru → config.ru} +0 -0
- data/lib/tumblargh.rb +1 -0
- data/lib/tumblargh/grammar.rb +235 -55
- data/lib/tumblargh/grammar.treetop +14 -2
- data/lib/tumblargh/node/block.rb +6 -4
- data/lib/tumblargh/node/block_start.rb +15 -3
- data/lib/tumblargh/parser.rb +5 -9
- data/lib/tumblargh/renderer.rb +2 -2
- data/lib/tumblargh/renderer/base.rb +7 -5
- data/lib/tumblargh/renderer/blocks.rb +3 -3
- data/lib/tumblargh/renderer/blocks/base.rb +2 -2
- data/lib/tumblargh/renderer/document.rb +4 -11
- data/lib/tumblargh/version.rb +3 -0
- data/spec/fixtures/themes/tumblr-boilerplate.html +168 -0
- data/spec/parser_spec.rb +89 -50
- data/tumblargh.gemspec +19 -118
- metadata +73 -66
- data/VERSION +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0e50e3d39c5dc3fb912cfcaf48113581fb644456
|
4
|
+
data.tar.gz: 66980f7b07a44cb19b191f86f3c1ff10fd6a31ac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a37b11aa4bc7d25724f36039cbf566e4f46362be27e13d655fadd4a039d69e9549bbc774150e034142302ccccd35db5b2cb4b6a7be812d04dab621fd0da95497
|
7
|
+
data.tar.gz: c318b3856836d9f07d7812624c877555963153585324a924f982dc84bf727b91c1a4ddd18c7454f85824efffa8f5258b412b35beaf55c9d14cc69796ff2e6803
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
@@ -1,15 +1,3 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
4
|
-
gem 'treetop'
|
5
|
-
gem 'nokogiri'
|
6
|
-
gem 'api_cache'
|
7
|
-
|
8
|
-
|
9
|
-
group :development do
|
10
|
-
gem 'autotest-standalone'
|
11
|
-
gem 'jeweler'
|
12
|
-
gem 'rake'
|
13
|
-
gem 'rspec'
|
14
|
-
gem 'simplecov'
|
15
|
-
end
|
3
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,26 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
tumblargh (0.2.0)
|
5
|
+
activesupport (>= 3.1)
|
6
|
+
api_cache
|
7
|
+
nokogiri
|
8
|
+
treetop
|
9
|
+
|
1
10
|
GEM
|
2
|
-
remote:
|
11
|
+
remote: https://rubygems.org/
|
3
12
|
specs:
|
4
|
-
activesupport (3.2.
|
5
|
-
i18n (~> 0.6)
|
13
|
+
activesupport (3.2.14)
|
14
|
+
i18n (~> 0.6, >= 0.6.4)
|
6
15
|
multi_json (~> 1.0)
|
7
16
|
api_cache (0.2.3)
|
8
17
|
autotest-standalone (4.5.9)
|
9
18
|
diff-lcs (1.1.3)
|
10
|
-
|
11
|
-
|
12
|
-
jeweler (1.8.3)
|
13
|
-
bundler (~> 1.0)
|
14
|
-
git (>= 1.2.5)
|
15
|
-
rake
|
16
|
-
rdoc
|
17
|
-
json (1.6.6)
|
19
|
+
i18n (0.6.5)
|
20
|
+
mini_portile (0.5.1)
|
18
21
|
multi_json (1.1.0)
|
19
|
-
nokogiri (1.
|
22
|
+
nokogiri (1.6.0)
|
23
|
+
mini_portile (~> 0.5.0)
|
20
24
|
polyglot (0.3.3)
|
21
25
|
rake (0.9.2.2)
|
22
|
-
rdoc (3.12)
|
23
|
-
json (~> 1.4)
|
24
26
|
rspec (2.8.0)
|
25
27
|
rspec-core (~> 2.8.0)
|
26
28
|
rspec-expectations (~> 2.8.0)
|
@@ -33,7 +35,7 @@ GEM
|
|
33
35
|
multi_json (~> 1.0)
|
34
36
|
simplecov-html (~> 0.5.3)
|
35
37
|
simplecov-html (0.5.3)
|
36
|
-
treetop (1.4.
|
38
|
+
treetop (1.4.14)
|
37
39
|
polyglot
|
38
40
|
polyglot (>= 0.3.1)
|
39
41
|
|
@@ -41,12 +43,8 @@ PLATFORMS
|
|
41
43
|
ruby
|
42
44
|
|
43
45
|
DEPENDENCIES
|
44
|
-
activesupport (>= 3.1)
|
45
|
-
api_cache
|
46
46
|
autotest-standalone
|
47
|
-
jeweler
|
48
|
-
nokogiri
|
49
47
|
rake
|
50
48
|
rspec
|
51
49
|
simplecov
|
52
|
-
|
50
|
+
tumblargh!
|
data/Rakefile
CHANGED
@@ -17,27 +17,7 @@ RSpec::Core::RakeTask.new(:coverage) do |t|
|
|
17
17
|
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
20
|
desc "Open an irb session preloaded with this library"
|
22
21
|
task :console do
|
23
22
|
sh "irb -rubygems -I lib -r tumblargh.rb"
|
24
23
|
end
|
25
|
-
|
26
|
-
|
27
|
-
require 'jeweler'
|
28
|
-
Jeweler::Tasks.new do |s|
|
29
|
-
s.name = 'tumblargh'
|
30
|
-
s.summary = 'Groan-less Tumblr theme development.'
|
31
|
-
s.description = "If you've ever had to build a Tumblr theme, you've probably cried out in pain while tweaking locally, copying, pasting into the theme editor, saving, switching tabs and finally refreshing and waiting for your tesing blog to reload. Tumblargh aims to reduce suffering involved with building a theme by offering a way to fully develop, lint and test Tumblr themes locally, with real posts from any existing Tumblog."
|
32
|
-
s.authors = ['Jason Webster']
|
33
|
-
s.email = 'jason@metalabdesign.com'
|
34
|
-
s.homepage = 'http://github.com/jasonwebster/tumblargh'
|
35
|
-
|
36
|
-
s.files = `git ls-files`.split("\n")
|
37
|
-
s.require_path = 'lib'
|
38
|
-
end
|
39
|
-
|
40
|
-
Jeweler::RubygemsDotOrgTasks.new
|
41
|
-
|
42
|
-
|
43
|
-
|
File without changes
|
data/lib/tumblargh.rb
CHANGED
data/lib/tumblargh/grammar.rb
CHANGED
@@ -134,6 +134,10 @@ module Tumblr
|
|
134
134
|
end
|
135
135
|
|
136
136
|
module BlockStart0
|
137
|
+
def block_name
|
138
|
+
elements[1]
|
139
|
+
end
|
140
|
+
|
137
141
|
end
|
138
142
|
|
139
143
|
def _nt_block_start
|
@@ -157,44 +161,43 @@ module Tumblr
|
|
157
161
|
end
|
158
162
|
s0 << r1
|
159
163
|
if r1
|
160
|
-
|
161
|
-
loop do
|
162
|
-
if has_terminal?('\G[^\\s}:;]', true, index)
|
163
|
-
r3 = true
|
164
|
-
@index += 1
|
165
|
-
else
|
166
|
-
r3 = nil
|
167
|
-
end
|
168
|
-
if r3
|
169
|
-
s2 << r3
|
170
|
-
else
|
171
|
-
break
|
172
|
-
end
|
173
|
-
end
|
174
|
-
if s2.empty?
|
175
|
-
@index = i2
|
176
|
-
r2 = nil
|
177
|
-
else
|
178
|
-
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
179
|
-
end
|
164
|
+
r2 = _nt_block_name
|
180
165
|
s0 << r2
|
181
166
|
if r2
|
182
|
-
|
183
|
-
|
184
|
-
|
167
|
+
r4 = _nt_space
|
168
|
+
if r4
|
169
|
+
r3 = r4
|
185
170
|
else
|
186
|
-
|
187
|
-
r4 = nil
|
171
|
+
r3 = instantiate_node(SyntaxNode,input, index...index)
|
188
172
|
end
|
189
|
-
s0 <<
|
190
|
-
if
|
191
|
-
r6 =
|
173
|
+
s0 << r3
|
174
|
+
if r3
|
175
|
+
r6 = _nt_block_arguments
|
192
176
|
if r6
|
193
177
|
r5 = r6
|
194
178
|
else
|
195
179
|
r5 = instantiate_node(SyntaxNode,input, index...index)
|
196
180
|
end
|
197
181
|
s0 << r5
|
182
|
+
if r5
|
183
|
+
if has_terminal?('}', false, index)
|
184
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
185
|
+
@index += 1
|
186
|
+
else
|
187
|
+
terminal_parse_failure('}')
|
188
|
+
r7 = nil
|
189
|
+
end
|
190
|
+
s0 << r7
|
191
|
+
if r7
|
192
|
+
r9 = _nt_space
|
193
|
+
if r9
|
194
|
+
r8 = r9
|
195
|
+
else
|
196
|
+
r8 = instantiate_node(SyntaxNode,input, index...index)
|
197
|
+
end
|
198
|
+
s0 << r8
|
199
|
+
end
|
200
|
+
end
|
198
201
|
end
|
199
202
|
end
|
200
203
|
end
|
@@ -212,6 +215,10 @@ module Tumblr
|
|
212
215
|
end
|
213
216
|
|
214
217
|
module BlockEnd0
|
218
|
+
def block_name
|
219
|
+
elements[1]
|
220
|
+
end
|
221
|
+
|
215
222
|
end
|
216
223
|
|
217
224
|
def _nt_block_end
|
@@ -235,56 +242,229 @@ module Tumblr
|
|
235
242
|
end
|
236
243
|
s0 << r1
|
237
244
|
if r1
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
245
|
+
r2 = _nt_block_name
|
246
|
+
s0 << r2
|
247
|
+
if r2
|
248
|
+
if has_terminal?('}', false, index)
|
249
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
242
250
|
@index += 1
|
243
251
|
else
|
252
|
+
terminal_parse_failure('}')
|
244
253
|
r3 = nil
|
245
254
|
end
|
255
|
+
s0 << r3
|
246
256
|
if r3
|
247
|
-
|
248
|
-
|
249
|
-
|
257
|
+
r5 = _nt_space
|
258
|
+
if r5
|
259
|
+
r4 = r5
|
260
|
+
else
|
261
|
+
r4 = instantiate_node(SyntaxNode,input, index...index)
|
262
|
+
end
|
263
|
+
s0 << r4
|
250
264
|
end
|
251
265
|
end
|
252
|
-
|
253
|
-
|
254
|
-
|
266
|
+
end
|
267
|
+
if s0.last
|
268
|
+
r0 = instantiate_node(Tumblargh::Node::BlockEnd,input, i0...index, s0)
|
269
|
+
r0.extend(BlockEnd0)
|
270
|
+
else
|
271
|
+
@index = i0
|
272
|
+
r0 = nil
|
273
|
+
end
|
274
|
+
|
275
|
+
node_cache[:block_end][start_index] = r0
|
276
|
+
|
277
|
+
r0
|
278
|
+
end
|
279
|
+
|
280
|
+
def _nt_block_name
|
281
|
+
start_index = index
|
282
|
+
if node_cache[:block_name].has_key?(index)
|
283
|
+
cached = node_cache[:block_name][index]
|
284
|
+
if cached
|
285
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
286
|
+
@index = cached.interval.end
|
287
|
+
end
|
288
|
+
return cached
|
289
|
+
end
|
290
|
+
|
291
|
+
s0, i0 = [], index
|
292
|
+
loop do
|
293
|
+
if has_terminal?('\G[^\\s}:;]', true, index)
|
294
|
+
r1 = true
|
295
|
+
@index += 1
|
255
296
|
else
|
256
|
-
|
297
|
+
r1 = nil
|
257
298
|
end
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
299
|
+
if r1
|
300
|
+
s0 << r1
|
301
|
+
else
|
302
|
+
break
|
303
|
+
end
|
304
|
+
end
|
305
|
+
if s0.empty?
|
306
|
+
@index = i0
|
307
|
+
r0 = nil
|
308
|
+
else
|
309
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
310
|
+
end
|
311
|
+
|
312
|
+
node_cache[:block_name][start_index] = r0
|
313
|
+
|
314
|
+
r0
|
315
|
+
end
|
316
|
+
|
317
|
+
def _nt_block_arguments
|
318
|
+
start_index = index
|
319
|
+
if node_cache[:block_arguments].has_key?(index)
|
320
|
+
cached = node_cache[:block_arguments][index]
|
321
|
+
if cached
|
322
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
323
|
+
@index = cached.interval.end
|
324
|
+
end
|
325
|
+
return cached
|
326
|
+
end
|
327
|
+
|
328
|
+
s0, i0 = [], index
|
329
|
+
loop do
|
330
|
+
r1 = _nt_block_argument
|
331
|
+
if r1
|
332
|
+
s0 << r1
|
333
|
+
else
|
334
|
+
break
|
335
|
+
end
|
336
|
+
end
|
337
|
+
if s0.empty?
|
338
|
+
@index = i0
|
339
|
+
r0 = nil
|
340
|
+
else
|
341
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
342
|
+
end
|
343
|
+
|
344
|
+
node_cache[:block_arguments][start_index] = r0
|
345
|
+
|
346
|
+
r0
|
347
|
+
end
|
348
|
+
|
349
|
+
module BlockArgument0
|
350
|
+
end
|
351
|
+
|
352
|
+
module BlockArgument1
|
353
|
+
end
|
354
|
+
|
355
|
+
def _nt_block_argument
|
356
|
+
start_index = index
|
357
|
+
if node_cache[:block_argument].has_key?(index)
|
358
|
+
cached = node_cache[:block_argument][index]
|
359
|
+
if cached
|
360
|
+
cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
361
|
+
@index = cached.interval.end
|
362
|
+
end
|
363
|
+
return cached
|
364
|
+
end
|
365
|
+
|
366
|
+
i0, s0 = index, []
|
367
|
+
i1, s1 = index, []
|
368
|
+
s2, i2 = [], index
|
369
|
+
loop do
|
370
|
+
if has_terminal?('\G[a-zA-Z0-9]', true, index)
|
371
|
+
r3 = true
|
372
|
+
@index += 1
|
373
|
+
else
|
374
|
+
r3 = nil
|
375
|
+
end
|
376
|
+
if r3
|
377
|
+
s2 << r3
|
378
|
+
else
|
379
|
+
break
|
380
|
+
end
|
381
|
+
end
|
382
|
+
if s2.empty?
|
383
|
+
@index = i2
|
384
|
+
r2 = nil
|
385
|
+
else
|
386
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
387
|
+
end
|
388
|
+
s1 << r2
|
389
|
+
if r2
|
390
|
+
if has_terminal?('=', false, index)
|
391
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
392
|
+
@index += 1
|
393
|
+
else
|
394
|
+
terminal_parse_failure('=')
|
395
|
+
r4 = nil
|
396
|
+
end
|
397
|
+
s1 << r4
|
398
|
+
if r4
|
399
|
+
if has_terminal?('"', false, index)
|
400
|
+
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
262
401
|
@index += 1
|
263
402
|
else
|
264
|
-
terminal_parse_failure('
|
265
|
-
|
403
|
+
terminal_parse_failure('"')
|
404
|
+
r5 = nil
|
266
405
|
end
|
267
|
-
|
268
|
-
if
|
269
|
-
|
270
|
-
|
271
|
-
|
406
|
+
s1 << r5
|
407
|
+
if r5
|
408
|
+
s6, i6 = [], index
|
409
|
+
loop do
|
410
|
+
if has_terminal?('\G[a-zA-Z0-9]', true, index)
|
411
|
+
r7 = true
|
412
|
+
@index += 1
|
413
|
+
else
|
414
|
+
r7 = nil
|
415
|
+
end
|
416
|
+
if r7
|
417
|
+
s6 << r7
|
418
|
+
else
|
419
|
+
break
|
420
|
+
end
|
421
|
+
end
|
422
|
+
if s6.empty?
|
423
|
+
@index = i6
|
424
|
+
r6 = nil
|
272
425
|
else
|
273
|
-
|
426
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
427
|
+
end
|
428
|
+
s1 << r6
|
429
|
+
if r6
|
430
|
+
if has_terminal?('"', false, index)
|
431
|
+
r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
432
|
+
@index += 1
|
433
|
+
else
|
434
|
+
terminal_parse_failure('"')
|
435
|
+
r8 = nil
|
436
|
+
end
|
437
|
+
s1 << r8
|
274
438
|
end
|
275
|
-
s0 << r5
|
276
439
|
end
|
277
440
|
end
|
278
441
|
end
|
442
|
+
if s1.last
|
443
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
444
|
+
r1.extend(BlockArgument0)
|
445
|
+
else
|
446
|
+
@index = i1
|
447
|
+
r1 = nil
|
448
|
+
end
|
449
|
+
s0 << r1
|
450
|
+
if r1
|
451
|
+
r10 = _nt_space
|
452
|
+
if r10
|
453
|
+
r9 = r10
|
454
|
+
else
|
455
|
+
r9 = instantiate_node(SyntaxNode,input, index...index)
|
456
|
+
end
|
457
|
+
s0 << r9
|
458
|
+
end
|
279
459
|
if s0.last
|
280
|
-
r0 = instantiate_node(
|
281
|
-
r0.extend(
|
460
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
461
|
+
r0.extend(BlockArgument1)
|
282
462
|
else
|
283
463
|
@index = i0
|
284
464
|
r0 = nil
|
285
465
|
end
|
286
466
|
|
287
|
-
node_cache[:
|
467
|
+
node_cache[:block_argument][start_index] = r0
|
288
468
|
|
289
469
|
r0
|
290
470
|
end
|