Hello community, here is the log from the commit of package rubygem-tilt for openSUSE:Factory checked in at 2016-05-29 03:12:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-tilt (Old) and /work/SRC/openSUSE:Factory/.rubygem-tilt.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-tilt" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-tilt/rubygem-tilt.changes 2016-03-01 09:40:09.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-tilt.new/rubygem-tilt.changes 2016-05-29 03:13:12.000000000 +0200 @@ -1,0 +2,24 @@ +Sat May 21 04:39:42 UTC 2016 - co...@suse.com + +- updated to version 2.0.4 + see installed CHANGELOG.md + + ## 2.0.4 (2016-05-16) + + * Fix regression in BuilderTemplate (#283, judofyr) + +------------------------------------------------------------------- +Fri May 13 04:51:41 UTC 2016 - co...@suse.com + +- updated to version 2.0.3 + see installed CHANGELOG.md + + ## 2.0.3 (2016-05-12) + + * Add Pandoc support (#276, jmuheim) + * Add CommonMark support (#282, raphink) + * Add TypeScript support (#278, nghitran) + * Work with frozen string literal (#274, jeremyevans) + * Add MIME type for Babel (#273, SaitoWu) + +------------------------------------------------------------------- Old: ---- tilt-2.0.2.gem New: ---- tilt-2.0.4.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-tilt.spec ++++++ --- /var/tmp/diff_new_pack.g12eRw/_old 2016-05-29 03:13:13.000000000 +0200 +++ /var/tmp/diff_new_pack.g12eRw/_new 2016-05-29 03:13:13.000000000 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-tilt -Version: 2.0.2 +Version: 2.0.4 Release: 0 %define mod_name tilt %define mod_full_name %{mod_name}-%{version} ++++++ tilt-2.0.2.gem -> tilt-2.0.4.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2016-01-05 13:57:20.000000000 +0100 +++ new/CHANGELOG.md 2016-05-16 10:25:06.000000000 +0200 @@ -1,3 +1,15 @@ +## 2.0.4 (2016-05-16) + +* Fix regression in BuilderTemplate (#283, judofyr) + +## 2.0.3 (2016-05-12) + +* Add Pandoc support (#276, jmuheim) +* Add CommonMark support (#282, raphink) +* Add TypeScript support (#278, nghitran) +* Work with frozen string literal (#274, jeremyevans) +* Add MIME type for Babel (#273, SaitoWu) + ## 2.0.2 (2016-01-06) * Pass options to Redcarpet (#250, hughbien) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Gemfile new/Gemfile --- old/Gemfile 2016-01-05 13:57:20.000000000 +0100 +++ new/Gemfile 2016-05-16 10:25:06.000000000 +0200 @@ -21,6 +21,7 @@ gem 'less' gem 'coffee-script' gem 'babel-transpiler' + gem 'typescript-node' end end @@ -36,6 +37,7 @@ gem 'asciidoctor', '>= 0.1.0' gem 'liquid' gem 'maruku' + gem 'pandoc-ruby' if RUBY_VERSION > '1.9.3' gem 'prawn', '>= 2.0.0' @@ -50,6 +52,7 @@ gem 'redcarpet' if RUBY_VERSION > '1.8.7' gem 'rdiscount', '>= 2.1.6' if RUBY_VERSION != '1.9.2' gem 'RedCloth' + gem 'commonmarker' if RUBY_VERSION > '1.9.3' end platform :mri do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2016-01-05 13:57:20.000000000 +0100 +++ new/README.md 2016-05-16 10:25:06.000000000 +0200 @@ -40,7 +40,9 @@ | Redcarpet | .markdown, .mkd, .md | redcarpet | Community | | BlueCloth | .markdown, .mkd, .md | bluecloth | Community | | Kramdown | .markdown, .mkd, .md | kramdown | Community | +| Pandoc | .markdown, .mkd, .md | pandoc | Community | | Maruku | .markdown, .mkd, .md | maruku | Community | +| CommonMarker | .markdown, .mkd, .md | commonmarker | Community | | RedCloth | .textile | redcloth | Community | | RDoc | .rdoc | rdoc | Tilt team | | Radius | .radius | radius | Community | Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/docs/TEMPLATES.md new/docs/TEMPLATES.md --- old/docs/TEMPLATES.md 2016-01-05 13:57:20.000000000 +0100 +++ new/docs/TEMPLATES.md 2016-05-16 10:25:06.000000000 +0200 @@ -44,6 +44,7 @@ * Redcarpet - `Tilt::RedcarpetTemplate` * BlueCloth - `Tilt::BlueClothTemplate` * Kramdown - `Tilt::KramdownTemplate` + * Pandoc - `Tilt::PandocTemplate` * Maruku - `Tilt::MarukuTemplate` <a name='erb'></a> @@ -432,6 +433,7 @@ * Redcarpet - `Tilt::RedcarpetTemplate` * BlueCloth - `Tilt::BlueClothTemplate` * Kramdown - `Tilt::KramdownTemplate` + * Pandoc - `Tilt::PandocTemplate` * Maruku - `Tilt::MarukuTemplate` Tilt will use fallback mode (as documented in the README) for determining which @@ -458,7 +460,7 @@ ### Options Every implementation of Markdown *should* support these options, but there are -some known problems with the Kramdown and Maruku engines. +some known problems with the Kramdown and Maruku engines. #### `:smartypants => true|false` @@ -474,7 +476,7 @@ Set `true` disallow raw HTML in Markdown contents. HTML is converted to literal text by escaping `<` characters. -Kramdown and Maruku doesn't support this option. +Kramdown and Maruku don't support this option. ### See also @@ -521,4 +523,3 @@ [rdiscount]: http://github.com/rtomayko/rdiscount/ "RDiscount" [smartypants]: http://daringfireball.net/projects/smartypants/ "Smarty Pants" [markdown]: http://en.wikipedia.org/wiki/Markdown "Markdown" - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/babel.rb new/lib/tilt/babel.rb --- old/lib/tilt/babel.rb 2016-01-05 13:57:20.000000000 +0100 +++ new/lib/tilt/babel.rb 2016-05-16 10:25:06.000000000 +0200 @@ -3,6 +3,8 @@ module Tilt class BabelTemplate < Template + self.default_mime_type = 'application/javascript' + def prepare options[:filename] ||= file end @@ -12,4 +14,3 @@ end end end - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/builder.rb new/lib/tilt/builder.rb --- old/lib/tilt/builder.rb 2016-01-05 13:57:20.000000000 +0100 +++ new/lib/tilt/builder.rb 2016-05-16 10:25:06.000000000 +0200 @@ -7,20 +7,24 @@ class BuilderTemplate < Template self.default_mime_type = 'text/xml' - def prepare; end + def prepare + options[:indent] ||= 2 + end def evaluate(scope, locals, &block) - return super(scope, locals, &block) if data.respond_to?(:to_str) - xml = ::Builder::XmlMarkup.new(:indent => 2) + xml = (locals[:xml] || ::Builder::XmlMarkup.new(options)) + + if data.respond_to?(:to_str) + if !locals[:xml] + locals = locals.merge(:xml => xml) + end + return super(scope, locals, &block) + end + data.call(xml) xml.target! end - def precompiled_preamble(locals) - return super if locals.include? :xml - "xml = ::Builder::XmlMarkup.new(:indent => 2)\n#{super}" - end - def precompiled_postamble(locals) "xml.target!" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/commonmarker.rb new/lib/tilt/commonmarker.rb --- old/lib/tilt/commonmarker.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/tilt/commonmarker.rb 2016-05-16 10:25:06.000000000 +0200 @@ -0,0 +1,21 @@ +require 'tilt/template' +require 'commonmarker' + +module Tilt + class CommonMarkerTemplate < Template + self.default_mime_type = 'text/html' + + def prepare + @engine = nil + @output = nil + end + + def evaluate(scope, locals, &block) + CommonMarker.render_html(data, :default) + end + + def allows_script? + false + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/dummy.rb new/lib/tilt/dummy.rb --- old/lib/tilt/dummy.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/tilt/dummy.rb 2016-05-16 10:25:06.000000000 +0200 @@ -0,0 +1,3 @@ +# Used for detecting autoloading bug in JRuby +class Tilt::Dummy; end + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/erubis.rb new/lib/tilt/erubis.rb --- old/lib/tilt/erubis.rb 2016-01-05 13:57:20.000000000 +0100 +++ new/lib/tilt/erubis.rb 2016-05-16 10:25:06.000000000 +0200 @@ -24,7 +24,7 @@ end def precompiled_preamble(locals) - [super, "#{@outvar} = _buf = ''"].join("\n") + [super, "#{@outvar} = _buf = String.new"].join("\n") end def precompiled_postamble(locals) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/mapping.rb new/lib/tilt/mapping.rb --- old/lib/tilt/mapping.rb 2016-01-05 13:57:20.000000000 +0100 +++ new/lib/tilt/mapping.rb 2016-05-16 10:25:06.000000000 +0200 @@ -60,7 +60,7 @@ @lazy_map = other.lazy_map.dup end - # Registrers a lazy template implementation by file extension. You + # Registers a lazy template implementation by file extension. You # can have multiple lazy template implementations defined on the # same file extension, in which case the template implementation # defined *last* will be attempted loaded *first*. @@ -254,10 +254,35 @@ raise first_failure if first_failure end + # This is due to a bug in JRuby (see GH issue jruby/jruby#3585) + Tilt.autoload :Dummy, "tilt/dummy" + require "tilt/dummy" + AUTOLOAD_IS_BROKEN = Tilt.autoload?(:Dummy) + + # The proper behavior (in MRI) for autoload? is to + # return `false` when the constant/file has been + # explicitly required. + # + # However, in JRuby it returns `true` even after it's + # been required. In that case it turns out that `defined?` + # returns `"constant"` if it exists and `nil` when it doesn't. + # This is actually a second bug: `defined?` should resolve + # autoload (aka. actually try to require the file). + # + # We use the second bug in order to resolve the first bug. + def constant_defined?(name) name.split('::').inject(Object) do |scope, n| - return false if scope.autoload?(n) # skip autload - return false unless scope.const_defined?(n) + if scope.autoload?(n) + if !AUTOLOAD_IS_BROKEN + return false + end + + if eval("!defined?(scope::#{n})") + return false + end + end + return false if !scope.const_defined?(n) scope.const_get(n) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/pandoc.rb new/lib/tilt/pandoc.rb --- old/lib/tilt/pandoc.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/tilt/pandoc.rb 2016-05-16 10:25:06.000000000 +0200 @@ -0,0 +1,53 @@ +require 'tilt/template' +require 'pandoc-ruby' + +module Tilt + # Pandoc markdown implementation. See: + # http://pandoc.org/ + class PandocTemplate < Template + def prepare + @output = PandocRuby.convert(data, options_hash, *options_array).strip + end + + def tilt_to_pandoc_mapping + { :smartypants => [:smart, true], + :escape_html => [:f, 'markdown-raw_html'] + } + end + + def pandoc_optimised_options + options.inject({}) do |hash, option| + if tilt_to_pandoc_mapping.has_key?(option[0]) && option[1] === true + hash[tilt_to_pandoc_mapping[option[0]][0]] = tilt_to_pandoc_mapping[option[0]][1] + else + hash[option[0]] = option[1] + end + + hash + end.merge({:to => :html}) + end + + def options_array + pandoc_optimised_options.map do |option| + option[0] if option[1] === true + end.compact + end + + def options_hash + pandoc_optimised_options.inject({}) do |hash, option| + # next if option[1] === true + # next if option[1] === false + hash[option[0]] = option[1] unless option[1] === true or option[1] === false + hash + end + end + + def evaluate(scope, locals, &block) + @output + end + + def allows_script? + false + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/string.rb new/lib/tilt/string.rb --- old/lib/tilt/string.rb 2016-01-05 13:57:20.000000000 +0100 +++ new/lib/tilt/string.rb 2016-05-16 10:25:06.000000000 +0200 @@ -6,7 +6,7 @@ class StringTemplate < Template def prepare hash = "TILT#{data.hash.abs}" - @code = "<<#{hash}.chomp\n#{data}\n#{hash}" + @code = String.new("<<#{hash}.chomp\n#{data}\n#{hash}") end def precompiled_template(locals) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/template.rb new/lib/tilt/template.rb --- old/lib/tilt/template.rb 2016-01-05 13:57:20.000000000 +0100 +++ new/lib/tilt/template.rb 2016-05-16 10:25:06.000000000 +0200 @@ -79,7 +79,10 @@ @data = @reader.call(self) if @data.respond_to?(:force_encoding) - @data.force_encoding(default_encoding) if default_encoding + if default_encoding + @data = @data.dup if @data.frozen? + @data.force_encoding(default_encoding) + end if !@data.valid_encoding? raise Encoding::InvalidByteSequenceError, "#{eval_file} is not valid #{@data.encoding}" @@ -177,7 +180,7 @@ preamble = precompiled_preamble(local_keys) template = precompiled_template(local_keys) postamble = precompiled_postamble(local_keys) - source = '' + source = String.new # Ensure that our generated source code has the same encoding as the # the source code generated by the template engine. @@ -246,7 +249,7 @@ local_code = local_extraction(local_keys) method_name = "__tilt_#{Thread.current.object_id.abs}" - method_source = "" + method_source = String.new if method_source.respond_to?(:force_encoding) method_source.force_encoding(source.encoding) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/typescript.rb new/lib/tilt/typescript.rb --- old/lib/tilt/typescript.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/tilt/typescript.rb 2016-05-16 10:25:06.000000000 +0200 @@ -0,0 +1,26 @@ +require 'tilt/template' +require 'typescript-node' + +module Tilt + class TypeScriptTemplate < Template + self.default_mime_type = 'application/javascript' + + def prepare + @option_args = [] + + options.each do |key, value| + next unless value + + @option_args << "--#{key}" + + if value != true + @option_args << value.to_s + end + end + end + + def evaluate(scope, locals, &block) + @output ||= TypeScript::Node.compile(data, *@option_args) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt.rb new/lib/tilt.rb --- old/lib/tilt.rb 2016-01-05 13:57:20.000000000 +0100 +++ new/lib/tilt.rb 2016-05-16 10:25:06.000000000 +0200 @@ -4,7 +4,7 @@ # Namespace for Tilt. This module is not intended to be included anywhere. module Tilt # Current version. - VERSION = '2.0.2' + VERSION = '2.0.4' @default_mapping = Mapping.new @@ -119,11 +119,13 @@ register_lazy :ErubisTemplate, 'tilt/erubis', 'erb', 'rhtml', 'erubis' # Markdown - register_lazy :BlueClothTemplate, 'tilt/bluecloth', 'markdown', 'mkd', 'md' - register_lazy :MarukuTemplate, 'tilt/maruku', 'markdown', 'mkd', 'md' - register_lazy :KramdownTemplate, 'tilt/kramdown', 'markdown', 'mkd', 'md' - register_lazy :RDiscountTemplate, 'tilt/rdiscount', 'markdown', 'mkd', 'md' - register_lazy :RedcarpetTemplate, 'tilt/redcarpet', 'markdown', 'mkd', 'md' + register_lazy :BlueClothTemplate, 'tilt/bluecloth', 'markdown', 'mkd', 'md' + register_lazy :MarukuTemplate, 'tilt/maruku', 'markdown', 'mkd', 'md' + register_lazy :KramdownTemplate, 'tilt/kramdown', 'markdown', 'mkd', 'md' + register_lazy :RDiscountTemplate, 'tilt/rdiscount', 'markdown', 'mkd', 'md' + register_lazy :RedcarpetTemplate, 'tilt/redcarpet', 'markdown', 'mkd', 'md' + register_lazy :CommonMarkerTemplate, 'tilt/commonmarker', 'markdown', 'mkd', 'md' + register_lazy :PandocTemplate, 'tilt/pandoc', 'markdown', 'mkd', 'md' # Rest (sorted by name) register_lazy :AsciidoctorTemplate, 'tilt/asciidoc', 'ad', 'adoc', 'asciidoc' @@ -147,6 +149,7 @@ register_lazy :SassTemplate, 'tilt/sass', 'sass' register_lazy :ScssTemplate, 'tilt/sass', 'scss' register_lazy :StringTemplate, 'tilt/string', 'str' + register_lazy :TypeScriptTemplate, 'tilt/typescript', 'ts' register_lazy :WikiClothTemplate, 'tilt/wikicloth', 'wiki', 'mediawiki', 'mw' register_lazy :YajlTemplate, 'tilt/yajl', 'yajl' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-01-05 13:57:20.000000000 +0100 +++ new/metadata 2016-05-16 10:25:06.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: tilt version: !ruby/object:Gem::Version - version: 2.0.2 + version: 2.0.4 platform: ruby authors: - Ryan Tomayko autorequire: bindir: bin cert_chain: [] -date: 2016-01-05 00:00:00.000000000 Z +date: 2016-05-16 00:00:00.000000000 Z dependencies: [] description: Generic interface to multiple Ruby template engines email: r...@tomayko.com @@ -32,8 +32,10 @@ - lib/tilt/bluecloth.rb - lib/tilt/builder.rb - lib/tilt/coffee.rb +- lib/tilt/commonmarker.rb - lib/tilt/creole.rb - lib/tilt/csv.rb +- lib/tilt/dummy.rb - lib/tilt/erb.rb - lib/tilt/erubis.rb - lib/tilt/etanni.rb @@ -45,6 +47,7 @@ - lib/tilt/markaby.rb - lib/tilt/maruku.rb - lib/tilt/nokogiri.rb +- lib/tilt/pandoc.rb - lib/tilt/plain.rb - lib/tilt/prawn.rb - lib/tilt/radius.rb @@ -55,6 +58,7 @@ - lib/tilt/sass.rb - lib/tilt/string.rb - lib/tilt/template.rb +- lib/tilt/typescript.rb - lib/tilt/wikicloth.rb - lib/tilt/yajl.rb - man/index.txt @@ -65,6 +69,7 @@ - test/markaby/render_twice.mab - test/markaby/scope.mab - test/markaby/yielding.mab +- test/mytemplate.rb - test/test_helper.rb - test/tilt_asciidoctor_test.rb - test/tilt_babeltemplate.rb @@ -72,6 +77,7 @@ - test/tilt_buildertemplate_test.rb - test/tilt_cache_test.rb - test/tilt_coffeescripttemplate_test.rb +- test/tilt_commonmarkertemplate_test.rb - test/tilt_compilesite_test.rb - test/tilt_creoletemplate_test.rb - test/tilt_csv_test.rb @@ -89,6 +95,7 @@ - test/tilt_marukutemplate_test.rb - test/tilt_metadata_test.rb - test/tilt_nokogiritemplate_test.rb +- test/tilt_pandoctemplate_test.rb - test/tilt_prawntemplate.prawn - test/tilt_prawntemplate_test.rb - test/tilt_radiustemplate_test.rb @@ -100,6 +107,7 @@ - test/tilt_stringtemplate_test.rb - test/tilt_template_test.rb - test/tilt_test.rb +- test/tilt_typescript_test.rb - test/tilt_wikiclothtemplate_test.rb - test/tilt_yajltemplate_test.rb - tilt.gemspec @@ -139,6 +147,7 @@ - test/tilt_buildertemplate_test.rb - test/tilt_cache_test.rb - test/tilt_coffeescripttemplate_test.rb +- test/tilt_commonmarkertemplate_test.rb - test/tilt_compilesite_test.rb - test/tilt_creoletemplate_test.rb - test/tilt_csv_test.rb @@ -155,6 +164,7 @@ - test/tilt_marukutemplate_test.rb - test/tilt_metadata_test.rb - test/tilt_nokogiritemplate_test.rb +- test/tilt_pandoctemplate_test.rb - test/tilt_prawntemplate_test.rb - test/tilt_radiustemplate_test.rb - test/tilt_rdiscounttemplate_test.rb @@ -165,6 +175,7 @@ - test/tilt_stringtemplate_test.rb - test/tilt_template_test.rb - test/tilt_test.rb +- test/tilt_typescript_test.rb - test/tilt_wikiclothtemplate_test.rb - test/tilt_yajltemplate_test.rb has_rdoc: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/mytemplate.rb new/test/mytemplate.rb --- old/test/mytemplate.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/mytemplate.rb 2016-05-16 10:25:06.000000000 +0200 @@ -0,0 +1,2 @@ +class MyTemplate +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_buildertemplate_test.rb new/test/tilt_buildertemplate_test.rb --- old/test/tilt_buildertemplate_test.rb 2016-01-05 13:57:20.000000000 +0100 +++ new/test/tilt_buildertemplate_test.rb 2016-05-16 10:25:06.000000000 +0200 @@ -44,6 +44,19 @@ assert_equal "<em>Hey Joe!</em>\n", template.render end + test "options can be overridden" do + template = Tilt::BuilderTemplate.new(:indent => 0) { "xml.div { xml.em('Hey') }" } + assert_equal "<div><em>Hey</em></div>", template.render + end + + test "can re-use locals for multiple calls" do + locals = { :name => "world" } + template = Tilt::BuilderTemplate.new(:indent => 0) { "xml.em name" } + 3.times do + assert_equal "<em>world</em>", template.render(self, locals) + end + end + test "allows nesting raw XML" do subtemplate = Tilt::BuilderTemplate.new { "xml.em 'Hello World!'" } template = Tilt::BuilderTemplate.new { "xml.strong { xml << yield }" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_commonmarkertemplate_test.rb new/test/tilt_commonmarkertemplate_test.rb --- old/test/tilt_commonmarkertemplate_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/tilt_commonmarkertemplate_test.rb 2016-05-16 10:25:06.000000000 +0200 @@ -0,0 +1,20 @@ +require 'test_helper' +require 'tilt' + +begin + require 'tilt/commonmarker' + + class CommonMarkerTemplateTest < Minitest::Test + test "preparing and evaluating templates on #render" do + template = Tilt::CommonMarkerTemplate.new { |t| "# Hello World!" } + assert_equal "<h1>Hello World!</h1>\n", template.render + end + + test "can be rendered more than once" do + template = Tilt::CommonMarkerTemplate.new { |t| "# Hello World!" } + 3.times { assert_equal "<h1>Hello World!</h1>\n", template.render } + end + end +rescue LoadError => boom + warn "Tilt::CommonMarkerTemplate (disabled)" +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_mapping_test.rb new/test/tilt_mapping_test.rb --- old/test/tilt_mapping_test.rb 2016-01-05 13:57:20.000000000 +0100 +++ new/test/tilt_mapping_test.rb 2016-05-16 10:25:06.000000000 +0200 @@ -57,10 +57,12 @@ context "lazy with one template class" do setup do @mapping.register_lazy('MyTemplate', 'my_template', 'mt') + @loaded_before = $LOADED_FEATURES.dup end teardown do Object.send :remove_const, :MyTemplate if defined? ::MyTemplate + $LOADED_FEATURES.replace(@loaded_before) end test "registered?" do @@ -89,6 +91,21 @@ req = proc do |file| flunk "#require shouldn't be called" + end + + @mapping.stub :require, req do + klass = @mapping['hello.mt'] + assert_equal ::MyTemplate, klass + end + end + + test "doesn't require when the template class is autoloaded, and then defined" do + Object.autoload :MyTemplate, 'mytemplate' + did_load = require 'mytemplate' + assert did_load, "mytemplate wasn't freshly required" + + req = proc do |file| + flunk "#require shouldn't be called" end @mapping.stub :require, req do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_markdown_test.rb new/test/tilt_markdown_test.rb --- old/test/tilt_markdown_test.rb 2016-01-05 13:57:20.000000000 +0100 +++ new/test/tilt_markdown_test.rb 2016-05-16 10:25:06.000000000 +0200 @@ -174,4 +174,16 @@ warn "Markdown tests need Nokogiri" end +begin + require 'tilt/pandoc' + class MarkdownPandocTest < Minitest::Test + include MarkdownTests + template Tilt::PandocTemplate + + # Doesn't support escaping + undef test_escape_html_true + end +rescue LoadError => boom + # It should already be warned in the main tests +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_pandoctemplate_test.rb new/test/tilt_pandoctemplate_test.rb --- old/test/tilt_pandoctemplate_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/tilt_pandoctemplate_test.rb 2016-05-16 10:25:06.000000000 +0200 @@ -0,0 +1,56 @@ +# encoding: utf-8 + +require 'test_helper' +require 'tilt' + +begin + require 'tilt/pandoc' + + class PandocTemplateTest < Minitest::Test + test "preparing and evaluating templates on #render" do + template = Tilt::PandocTemplate.new { |t| "# Hello World!" } + assert_equal "<h1 id=\"hello-world\">Hello World!</h1>", template.render.strip + end + + test "can be rendered more than once" do + template = Tilt::PandocTemplate.new { |t| "# Hello World!" } + 3.times { assert_equal "<h1 id=\"hello-world\">Hello World!</h1>", template.render.strip } + end + + test "smartypants when :smartypants is set" do + template = Tilt::PandocTemplate.new(:smartypants => true) { |t| "OKAY -- 'Smarty Pants'" } + assert_equal "<p>OKAY – ‘Smarty Pants’</p>", template.render + end + + test "stripping HTML when :escape_html is set" do + template = Tilt::PandocTemplate.new(:escape_html => true) { |t| "HELLO <blink>WORLD</blink>" } + assert_equal "<p>HELLO <blink>WORLD</blink></p>", template.render + end + + # Pandoc has tons of additional markdown features (see http://pandoc.org/README.html#pandocs-markdown). + # The test for footnotes should be seen as a general representation for all of them. + test "generates footnotes" do + template = Tilt::PandocTemplate.new { |t| "Here is an inline note.^[Inlines notes are cool!]" } + assert_equal "<p>Here is an inline note.<a href=\"#fn1\" class=\"footnoteRef\" id=\"fnref1\"><sup>1</sup></a></p>\n<div class=\"footnotes\">\n<hr />\n<ol>\n<li id=\"fn1\"><p>Inlines notes are cool!<a href=\"#fnref1\">↩</a></p></li>\n</ol>\n</div>", template.render.strip + end + + describe "passing in Pandoc options" do + test "accepts arguments with values (e.g. :id_prefix => 'xyz')" do + # Table of contents isn't on by default + template = Tilt::PandocTemplate.new { |t| "# This is a heading" } + assert_equal "<h1 id=\"this-is-a-heading\">This is a heading</h1>", template.render + + # But it can be activated + template = Tilt::PandocTemplate.new(:id_prefix => 'test-') { |t| "# This is a heading" } + assert_equal "<h1 id=\"test-this-is-a-heading\">This is a heading</h1>", template.render + end + + test "requires arguments without value (e.g. --standalone) to be passed as hash keys (:standalone => true)" do + template = Tilt::PandocTemplate.new(:standalone => true) { |t| "# This is a heading" } + assert_match /^<!DOCTYPE html.*<h1 id="this-is-a-heading">This is a heading<\/h1>.*<\/html>$/m, template.render + end + end + end +rescue LoadError => boom + warn "Tilt::PandocTemplate (disabled)" +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_typescript_test.rb new/test/tilt_typescript_test.rb --- old/test/tilt_typescript_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/tilt_typescript_test.rb 2016-05-16 10:25:06.000000000 +0200 @@ -0,0 +1,34 @@ +require 'test_helper' +require 'tilt' + +begin + require 'tilt/typescript' + + class TypeScriptTemplateTest < Minitest::Test + def setup + @ts = "var x:number = 5" + @js = /var x = 5;\s*/ + end + + test "is registered for '.ts' files" do + assert_equal Tilt::TypeScriptTemplate, Tilt['test.ts'] + end + + test "compiles and evaluates the template on #render" do + template = Tilt::TypeScriptTemplate.new { @ts } + assert_match @js, template.render + end + + test "supports source map" do + template = Tilt::TypeScriptTemplate.new(inlineSourceMap: true) { @ts } + assert_match /sourceMappingURL/, template.render + end + + test "can be rendered more than once" do + template = Tilt::TypeScriptTemplate.new { @ts } + 3.times { assert_match @js, template.render } + end + end +rescue LoadError => boom + warn "Tilt::TypeScriptTemplate (disabled)" +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tilt.gemspec new/tilt.gemspec --- old/tilt.gemspec 2016-01-05 13:57:20.000000000 +0100 +++ new/tilt.gemspec 2016-05-16 10:25:06.000000000 +0200 @@ -3,8 +3,8 @@ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.name = 'tilt' - s.version = '2.0.2' - s.date = '2016-01-05' + s.version = '2.0.4' + s.date = '2016-05-16' s.description = "Generic interface to multiple Ruby template engines" s.summary = s.description @@ -30,8 +30,10 @@ lib/tilt/bluecloth.rb lib/tilt/builder.rb lib/tilt/coffee.rb + lib/tilt/commonmarker.rb lib/tilt/creole.rb lib/tilt/csv.rb + lib/tilt/dummy.rb lib/tilt/erb.rb lib/tilt/erubis.rb lib/tilt/etanni.rb @@ -43,6 +45,7 @@ lib/tilt/markaby.rb lib/tilt/maruku.rb lib/tilt/nokogiri.rb + lib/tilt/pandoc.rb lib/tilt/plain.rb lib/tilt/prawn.rb lib/tilt/radius.rb @@ -53,6 +56,7 @@ lib/tilt/sass.rb lib/tilt/string.rb lib/tilt/template.rb + lib/tilt/typescript.rb lib/tilt/wikicloth.rb lib/tilt/yajl.rb man/index.txt @@ -63,6 +67,7 @@ test/markaby/render_twice.mab test/markaby/scope.mab test/markaby/yielding.mab + test/mytemplate.rb test/test_helper.rb test/tilt_asciidoctor_test.rb test/tilt_babeltemplate.rb @@ -70,6 +75,7 @@ test/tilt_buildertemplate_test.rb test/tilt_cache_test.rb test/tilt_coffeescripttemplate_test.rb + test/tilt_commonmarkertemplate_test.rb test/tilt_compilesite_test.rb test/tilt_creoletemplate_test.rb test/tilt_csv_test.rb @@ -87,6 +93,7 @@ test/tilt_marukutemplate_test.rb test/tilt_metadata_test.rb test/tilt_nokogiritemplate_test.rb + test/tilt_pandoctemplate_test.rb test/tilt_prawntemplate.prawn test/tilt_prawntemplate_test.rb test/tilt_radiustemplate_test.rb @@ -98,6 +105,7 @@ test/tilt_stringtemplate_test.rb test/tilt_template_test.rb test/tilt_test.rb + test/tilt_typescript_test.rb test/tilt_wikiclothtemplate_test.rb test/tilt_yajltemplate_test.rb tilt.gemspec