vanilla 1.12.3 → 1.12.4

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 CHANGED
@@ -24,7 +24,7 @@ if Object.const_defined?(:Gem)
24
24
 
25
25
  # Change these as appropriate
26
26
  s.name = "vanilla"
27
- s.version = "1.12.3"
27
+ s.version = "1.12.4"
28
28
  s.summary = "A bliki-type web content thing."
29
29
  s.author = "James Adam"
30
30
  s.email = "james@lazyatom.com.com"
@@ -1,8 +1,11 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
1
4
  module SnipReference
2
5
  include Treetop::Runtime
3
6
 
4
7
  def root
5
- @root || :snip_call
8
+ @root ||= :snip_call
6
9
  end
7
10
 
8
11
  module SnipCall0
@@ -22,7 +25,10 @@ module SnipReference
22
25
  start_index = index
23
26
  if node_cache[:snip_call].has_key?(index)
24
27
  cached = node_cache[:snip_call][index]
25
- @index = cached.interval.end if cached
28
+ if cached
29
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
30
+ @index = cached.interval.end
31
+ end
26
32
  return cached
27
33
  end
28
34
 
@@ -85,11 +91,11 @@ module SnipReference
85
91
  end
86
92
 
87
93
  module SnipName0
88
- def word
94
+ def word1
89
95
  elements[0]
90
96
  end
91
97
 
92
- def word
98
+ def word2
93
99
  elements[2]
94
100
  end
95
101
  end
@@ -98,7 +104,10 @@ module SnipReference
98
104
  start_index = index
99
105
  if node_cache[:snip_name].has_key?(index)
100
106
  cached = node_cache[:snip_name][index]
101
- @index = cached.interval.end if cached
107
+ if cached
108
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
109
+ @index = cached.interval.end
110
+ end
102
111
  return cached
103
112
  end
104
113
 
@@ -166,7 +175,10 @@ module SnipReference
166
175
  start_index = index
167
176
  if node_cache[:argument_list].has_key?(index)
168
177
  cached = node_cache[:argument_list][index]
169
- @index = cached.interval.end if cached
178
+ if cached
179
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
180
+ @index = cached.interval.end
181
+ end
170
182
  return cached
171
183
  end
172
184
 
@@ -212,23 +224,38 @@ module SnipReference
212
224
  start_index = index
213
225
  if node_cache[:argument].has_key?(index)
214
226
  cached = node_cache[:argument][index]
215
- @index = cached.interval.end if cached
227
+ if cached
228
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
229
+ @index = cached.interval.end
230
+ end
216
231
  return cached
217
232
  end
218
233
 
219
234
  i0 = index
220
- r1 = _nt_unquoted_words
221
- r1.extend(NormalArgument)
235
+ r1 = _nt_hash_argument
236
+ r1.extend(HashArgument)
222
237
  if r1
223
238
  r0 = r1
224
239
  else
225
- r2 = _nt_quoted_word
240
+ r2 = _nt_unquoted_words
226
241
  r2.extend(NormalArgument)
227
242
  if r2
228
243
  r0 = r2
229
244
  else
230
- @index = i0
231
- r0 = nil
245
+ r3 = _nt_quoted_word
246
+ r3.extend(NormalArgument)
247
+ if r3
248
+ r0 = r3
249
+ else
250
+ r4 = _nt_empty_argument
251
+ r4.extend(EmptyArgument)
252
+ if r4
253
+ r0 = r4
254
+ else
255
+ @index = i0
256
+ r0 = nil
257
+ end
258
+ end
232
259
  end
233
260
  end
234
261
 
@@ -247,7 +274,10 @@ module SnipReference
247
274
  start_index = index
248
275
  if node_cache[:argument_separator].has_key?(index)
249
276
  cached = node_cache[:argument_separator][index]
250
- @index = cached.interval.end if cached
277
+ if cached
278
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
279
+ @index = cached.interval.end
280
+ end
251
281
  return cached
252
282
  end
253
283
 
@@ -277,11 +307,186 @@ module SnipReference
277
307
  r0
278
308
  end
279
309
 
310
+ module HashArgument0
311
+ def word_or_symbol
312
+ elements[0]
313
+ end
314
+
315
+ def optional_spaces1
316
+ elements[1]
317
+ end
318
+
319
+ def hash_argument_separator
320
+ elements[2]
321
+ end
322
+
323
+ def optional_spaces2
324
+ elements[3]
325
+ end
326
+
327
+ def word
328
+ elements[4]
329
+ end
330
+ end
331
+
332
+ def _nt_hash_argument
333
+ start_index = index
334
+ if node_cache[:hash_argument].has_key?(index)
335
+ cached = node_cache[:hash_argument][index]
336
+ if cached
337
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
338
+ @index = cached.interval.end
339
+ end
340
+ return cached
341
+ end
342
+
343
+ i0, s0 = index, []
344
+ r1 = _nt_word_or_symbol
345
+ s0 << r1
346
+ if r1
347
+ r2 = _nt_optional_spaces
348
+ s0 << r2
349
+ if r2
350
+ r3 = _nt_hash_argument_separator
351
+ s0 << r3
352
+ if r3
353
+ r4 = _nt_optional_spaces
354
+ s0 << r4
355
+ if r4
356
+ r5 = _nt_word
357
+ s0 << r5
358
+ end
359
+ end
360
+ end
361
+ end
362
+ if s0.last
363
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
364
+ r0.extend(HashArgument0)
365
+ else
366
+ @index = i0
367
+ r0 = nil
368
+ end
369
+
370
+ node_cache[:hash_argument][start_index] = r0
371
+
372
+ r0
373
+ end
374
+
375
+ def _nt_hash_argument_separator
376
+ start_index = index
377
+ if node_cache[:hash_argument_separator].has_key?(index)
378
+ cached = node_cache[:hash_argument_separator][index]
379
+ if cached
380
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
381
+ @index = cached.interval.end
382
+ end
383
+ return cached
384
+ end
385
+
386
+ i0 = index
387
+ if has_terminal?("=>", false, index)
388
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 2))
389
+ @index += 2
390
+ else
391
+ terminal_parse_failure("=>")
392
+ r1 = nil
393
+ end
394
+ if r1
395
+ r0 = r1
396
+ else
397
+ if has_terminal?(":", false, index)
398
+ r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
399
+ @index += 1
400
+ else
401
+ terminal_parse_failure(":")
402
+ r2 = nil
403
+ end
404
+ if r2
405
+ r0 = r2
406
+ else
407
+ @index = i0
408
+ r0 = nil
409
+ end
410
+ end
411
+
412
+ node_cache[:hash_argument_separator][start_index] = r0
413
+
414
+ r0
415
+ end
416
+
417
+ def _nt_empty_argument
418
+ start_index = index
419
+ if node_cache[:empty_argument].has_key?(index)
420
+ cached = node_cache[:empty_argument][index]
421
+ if cached
422
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
423
+ @index = cached.interval.end
424
+ end
425
+ return cached
426
+ end
427
+
428
+ r0 = _nt_optional_spaces
429
+
430
+ node_cache[:empty_argument][start_index] = r0
431
+
432
+ r0
433
+ end
434
+
435
+ module WordOrSymbol0
436
+ def word
437
+ elements[1]
438
+ end
439
+ end
440
+
441
+ def _nt_word_or_symbol
442
+ start_index = index
443
+ if node_cache[:word_or_symbol].has_key?(index)
444
+ cached = node_cache[:word_or_symbol][index]
445
+ if cached
446
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
447
+ @index = cached.interval.end
448
+ end
449
+ return cached
450
+ end
451
+
452
+ i0, s0 = index, []
453
+ if has_terminal?('\G[:]', true, index)
454
+ r2 = true
455
+ @index += 1
456
+ else
457
+ r2 = nil
458
+ end
459
+ if r2
460
+ r1 = r2
461
+ else
462
+ r1 = instantiate_node(SyntaxNode,input, index...index)
463
+ end
464
+ s0 << r1
465
+ if r1
466
+ r3 = _nt_word
467
+ s0 << r3
468
+ end
469
+ if s0.last
470
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
471
+ r0.extend(WordOrSymbol0)
472
+ else
473
+ @index = i0
474
+ r0 = nil
475
+ end
476
+
477
+ node_cache[:word_or_symbol][start_index] = r0
478
+
479
+ r0
480
+ end
481
+
280
482
  def _nt_word
281
483
  start_index = index
282
484
  if node_cache[:word].has_key?(index)
283
485
  cached = node_cache[:word][index]
284
- @index = cached.interval.end if cached
486
+ if cached
487
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
488
+ @index = cached.interval.end
489
+ end
285
490
  return cached
286
491
  end
287
492
 
@@ -308,14 +513,17 @@ module SnipReference
308
513
  start_index = index
309
514
  if node_cache[:unquoted_word].has_key?(index)
310
515
  cached = node_cache[:unquoted_word][index]
311
- @index = cached.interval.end if cached
516
+ if cached
517
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
518
+ @index = cached.interval.end
519
+ end
312
520
  return cached
313
521
  end
314
522
 
315
523
  s0, i0 = [], index
316
524
  loop do
317
525
  if has_terminal?('\G[a-zA-Z0-9_\\-]', true, index)
318
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
526
+ r1 = true
319
527
  @index += 1
320
528
  else
321
529
  r1 = nil
@@ -348,7 +556,10 @@ module SnipReference
348
556
  start_index = index
349
557
  if node_cache[:quoted_word].has_key?(index)
350
558
  cached = node_cache[:quoted_word][index]
351
- @index = cached.interval.end if cached
559
+ if cached
560
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
561
+ @index = cached.interval.end
562
+ end
352
563
  return cached
353
564
  end
354
565
 
@@ -433,14 +644,17 @@ module SnipReference
433
644
  start_index = index
434
645
  if node_cache[:unquoted_words].has_key?(index)
435
646
  cached = node_cache[:unquoted_words][index]
436
- @index = cached.interval.end if cached
647
+ if cached
648
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
649
+ @index = cached.interval.end
650
+ end
437
651
  return cached
438
652
  end
439
653
 
440
654
  s0, i0 = [], index
441
655
  loop do
442
656
  if has_terminal?('\G[a-zA-Z0-9_\\- ]', true, index)
443
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
657
+ r1 = true
444
658
  @index += 1
445
659
  else
446
660
  r1 = nil
@@ -467,14 +681,17 @@ module SnipReference
467
681
  start_index = index
468
682
  if node_cache[:optional_spaces].has_key?(index)
469
683
  cached = node_cache[:optional_spaces][index]
470
- @index = cached.interval.end if cached
684
+ if cached
685
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
686
+ @index = cached.interval.end
687
+ end
471
688
  return cached
472
689
  end
473
690
 
474
691
  s0, i0 = [], index
475
692
  loop do
476
693
  if has_terminal?('\G[ ]', true, index)
477
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
694
+ r1 = true
478
695
  @index += 1
479
696
  else
480
697
  r1 = nil
@@ -496,14 +713,17 @@ module SnipReference
496
713
  start_index = index
497
714
  if node_cache[:spaces].has_key?(index)
498
715
  cached = node_cache[:spaces][index]
499
- @index = cached.interval.end if cached
716
+ if cached
717
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
718
+ @index = cached.interval.end
719
+ end
500
720
  return cached
501
721
  end
502
722
 
503
723
  s0, i0 = [], index
504
724
  loop do
505
725
  if has_terminal?('\G[ ]', true, index)
506
- r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
726
+ r1 = true
507
727
  @index += 1
508
728
  else
509
729
  r1 = nil
@@ -15,7 +15,8 @@ grammar SnipReference
15
15
  rule argument
16
16
  hash_argument <HashArgument> /
17
17
  unquoted_words <NormalArgument> /
18
- quoted_word <NormalArgument>
18
+ quoted_word <NormalArgument> /
19
+ empty_argument <EmptyArgument>
19
20
  end
20
21
 
21
22
  rule argument_separator
@@ -31,6 +32,10 @@ grammar SnipReference
31
32
  ":"
32
33
  end
33
34
 
35
+ rule empty_argument
36
+ optional_spaces
37
+ end
38
+
34
39
  rule word_or_symbol
35
40
  [:]? word
36
41
  end
@@ -60,6 +60,11 @@ module SnipReference
60
60
  [text_value]
61
61
  end
62
62
  end
63
+ module EmptyArgument
64
+ def to_arguments
65
+ [nil]
66
+ end
67
+ end
63
68
  end
64
69
 
65
70
  require 'treetop'
@@ -16,6 +16,8 @@ class SnipReferenceParserTest < Test::Unit::TestCase
16
16
  %|{snip arg1, arg2}| => {:snip => 'snip', :attribute => nil, :arguments => ['arg1', 'arg2']},
17
17
  %|{snip "argument with spaces", arg2}| => {:snip => 'snip', :attribute => nil, :arguments => ['argument with spaces', 'arg2']},
18
18
  %|{"snip with spaces" arg1, arg2}| => {:snip => 'snip with spaces', :attribute => nil, :arguments => ['arg1', 'arg2']},
19
+ %|{snip arg1,,arg3}| => {:snip => 'snip', :attribute => nil, :arguments => ['arg1', nil, 'arg3']},
20
+ %|{snip arg1, ,arg3}| => {:snip => 'snip', :attribute => nil, :arguments => ['arg1', nil, 'arg3']},
19
21
  %|{snip.snip_attribute}| => {:snip => 'snip', :attribute => 'snip_attribute', :arguments => []},
20
22
  %|{snip."spaced attribute"}| => {:snip => 'snip', :attribute => 'spaced attribute', :arguments => []},
21
23
  %|{"snip with spaces".attribute}| => {:snip => 'snip with spaces', :attribute => 'attribute', :arguments => []},
@@ -33,6 +33,11 @@ class SnipReferenceTest < Vanilla::TestCase
33
33
  assert_equal "rendering snip content", render("rendering {test1}")
34
34
  end
35
35
 
36
+ should "match snips with ruby 1.9 style hashes" do
37
+ create_snip :name => "test", :content => "snip content"
38
+ assert_equal "rendering snip content", render("rendering {test x:1}")
39
+ end
40
+
36
41
  should "ignore references that are rubyish" do
37
42
  assert_equal "10.times { |x| puts x }", render("10.times { |x| puts x }")
38
43
  assert_equal "10.times {|x| puts x }", render("10.times {|x| puts x }")
@@ -1,7 +1,6 @@
1
1
  CurrentSnip
2
2
 
3
3
  :render_as: Ruby
4
- :name: current_snip
5
4
  :usage: |-
6
5
  The current_snip dyna normally returns the result of rendering the snip named by the
7
6
  'snip' value in the parameters. This way, it can be used in templates to place the currently
@@ -12,3 +11,4 @@ CurrentSnip
12
11
  &#123;current_snip name&#125;
13
12
 
14
13
  will output the name of the current snip, or the name of the snip currently being edited.
14
+ :name: current_snip
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanilla
3
3
  version: !ruby/object:Gem::Version
4
- hash: 33
4
+ hash: 47
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 12
9
- - 3
10
- version: 1.12.3
9
+ - 4
10
+ version: 1.12.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Adam