Hello community, here is the log from the commit of package rubygem-erubi for openSUSE:Factory checked in at 2019-03-04 09:19:51 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-erubi (Old) and /work/SRC/openSUSE:Factory/.rubygem-erubi.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-erubi" Mon Mar 4 09:19:51 2019 rev:4 rq:679519 version:1.8.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-erubi/rubygem-erubi.changes 2018-03-09 10:44:26.071349362 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-erubi.new.28833/rubygem-erubi.changes 2019-03-04 09:19:54.748605978 +0100 @@ -1,0 +2,10 @@ +Wed Dec 19 07:06:00 UTC 2018 - Stephan Kulow <[email protected]> + +- updated to version 1.8.0 + see installed CHANGELOG + + === 1.8.0 (2018-12-18) + + * Support :yield_returns_buffer option in capture_end for always returning the (potentially modified) buffer in <%|= tags (evanleck) (#15) + +------------------------------------------------------------------- Old: ---- erubi-1.7.1.gem New: ---- erubi-1.8.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-erubi.spec ++++++ --- /var/tmp/diff_new_pack.aOvjpX/_old 2019-03-04 09:19:55.792605790 +0100 +++ /var/tmp/diff_new_pack.aOvjpX/_new 2019-03-04 09:19:55.796605789 +0100 @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -24,7 +24,7 @@ # Name: rubygem-erubi -Version: 1.7.1 +Version: 1.8.0 Release: 0 %define mod_name erubi %define mod_full_name %{mod_name}-%{version} ++++++ erubi-1.7.1.gem -> erubi-1.8.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG new/CHANGELOG --- old/CHANGELOG 2018-03-05 23:12:53.000000000 +0100 +++ new/CHANGELOG 2018-12-18 23:43:37.000000000 +0100 @@ -1,3 +1,7 @@ +=== 1.8.0 (2018-12-18) + +* Support :yield_returns_buffer option in capture_end for always returning the (potentially modified) buffer in <%|= tags (evanleck) (#15) + === 1.7.1 (2018-03-05) * Make whitespace handling for <%# %> tags more compatible with Erubis (jeremyevans) (#14) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.rdoc new/README.rdoc --- old/README.rdoc 2018-03-05 23:12:53.000000000 +0100 +++ new/README.rdoc 2018-12-18 23:43:37.000000000 +0100 @@ -63,6 +63,38 @@ require 'erubi/capture_end' Tilt.new("filename.erb", :engine_class=>Erubi::CaptureEndEngine).render +When using the capture_end support, any methods (such as +form+ in the example +above) should return the (potentially modified) buffer. Since the buffer +variable is a local variable and not an instance variable by default, you'll +probably want to set the +:bufvar+ variable when using the capture_end +support to an instance variable, and have any methods used access that +instance variable. Example: + + def form + @_buf << "<form>" + yield + @_buf << "</form>" + @_buf + end + + puts eval(Erubi::CaptureEndEngine.new(<<-END, :bufvar=>:@_buf).src) + before + <%|= form do %> + inside + <%| end %> + after + END + + # Output: + # before + # <form> + # inside + # </form> + # after + +Alternatively, passing the option +:yield_returns_buffer => true+ will return the +buffer captured by the block instead of the last expression in the block. + = Reporting Bugs The bug tracker is located at https://github.com/jeremyevans/erubi/issues Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/erubi/capture_end.rb new/lib/erubi/capture_end.rb --- old/lib/erubi/capture_end.rb 2018-03-05 23:12:53.000000000 +0100 +++ new/lib/erubi/capture_end.rb 2018-12-18 23:43:37.000000000 +0100 @@ -10,10 +10,17 @@ # additional options: # :escape_capture :: Whether to make <%|= escape by default, and <%|== not escape by default, # defaults to the same value as :escape. + # :yield_returns_buffer :: Whether to have <%| tags insert the buffer as an expression, so that + # <%| end %> tags will have the buffer be the last expression inside + # the block, and therefore have the buffer be returned by the yield + # expression. Normally the buffer will be returned anyway, but there + # are cases where the last expression will not be the buffer, + # and therefore a different object will be returned. def initialize(input, properties={}) properties = Hash[properties] escape = properties.fetch(:escape){properties.fetch(:escape_html, false)} @escape_capture = properties.fetch(:escape_capture, escape) + @yield_returns_buffer = properties.fetch(:yield_returns_buffer, false) @bufval = properties[:bufval] ||= 'String.new' @bufstack = '__erubi_stack' properties[:regexp] ||= /<%(\|?={1,2}|-|\#|%|\|)?(.*?)([-=])?%>([ \t]*\r?\n)?/m @@ -34,7 +41,8 @@ when '|' rspace = nil if tailch && !tailch.empty? add_text(lspace) if lspace - src << code << ")).to_s; ensure; #{@bufvar} = #{@bufstack}.pop; end;" + result = @yield_returns_buffer ? " #{@bufvar}; " : "" + src << result << code << ")).to_s; ensure; #{@bufvar} = #{@bufstack}.pop; end;" add_text(rspace) if rspace else super diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/erubi.rb new/lib/erubi.rb --- old/lib/erubi.rb 2018-03-05 23:12:53.000000000 +0100 +++ new/lib/erubi.rb 2018-12-18 23:43:37.000000000 +0100 @@ -1,7 +1,7 @@ # frozen_string_literal: true module Erubi - VERSION = '1.7.1' + VERSION = '1.8.0' RANGE_ALL = 0..-1 if RUBY_VERSION >= '1.9' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2018-03-05 23:12:53.000000000 +0100 +++ new/metadata 2018-12-18 23:43:37.000000000 +0100 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: erubi version: !ruby/object:Gem::Version - version: 1.7.1 + version: 1.8.0 platform: ruby authors: - Jeremy Evans @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2018-03-05 00:00:00.000000000 Z +date: 2018-12-18 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: minitest @@ -68,7 +68,7 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.7.3 +rubygems_version: 2.7.6 signing_key: specification_version: 4 summary: Small ERB Implementation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/test.rb new/test/test.rb --- old/test/test.rb 2018-03-05 23:12:53.000000000 +0100 +++ new/test/test.rb 2018-12-18 23:43:37.000000000 +0100 @@ -23,6 +23,8 @@ require 'erubi' require 'erubi/capture_end' + +ENV['MT_NO_PLUGINS'] = '1' # Work around stupid autoloading of plugins require 'minitest/spec' require 'minitest/autorun' @@ -663,4 +665,110 @@ proc{Erubi::Engine.new('<%] %>', :regexp =>/<%(={1,2}|\]|-|\#|%)?(.*?)([-=])?%>([ \t]*\r?\n)?/m)}.must_raise ArgumentError proc{Erubi::CaptureEndEngine.new('<%] %>', :regexp =>/<%(={1,2}|\]|-|\#|%)?(.*?)([-=])?%>([ \t]*\r?\n)?/m)}.must_raise ArgumentError end + + it "should respect the :yield_returns_buffer option for making templates return the (potentially modified) buffer" do + @options[:engine] = ::Erubi::CaptureEndEngine + @options[:bufvar] = '@a' + + def self.bar + a = String.new + a << "a" + yield 'burgers' + case b = (yield 'salads') + when String + a << b + a << 'b' + a.upcase + end + end + + check_output(<<END1, <<END2, <<END3){} +<%|= bar do |item| %> +Let's eat <%= item %>! +<% nil %><%| end %> +END1 +@a = String.new;begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << (( bar do |item| @a << ' +'; @a << 'Let\\'s eat '; @a << ( item ).to_s; @a << '! +'; nil ; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << ' +'; [email protected]_s +END2 + +END3 + + @options[:yield_returns_buffer] = true + + check_output(<<END1, <<END2, <<END3) {} +<%|= bar do |item| %> +Let's eat <%= item %>! +<% nil %><%| end %> +END1 +@a = String.new;begin; (__erubi_stack ||= []) << @a; @a = String.new; __erubi_stack.last << (( bar do |item| @a << ' +'; @a << 'Let\\'s eat '; @a << ( item ).to_s; @a << '! +'; nil ; @a; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << ' +'; [email protected]_s +END2 +A +LET'S EAT BURGERS! + +LET'S EAT SALADS! +B +END3 + end + + it "should respect the :yield_returns_buffer option for making templates return the (potentially modified) buffer as the result of the block" do + @options[:engine] = ::Erubi::CaptureEndEngine + @options[:yield_returns_buffer] = true + + def self.bar(foo = nil) + if foo.nil? + yield + else + foo + end + end + + check_output(<<END1, <<END2, <<END3) {} +<%|= bar do %> +Let's eat the tacos! +<%| end %> + +Delicious! +END1 +_buf = String.new;begin; (__erubi_stack ||= []) << _buf; _buf = String.new; __erubi_stack.last << (( bar do _buf << ' +'; _buf << 'Let\\'s eat the tacos! +'; _buf; end )).to_s; ensure; _buf = __erubi_stack.pop; end; _buf << ' +'; _buf << ' +Delicious! +'; +_buf.to_s +END2 + +Let's eat the tacos! + + +Delicious! +END3 + + check_output(<<END1, <<END2, <<END3) {} +<%|= bar("Don't eat the burgers!") do %> +Let's eat burgers! +<%| end %> + +Delicious! +END1 +_buf = String.new;begin; (__erubi_stack ||= []) << _buf; _buf = String.new; __erubi_stack.last << (( bar(\"Don't eat the burgers!\") do _buf << ' +'; _buf << 'Let\\'s eat burgers! +'; _buf; end )).to_s; ensure; _buf = __erubi_stack.pop; end; _buf << ' +'; _buf << ' +Delicious! +'; +_buf.to_s +END2 +Don't eat the burgers! + +Delicious! +END3 + end end
