erubi 1.8.0 → 1.9.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30bbae115393cc4d2ff05acd506ebd7616aad0797454c91766b379bfbfecef8b
4
- data.tar.gz: 4dd7876504af9f3a17674875daad4233b9731c7bd3f195ecdf2e2507a2fa33b1
3
+ metadata.gz: '0929d05c25dcdf116a4629c9803bbf70e4abac132acec9d831a3492a5903c5c6'
4
+ data.tar.gz: d95fccdac8f5755b1137b4cd652be69f23db18729f972cd017b613e2e2b80426
5
5
  SHA512:
6
- metadata.gz: 380753f81d65b28686ccc285bb77ed998fe95ef179fea87b28c74701c833182225ba22f544fbc2276cad1f5d1c8309a3c837e5e78ba120806b49b8b675d2ba30
7
- data.tar.gz: 006365ddcb013ebb47789055993e176640ba8f285b4bb718c85d9a0793d7ba428587adab203976dc068dcb7fc0d466e76362f6fbcab7832d7463dfc05a7e3934
6
+ metadata.gz: 54b160b258687a50dfc541b9f9c59fbbe3e8cff020432003b00e7cfa950c81d1a7ae0eef978c8e53b2c49c85995f40600395ffaccb578e1e07b303f5f7bb3298
7
+ data.tar.gz: 5d9a63e80b79f2afc48cdb42016ec937556dc62d98987fe0fa9d87e0bad7e744d8f710860f188e500bb0718ca0eb0d5779d6e65de7f2d3664833e86f1802e68d
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.9.0 (2019-09-25)
2
+
3
+ * Change default :bufvar from 'String.new' to '::String.new' to work with BasicObject (jeremyevans)
4
+
1
5
  === 1.8.0 (2018-12-18)
2
6
 
3
7
  * Support :yield_returns_buffer option in capture_end for always returning the (potentially modified) buffer in <%|= tags (evanleck) (#15)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Erubi
4
- VERSION = '1.8.0'
4
+ VERSION = '1.9.0'
5
5
  RANGE_ALL = 0..-1
6
6
 
7
7
  if RUBY_VERSION >= '1.9'
@@ -51,9 +51,9 @@ module Erubi
51
51
 
52
52
  # Initialize a new Erubi::Engine. Options:
53
53
  # :bufval :: The value to use for the buffer variable, as a string.
54
- # :bufvar :: The variable name to use for the buffer variable, as a string.
54
+ # :bufvar :: The variable name to use for the buffer variable, as a string (default '::String.new')
55
55
  # :ensure :: Wrap the template in a begin/ensure block restoring the previous value of bufvar.
56
- # :escapefunc :: The function to use for escaping, as a string (default: ::Erubi.h).
56
+ # :escapefunc :: The function to use for escaping, as a string (default: '::Erubi.h').
57
57
  # :escape :: Whether to make <%= escape by default, and <%== not escape by default.
58
58
  # :escape_html :: Same as :escape, with lower priority.
59
59
  # :filename :: The filename for the template.
@@ -69,7 +69,7 @@ module Erubi
69
69
  trim = properties[:trim] != false
70
70
  @filename = properties[:filename]
71
71
  @bufvar = bufvar = properties[:bufvar] || properties[:outvar] || "_buf"
72
- bufval = properties[:bufval] || 'String.new'
72
+ bufval = properties[:bufval] || '::String.new'
73
73
  regexp = properties[:regexp] || /<%(={1,2}|-|\#|%)?(.*?)([-=])?%>([ \t]*\r?\n)?/m
74
74
  preamble = properties[:preamble] || "#{bufvar} = #{bufval};"
75
75
  postamble = properties[:postamble] || "#{bufvar}.to_s\n"
@@ -21,7 +21,7 @@ module Erubi
21
21
  escape = properties.fetch(:escape){properties.fetch(:escape_html, false)}
22
22
  @escape_capture = properties.fetch(:escape_capture, escape)
23
23
  @yield_returns_buffer = properties.fetch(:yield_returns_buffer, false)
24
- @bufval = properties[:bufval] ||= 'String.new'
24
+ @bufval = properties[:bufval] ||= '::String.new'
25
25
  @bufstack = '__erubi_stack'
26
26
  properties[:regexp] ||= /<%(\|?={1,2}|-|\#|%|\|)?(.*?)([-=])?%>([ \t]*\r?\n)?/m
27
27
  super
@@ -25,8 +25,8 @@ require 'erubi'
25
25
  require 'erubi/capture_end'
26
26
 
27
27
  ENV['MT_NO_PLUGINS'] = '1' # Work around stupid autoloading of plugins
28
- require 'minitest/spec'
29
- require 'minitest/autorun'
28
+ gem 'minitest'
29
+ require 'minitest/global_expectations/autorun'
30
30
 
31
31
  describe Erubi::Engine do
32
32
  before do
@@ -94,7 +94,7 @@ describe Erubi::Engine do
94
94
  </table>
95
95
  <%== i+1 %>
96
96
  END1
97
- _buf = String.new; _buf << '<table>
97
+ _buf = ::String.new; _buf << '<table>
98
98
  <tbody>
99
99
  '; i = 0
100
100
  list.each_with_index do |item, i|
@@ -142,7 +142,7 @@ b
142
142
  <%# 3 %>//
143
143
  c
144
144
  END1
145
- _buf = String.new; 1
145
+ _buf = ::String.new; 1
146
146
  _buf << 'a
147
147
  '; 2
148
148
  _buf << 'b
@@ -201,7 +201,7 @@ END3
201
201
  </table>
202
202
  <%== i+1 %>
203
203
  END1
204
- begin; __original_outvar = @a if defined?(@a); @a = String.new; @a << '<table>
204
+ begin; __original_outvar = @a if defined?(@a); @a = ::String.new; @a << '<table>
205
205
  <tbody>
206
206
  '; i = 0
207
207
  list.each_with_index do |item, i|
@@ -265,9 +265,9 @@ END3
265
265
  </tbody>
266
266
  </table>
267
267
  END1
268
- #{'__erubi = ::Erubi;' unless escape}@a = String.new; @a << '<table>
268
+ #{'__erubi = ::Erubi;' unless escape}@a = ::String.new; @a << '<table>
269
269
  <tbody>
270
- '; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << (( bar do @a << '
270
+ '; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << (( bar do @a << '
271
271
  '; @a << ' <b>'; @a << #{!escape ? '__erubi' : '::Erubi'}.h(( '&' )); @a << '</b>
272
272
  '; @a << ' '; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
273
273
  '; @a << ' </tbody>
@@ -301,9 +301,9 @@ END3
301
301
  </tbody>
302
302
  </table>
303
303
  END1
304
- #{'__erubi = ::Erubi;' if escape}@a = String.new; @a << '<table>
304
+ #{'__erubi = ::Erubi;' if escape}@a = ::String.new; @a << '<table>
305
305
  <tbody>
306
- '; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( bar do @a << '
306
+ '; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( bar do @a << '
307
307
  '; @a << ' <b>'; @a << #{escape ? '__erubi' : '::Erubi'}.h(( '&' )); @a << '</b>
308
308
  '; @a << ' '; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
309
309
  '; @a << ' </tbody>
@@ -335,9 +335,9 @@ END3
335
335
  </tbody>
336
336
  </table>
337
337
  END1
338
- #{'__erubi = ::Erubi;' if escape}@a = String.new; @a << '<table>
338
+ #{'__erubi = ::Erubi;' if escape}@a = ::String.new; @a << '<table>
339
339
  <tbody>
340
- '; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( quux do |i| @a << '
340
+ '; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( quux do |i| @a << '
341
341
  '; @a << ' <b>'; @a << #{escape ? '__erubi' : '::Erubi'}.h(( "\#{i}&" )); @a << '</b>
342
342
  '; @a << ' '; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
343
343
  '; @a << ' </tbody>
@@ -374,11 +374,11 @@ END3
374
374
  </tbody>
375
375
  </table>
376
376
  END1
377
- #{'__erubi = ::Erubi;' if escape}@a = String.new; @a << '<table>
377
+ #{'__erubi = ::Erubi;' if escape}@a = ::String.new; @a << '<table>
378
378
  <tbody>
379
- '; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( bar do @a << '
379
+ '; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( bar do @a << '
380
380
  '; @a << ' <b>'; @a << #{escape ? '__erubi' : '::Erubi'}.h(( '&' )); @a << '</b>
381
- '; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( baz do @a << 'e'; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
381
+ '; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( baz do @a << 'e'; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
382
382
  '; @a << ' '; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
383
383
  '; @a << ' </tbody>
384
384
  </table>
@@ -414,7 +414,7 @@ END3
414
414
  </table>
415
415
  END1
416
416
  # frozen_string_literal: true
417
- @_out_buf = String.new; @_out_buf << '<table>
417
+ @_out_buf = ::String.new; @_out_buf << '<table>
418
418
  '; for item in @items
419
419
  @_out_buf << ' <tr>
420
420
  <td>'; @_out_buf << ( i+1 ).to_s; @_out_buf << '</td>
@@ -448,7 +448,7 @@ END3
448
448
  <%% end %>
449
449
  </table>
450
450
  END1
451
- _buf = String.new; _buf << '<table>
451
+ _buf = ::String.new; _buf << '<table>
452
452
  '; _buf << '<% for item in @items %>
453
453
  '; _buf << ' <tr>
454
454
  <td>';; _buf << '</td>
@@ -488,7 +488,7 @@ END3
488
488
  <% i %>
489
489
  </table>
490
490
  END1
491
- _buf = String.new; _buf << '<table>
491
+ _buf = ::String.new; _buf << '<table>
492
492
  '; _buf << ' '; for item in @items ; _buf << '
493
493
  '; _buf << ' <tr>
494
494
  <td>';
@@ -537,7 +537,7 @@ END3
537
537
  </table>
538
538
  <%== i+1 %>
539
539
  END1
540
- _buf = String.new; _buf << '<table>
540
+ _buf = ::String.new; _buf << '<table>
541
541
  <tbody>
542
542
  '; i = 0
543
543
  list.each_with_index do |item, i|
@@ -581,7 +581,7 @@ END3
581
581
  </tbody>
582
582
  </table>
583
583
  END1
584
- __erubi = ::Erubi;_buf = String.new; _buf << '<table>
584
+ __erubi = ::Erubi;_buf = ::String.new; _buf << '<table>
585
585
  <tbody>
586
586
  '; i = 0
587
587
  list.each_with_index do |item, i|
@@ -653,6 +653,12 @@ END3
653
653
  Erubi::Engine.new('', :outvar=>'foo').bufvar.must_equal 'foo'
654
654
  end
655
655
 
656
+ it "should work with BasicObject methods" do
657
+ c = Class.new(BasicObject)
658
+ c.class_eval("def a; #{Erubi::Engine.new('2').src} end")
659
+ c.new.a.must_equal '2'
660
+ end if defined?(BasicObject)
661
+
656
662
  it "should return frozen object" do
657
663
  Erubi::Engine.new('').frozen?.must_equal true
658
664
  end
@@ -687,7 +693,7 @@ END3
687
693
  Let's eat <%= item %>!
688
694
  <% nil %><%| end %>
689
695
  END1
690
- @a = String.new;begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << (( bar do |item| @a << '
696
+ @a = ::String.new;begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << (( bar do |item| @a << '
691
697
  '; @a << 'Let\\'s eat '; @a << ( item ).to_s; @a << '!
692
698
  '; nil ; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
693
699
  ';
@@ -703,7 +709,7 @@ END3
703
709
  Let's eat <%= item %>!
704
710
  <% nil %><%| end %>
705
711
  END1
706
- @a = String.new;begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << (( bar do |item| @a << '
712
+ @a = ::String.new;begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << (( bar do |item| @a << '
707
713
  '; @a << 'Let\\'s eat '; @a << ( item ).to_s; @a << '!
708
714
  '; nil ; @a; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
709
715
  ';
@@ -736,7 +742,7 @@ Let's eat the tacos!
736
742
 
737
743
  Delicious!
738
744
  END1
739
- _buf = String.new;begin; (__erubi_stack ||= []) << _buf; _buf = String.new; __erubi_stack.last << (( bar do _buf << '
745
+ _buf = ::String.new;begin; (__erubi_stack ||= []) << _buf; _buf = ::String.new; __erubi_stack.last << (( bar do _buf << '
740
746
  '; _buf << 'Let\\'s eat the tacos!
741
747
  '; _buf; end )).to_s; ensure; _buf = __erubi_stack.pop; end; _buf << '
742
748
  '; _buf << '
@@ -758,7 +764,7 @@ Let's eat burgers!
758
764
 
759
765
  Delicious!
760
766
  END1
761
- _buf = String.new;begin; (__erubi_stack ||= []) << _buf; _buf = String.new; __erubi_stack.last << (( bar(\"Don't eat the burgers!\") do _buf << '
767
+ _buf = ::String.new;begin; (__erubi_stack ||= []) << _buf; _buf = ::String.new; __erubi_stack.last << (( bar(\"Don't eat the burgers!\") do _buf << '
762
768
  '; _buf << 'Let\\'s eat burgers!
763
769
  '; _buf; end )).to_s; ensure; _buf = __erubi_stack.pop; end; _buf << '
764
770
  '; _buf << '
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erubi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-12-18 00:00:00.000000000 Z
12
+ date: 2019-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: minitest-global_expectations
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
28
42
  description: Erubi is a ERB template engine for ruby. It is a simplified fork of Erubis
29
43
  email: code@jeremyevans.net
30
44
  executables: []
@@ -67,8 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  requirements: []
70
- rubyforge_project:
71
- rubygems_version: 2.7.6
84
+ rubygems_version: 3.0.3
72
85
  signing_key:
73
86
  specification_version: 4
74
87
  summary: Small ERB Implementation