Hello community, here is the log from the commit of package rubygem-tilt for openSUSE:Factory checked in at 2016-03-01 09:40:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 2014-12-03 22:53:20.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-tilt.new/rubygem-tilt.changes 2016-03-01 09:40:09.000000000 +0100 @@ -1,0 +2,6 @@ +Thu Jan 21 05:50:04 UTC 2016 - [email protected] + +- updated to version 2.0.2 + see installed CHANGELOG.md + +------------------------------------------------------------------- Old: ---- tilt-2.0.1.gem New: ---- gem2rpm.yml tilt-2.0.2.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-tilt.spec ++++++ --- /var/tmp/diff_new_pack.Zz2KTb/_old 2016-03-01 09:40:12.000000000 +0100 +++ /var/tmp/diff_new_pack.Zz2KTb/_new 2016-03-01 09:40:12.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package rubygem-tilt # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,27 +16,34 @@ # +# +# This file was generated with a gem2rpm.yml and not just plain gem2rpm. +# All sections marked as MANUAL, license headers, summaries and descriptions +# can be maintained in that file. Please consult this file before editing any +# of those fields +# + Name: rubygem-tilt -Version: 2.0.1 +Version: 2.0.2 Release: 0 %define mod_name tilt %define mod_full_name %{mod_name}-%{version} -%define mod_branch -%{version} -%define mod_weight 20001 - BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: %{rubygem gem2rpm} +BuildRequires: %{rubygem rdoc > 3.10} +BuildRequires: %{ruby} BuildRequires: ruby-macros >= 5 BuildRequires: update-alternatives -BuildRequires: rubygem(rdoc) > 3.10 Url: http://github.com/rtomayko/tilt/ Source: http://rubygems.org/gems/%{mod_full_name}.gem +Source1: gem2rpm.yml Summary: Generic interface to multiple Ruby template engines License: MIT Group: Development/Languages/Ruby PreReq: update-alternatives %description -Generic interface to multiple Ruby template engines +Generic interface to multiple Ruby template engines. %prep ++++++ gem2rpm.yml ++++++ # --- # ## used by gem2rpm # :summary: this is a custom summary # ## used by gem2rpm # :description: |- # this is a custom description # # it can be multiline # ## used by gem2rpm # :license: MIT or Ruby # ## used by gem2rpm and gem_packages # :version_suffix: -x_y # ## used by gem2rpm and gem_packages # :disable_docs: true # ## used by gem2rpm # :disable_automatic_rdoc_dep: true # ## used by gem2rpm # :preamble: |- # BuildRequires: foobar # Requires: foobar # ## used by gem2rpm # :patches: # foo.patch: -p1 # bar.patch: # ## used by gem2rpm :sources: # - foo.desktop # - bar.desktop # :gem_install_args: '....' # ## used by gem2rpm # :pre_install: |- # %if 0%{?use_system_libev} # export USE_VENDORED_LIBEV="no" # %endif # ## used by gem2rpm # :post_install: |- # # delete custom files here or do other fancy stuff # install -D -m 0644 %{S:1} %{buildroot}%{_bindir}/gem2rpm-opensuse # ## used by gem2rpm # :testsuite_command: |- # (pushd %{buildroot}%{gem_base}/gems/%{mod_full_name} && rake test) # ## used by gem2rpm # :filelist: |- # /usr/bin/gem2rpm-opensuse # ## used by gem2rpm # :scripts: # :post: |- # /bin/echo foo # ## used by gem_packages # :main: # :preamble: |- # Requires: util-linux # Recommends: pwgen # :filelist: |- # /usr/bin/gem2rpm-opensuse # ## used by gem_packages # :custom: # apache: # :preamble: |- # Requires: ..... # :filelist: |- # /etc/apache2/conf.d/passenger.conf # :summary: Custom summary is optional # :description: |- # Custom description is optional # # bar # :post: |- # /bin/echo foo # ++++++ tilt-2.0.1.gem -> tilt-2.0.2.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2014-03-21 09:49:40.000000000 +0100 +++ new/CHANGELOG.md 2016-01-05 13:57:20.000000000 +0100 @@ -1,4 +1,16 @@ -## master +## 2.0.2 (2016-01-06) + +* Pass options to Redcarpet (#250, hughbien) +* Haml: Improve error message on frozen self (judofyr) +* Add basic support for Babel (judofyr) +* Add support for .litcoffee (#243, judofyr, mr-vinn) +* Document Tilt::Cache (#266, tommay) +* Sort local keys for better caching (#257, jeremyevans) +* Add more CSV options (#256, Juanmcuello) +* Add Prawn template (kematzy) +* Improve cache-miss performance in Tilt::Cache (#251, tommay) +* Add man page (#241, josephholsten) +* Support YAML/JSON data in bin/tilt (#241, josephholsten) ## 2.0.1 (2014-03-21) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Gemfile new/Gemfile --- old/Gemfile 2014-03-21 09:49:40.000000000 +0100 +++ new/Gemfile 2016-01-05 13:57:20.000000000 +0100 @@ -1,27 +1,48 @@ source 'https://rubygems.org' -gem 'yard', '~> 0.8.6' +gem 'rake' gem 'minitest', '~> 5.0' -gem 'rake' +group :development do + gem 'yard', '~> 0.8.6' + gem 'ronn', '~> 0.7.3' +end -group :engines do - gem 'asciidoctor', '>= 0.1.0' +can_execjs = (RUBY_VERSION >= '1.9.3') + +group :primary do gem 'builder' - gem 'coffee-script' - gem 'contest' - gem 'creole' - gem 'erubis' gem 'haml', '>= 2.2.11', '< 4' + gem 'erubis' + gem 'markaby' + gem 'sass' + + if can_execjs + gem 'less' + gem 'coffee-script' + gem 'babel-transpiler' + end +end + +platform :mri do + gem 'duktape', '~> 1.2.1.0' if can_execjs +end + +group :secondary do + gem 'creole' gem 'kramdown' - gem 'less' + gem 'rdoc' + gem 'radius' + gem 'asciidoctor', '>= 0.1.0' gem 'liquid' - gem 'markaby' gem 'maruku' + + if RUBY_VERSION > '1.9.3' + gem 'prawn', '>= 2.0.0' + gem 'pdf-reader', '~> 1.3.3' + end + gem 'nokogiri' if RUBY_VERSION > '1.9.2' - gem 'radius' - gem 'sass' - gem 'rdoc', (ENV['RDOC_VERSION'] || '> 0') platform :ruby do gem 'wikicloth' @@ -32,8 +53,7 @@ end platform :mri do - gem 'therubyracer' - gem 'bluecloth' if ENV['BLUECLOTH'] + gem 'bluecloth' end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2014-03-21 09:49:40.000000000 +0100 +++ new/README.md 2016-01-05 13:57:20.000000000 +0100 @@ -1,4 +1,4 @@ -Tilt [](http://travis-ci.org/rtomayko/tilt) [](https://gemnasium.com/rtomayko/tilt) +Tilt [](http://travis-ci.org/rtomayko/tilt) [](https://gemnasium.com/rtomayko/tilt) [](http://inch-ci.org/github/rtomayko/tilt) ==== **NOTE** The following file documents the current release of Tilt (2.0). See @@ -24,44 +24,64 @@ Support for these template engines is included with the package: - ENGINE FILE EXTENSIONS REQUIRED LIBRARIES - -------------------------- ----------------------- ---------------------------- - Asciidoctor .ad, .adoc, .asciidoc asciidoctor (>= 0.1.0) - ERB .erb, .rhtml none (included ruby stdlib) - Interpolated String .str none (included ruby core) - Erubis .erb, .rhtml, .erubis erubis - Haml .haml haml - Sass .sass haml (< 3.1) or sass (>= 3.1) - Scss .scss haml (< 3.1) or sass (>= 3.1) - Less CSS .less less - Builder .builder builder - Liquid .liquid liquid - RDiscount .markdown, .mkd, .md rdiscount - Redcarpet .markdown, .mkd, .md redcarpet - BlueCloth .markdown, .mkd, .md bluecloth - Kramdown .markdown, .mkd, .md kramdown - Maruku .markdown, .mkd, .md maruku - RedCloth .textile redcloth - RDoc .rdoc rdoc - Radius .radius radius - Markaby .mab markaby - Nokogiri .nokogiri nokogiri - CoffeeScript .coffee coffee-script (+ javascript) - Creole (Wiki markup) .wiki, .creole creole - WikiCloth (Wiki markup) .wiki, .mediawiki, .mw wikicloth - Yajl .yajl yajl-ruby - CSV .rcsv none (Ruby >= 1.9), fastercsv (Ruby < 1.9) +| Engine | File Extensions | Required Libraries | Maintainer | +| ----------------------- | ---------------------- | ------------------------------------------ | ----------- | +| Asciidoctor | .ad, .adoc, .asciidoc | asciidoctor (>= 0.1.0) | Community | +| ERB | .erb, .rhtml | none (included ruby stdlib) | Tilt team | +| InterpolatedString | .str | none (included ruby core) | Tilt team | +| Erubis | .erb, .rhtml, .erubis | erubis | Tilt team | +| Haml | .haml | haml | Tilt team | +| Sass | .sass | haml (< 3.1) or sass (>= 3.1) | Tilt team | +| Scss | .scss | haml (< 3.1) or sass (>= 3.1) | Tilt team | +| Less CSS | .less | less | Tilt team | +| Builder | .builder | builder | Tilt team | +| Liquid | .liquid | liquid | Community | +| RDiscount | .markdown, .mkd, .md | rdiscount | Community | +| Redcarpet | .markdown, .mkd, .md | redcarpet | Community | +| BlueCloth | .markdown, .mkd, .md | bluecloth | Community | +| Kramdown | .markdown, .mkd, .md | kramdown | Community | +| Maruku | .markdown, .mkd, .md | maruku | Community | +| RedCloth | .textile | redcloth | Community | +| RDoc | .rdoc | rdoc | Tilt team | +| Radius | .radius | radius | Community | +| Markaby | .mab | markaby | Tilt team | +| Nokogiri | .nokogiri | nokogiri | Community | +| CoffeeScript | .coffee | coffee-script (+ javascript) | Tilt team | +| CoffeeScript (literate) | .litcoffee | coffee-script (>= 1.5.0) (+ javascript) | Tilt team | +| Creole (Wiki markup) | .wiki, .creole | creole | Community | +| WikiCloth (Wiki markup) | .wiki, .mediawiki, .mw | wikicloth | Community | +| Yajl | .yajl | yajl-ruby | Community | +| CSV | .rcsv | none (Ruby >= 1.9), fastercsv (Ruby < 1.9) | Tilt team | +| Prawn | .prawn | prawn (>= 2.0.0) | Community | +| Babel | .es6, .babel, .jsx | babel-transpiler | Tilt team | +| Opal | .rb | opal | Community | + +Every supported template engine has a *maintainer*. Note that this is the +maintainer of the Tilt integration, not the maintainer of the template engine +itself. The maintainer is responsible for providing an adequate integration and +keeping backwards compatibility across Tilt version. Some integrations are +maintained by the *community*, which is handled in the following way: + +- The Tilt team will liberally accept pull requests against the template + integration. It's up the community as a whole to make sure the integration + stays consistent and backwards compatible over time. +- Test failures in community-maintained integrations will not be prioritized by + the Tilt team and a new version of Tilt might be released even though these + tests are failing. +- Anyone can become a maintainer for a template engine integration they care + about. Just open an issue and we'll figure it out. These template engines ship with their own Tilt integration: - ENGINE FILE EXTENSIONS REQUIRED LIBRARIES - -------------------------- ----------------- ---------------------------- - Slim .slim slim (>= 0.7) - Embedded JavaScript sprockets - Embedded CoffeeScript sprockets - JST sprockets - Org-mode .org org-ruby (>= 0.6.2) - Handlebars .hbs, .handlebars tilt-handlebars +| Engine | File Extensions | Required Libraries | +| ------------------- | ---------------- | ------------------- | +| Slim | .slim | slim (>= 0.7) | +| Embedded JavaScript | | sprockets | +| Embedded CoffeeScript | | sprockets | +| JST | | sprockets | +| Org-mode | .org | org-ruby (>= 0.6.2) | +| Handlebars | .hbs, handlebars | tilt-handlebars | +| Jbuilder | .jbuilder | tilt-jbuilder | See [TEMPLATES.md][t] for detailed information on template engine options and supported features. @@ -77,7 +97,7 @@ require 'erb' require 'tilt' template = Tilt.new('templates/foo.erb') - => #<Tilt::ERBTemplate @file="templates/foo.rb" ...> + => #<Tilt::ERBTemplate @file="templates/foo.erb" ...> output = template.render => "Hello world!" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Rakefile new/Rakefile --- old/Rakefile 2014-03-21 09:49:40.000000000 +0100 +++ new/Rakefile 2016-01-05 13:57:20.000000000 +0100 @@ -15,19 +15,29 @@ # DOCUMENTATION ============================================================= -require 'yard' -YARD::Rake::YardocTask.new do |t| - t.files = [ - 'lib/tilt.rb', 'lib/tilt/mapping.rb', 'lib/tilt/template.rb', - '-', - '*.md', 'docs/*.md', - ] +begin + require 'yard' + YARD::Rake::YardocTask.new do |t| + t.files = [ + 'lib/tilt.rb', 'lib/tilt/mapping.rb', 'lib/tilt/template.rb', + '-', + '*.md', 'docs/*.md', + ] - t.options << - '--no-private' << - '--protected' << - '-m' << 'markdown' << - '--asset' << 'docs/common.css:css/common.css' + t.options << + '--no-private' << + '--protected' << + '-m' << 'markdown' << + '--asset' << 'docs/common.css:css/common.css' + end +rescue LoadError +end + +task :man do + require 'ronn' + ENV['RONN_MANUAL'] = "Tilt Manual" + ENV['RONN_ORGANIZATION'] = "Tilt #{SPEC.version}" + sh "ronn -w -s toc -r5 --markdown man/*.ronn" end # PACKAGING ================================================================= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bin/tilt new/bin/tilt --- old/bin/tilt 2014-03-21 09:49:40.000000000 +0100 +++ new/bin/tilt 2016-01-05 13:57:20.000000000 +0100 @@ -10,14 +10,15 @@ to determine the template's type. Options - -l, --list List template engines + file patterns and exit - -t, --type=<pattern> Use this template engine; required if no <file> - -y, --layout=<file> Use <file> as a layout template + -l, --list List template engines + file patterns and exit + -t, --type=<pattern> Use this template engine; required if no <file> + -y, --layout=<file> Use <file> as a layout template + + -D<name>=<value> Define variable <name> as <value> + -d, --define-file=<file> Load YAML from <file> and use for variables + --vars=<ruby> Evaluate <ruby> to Hash and use for variables - -D<name>=<value> Define variable <name> as <value> - --vars=<ruby> Evaluate <ruby> to Hash and use for variables - - -h, --help Show this help message + -h, --help Show this help message Convert markdown to HTML: $ tilt foo.markdown > foo.html @@ -77,6 +78,15 @@ locals[key.to_sym] = value end + # define local variables from YAML or JSON + o.on("-d", "--define-file=FILE", String) do |file| + require 'yaml' + abort "no such define file: #{file}" unless File.exist? file + hash = File.open(file, 'r:bom|utf-8') { |f| YAML.load f, file } + abort "vars must be a Hash, not #{hash.inspect}" if !hash.is_a?(Hash) + hash.each { |key, value| locals[key.to_sym] = value } + end + # define local variables using a Ruby hash o.on("--vars=RUBY") do |ruby| hash = eval(ruby) 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 2014-03-21 09:49:40.000000000 +0100 +++ new/docs/TEMPLATES.md 2016-01-05 13:57:20.000000000 +0100 @@ -31,6 +31,7 @@ * Sass - `Tilt::SassTemplate` * Scss - `Tilt::ScssTemplate` * CoffeeScript - `Tilt::CoffeeScriptTemplate` + * Literate CoffeeScript - `Tilt::CoffeeScriptLiterateTemplate` * [Textile](#redcloth) - `Tilt::RedClothTemplate` * Creole - `Tilt::CreoleTemplate` * [RDoc](#rdoc) - `Tilt::RDocTemplate` 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 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/tilt/babel.rb 2016-01-05 13:57:20.000000000 +0100 @@ -0,0 +1,15 @@ +require 'tilt/template' +require 'babel/transpiler' + +module Tilt + class BabelTemplate < Template + def prepare + options[:filename] ||= file + end + + def evaluate(scope, locals, &block) + @output ||= Babel::Transpiler.transform(data)["code"] + end + end +end + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/coffee.rb new/lib/tilt/coffee.rb --- old/lib/tilt/coffee.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/lib/tilt/coffee.rb 2016-01-05 13:57:20.000000000 +0100 @@ -29,10 +29,15 @@ @@default_bare = value end + def self.literate? + false + end + def prepare if !options.key?(:bare) and !options.key?(:no_wrap) options[:bare] = self.class.default_bare end + options[:literate] ||= self.class.literate? end def evaluate(scope, locals, &block) @@ -43,5 +48,11 @@ false end end + + class CoffeeScriptLiterateTemplate < CoffeeScriptTemplate + def self.literate? + true + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/csv.rb new/lib/tilt/csv.rb --- old/lib/tilt/csv.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/lib/tilt/csv.rb 2016-01-05 13:57:20.000000000 +0100 @@ -45,15 +45,15 @@ end def prepare - @code =<<-RUBY - #{self.class.engine}.generate do |csv| - #{data} - end - RUBY + @outvar = options.delete(:outvar) || '_csvout' end def precompiled_template(locals) - @code + <<-RUBY + #{@outvar} = #{self.class.engine}.generate(#{options}) do |csv| + #{data} + end + RUBY end def precompiled(locals) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/haml.rb new/lib/tilt/haml.rb --- old/lib/tilt/haml.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/lib/tilt/haml.rb 2016-01-05 13:57:20.000000000 +0100 @@ -13,6 +13,8 @@ end def evaluate(scope, locals, &block) + raise ArgumentError, 'invalid scope: must not be frozen' if scope.frozen? + if @engine.respond_to?(:precompiled_method_return_value, true) super else @@ -47,11 +49,10 @@ <<-RUBY #{precompiled_method_return_value} ensure - @haml_buffer = @haml_buffer.upper + @haml_buffer = @haml_buffer.upper if @haml_buffer end RUBY end end end end - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/kramdown.rb new/lib/tilt/kramdown.rb --- old/lib/tilt/kramdown.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/lib/tilt/kramdown.rb 2016-01-05 13:57:20.000000000 +0100 @@ -7,14 +7,6 @@ class KramdownTemplate < Template DUMB_QUOTES = [39, 39, 34, 34] - def self.engine_initialized? - defined? ::Kramdown - end - - def initialize_engine - require_template_library 'kramdown' - end - def prepare options[:smart_quotes] = DUMB_QUOTES unless options[:smartypants] @engine = Kramdown::Document.new(data, options) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/less.rb new/lib/tilt/less.rb --- old/lib/tilt/less.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/lib/tilt/less.rb 2016-01-05 13:57:20.000000000 +0100 @@ -9,14 +9,6 @@ class LessTemplate < Template self.default_mime_type = 'text/css' - def self.engine_initialized? - defined? ::Less - end - - def initialize_engine - require_template_library 'less' - end - def prepare if ::Less.const_defined? :Engine @engine = ::Less::Engine.new(data) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/liquid.rb new/lib/tilt/liquid.rb --- old/lib/tilt/liquid.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/lib/tilt/liquid.rb 2016-01-05 13:57:20.000000000 +0100 @@ -3,7 +3,7 @@ module Tilt # Liquid template implementation. See: - # http://liquid.rubyforge.org/ + # http://liquidmarkup.org/ # # Liquid is designed to be a *safe* template system and threfore # does not provide direct access to execuatable scopes. In order to diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/plain.rb new/lib/tilt/plain.rb --- old/lib/tilt/plain.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/lib/tilt/plain.rb 2016-01-05 13:57:20.000000000 +0100 @@ -6,10 +6,6 @@ class PlainTemplate < Template self.default_mime_type = 'text/html' - def self.engine_initialized? - true - end - def prepare end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/prawn.rb new/lib/tilt/prawn.rb --- old/lib/tilt/prawn.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/tilt/prawn.rb 2016-01-05 13:57:20.000000000 +0100 @@ -0,0 +1,43 @@ +require 'tilt/template' +require 'prawn' + +module Tilt + # Prawn template implementation. See: http://prawnpdf.org + # + class PrawnTemplate < Template + self.default_mime_type = 'application/pdf' + + def prepare + @engine = ::Prawn::Document.new(prawn_options) + end + + def evaluate(scope, locals, &block) + pdf = @engine + if data.respond_to?(:to_str) + locals[:pdf] = pdf + super(scope, locals, &block) + elsif data.kind_of?(Proc) + data.call(pdf) + end + @output ||= pdf.render + end + + def allows_script? + false + end + + def precompiled_template(locals) + data.to_str + end + + + private + + def prawn_options + # defaults to A4 instead of crazy US Letter format. + { :page_size => "A4", :page_layout => :portrait }.merge(options) + end + + end + +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt/redcarpet.rb new/lib/tilt/redcarpet.rb --- old/lib/tilt/redcarpet.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/lib/tilt/redcarpet.rb 2016-01-05 13:57:20.000000000 +0100 @@ -35,12 +35,8 @@ class Redcarpet2Template < Template self.default_mime_type = 'text/html' - def self.engine_initialized? - defined? ::Redcarpet::Render and defined? ::Redcarpet::Markdown - end - def generate_renderer - renderer = options.delete(:renderer) || ::Redcarpet::Render::HTML + renderer = options.delete(:renderer) || ::Redcarpet::Render::HTML.new(options) return renderer unless options.delete(:smartypants) return renderer if renderer.is_a?(Class) && renderer <= ::Redcarpet::Render::SmartyPants @@ -78,27 +74,10 @@ end end - # Upskirt Markdown implementation. See: - # https://github.com/tanoku/redcarpet - # - # Supports both Redcarpet 1.x and 2.x - class RedcarpetTemplate < Template - Redcarpet1 = Redcarpet1Template - Redcarpet2 = Redcarpet2Template - - def prepare - klass = Redcarpet2.engine_initialized? ? Redcarpet2 : Redcarpet1 - @engine = klass.new(file, line, options) { data } - end - - def evaluate(scope, locals, &block) - @engine.evaluate(scope, locals, &block) - end - - def allows_script? - false - end + if defined? ::Redcarpet::Render and defined? ::Redcarpet::Markdown + RedcarpetTemplate = Redcarpet2Template + else + RedcarpetTemplate = Redcarpet1Template end - end 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 2014-03-21 09:49:40.000000000 +0100 +++ new/lib/tilt/template.rb 2016-01-05 13:57:20.000000000 +0100 @@ -5,6 +5,8 @@ TOPOBJECT = Object.superclass || Object # @private LOCK = Mutex.new + # @private + SYMBOL_ARRAY_SORTABLE = RUBY_VERSION >= '1.9' # Base class for template implementations. Subclasses must implement # the #prepare method and one of the #evaluate or #precompiled_template @@ -90,7 +92,8 @@ # Render the template in the given scope with the locals specified. If a # block is given, it is typically available within the template via # +yield+. - def render(scope=Object.new, locals={}, &block) + def render(scope=nil, locals={}, &block) + scope ||= Object.new current_template = Thread.current[:tilt_current_template] Thread.current[:tilt_current_template] = self evaluate(scope, locals || {}, &block) @@ -151,7 +154,13 @@ # This method is only used by source generating templates. Subclasses that # override render() may not support all features. def evaluate(scope, locals, &block) - method = compiled_method(locals.keys) + locals_keys = locals.keys + if SYMBOL_ARRAY_SORTABLE + locals_keys.sort! + else + locals_keys.sort!{|x, y| x.to_s <=> y.to_s} + end + method = compiled_method(locals_keys) method.bind(scope).call(locals, &block) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/tilt.rb new/lib/tilt.rb --- old/lib/tilt.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/lib/tilt.rb 2016-01-05 13:57:20.000000000 +0100 @@ -4,7 +4,7 @@ # Namespace for Tilt. This module is not intended to be included anywhere. module Tilt # Current version. - VERSION = '2.0.1' + VERSION = '2.0.2' @default_mapping = Mapping.new @@ -78,14 +78,31 @@ # cache.fetch(path, line, options) { Tilt.new(path, line, options) } # # Subsequent invocations return the already loaded template object. + # + # @note + # Tilt::Cache is a thin wrapper around Hash. It has the following + # limitations: + # * Not thread-safe. + # * Size is unbounded. + # * Keys are not copied defensively, and should not be modified after + # being passed to #fetch. More specifically, the values returned by + # key#hash and key#eql? should not change. + # If this is too limiting for you, use a different cache implementation. class Cache def initialize @cache = {} end - # @see Cache + # Caches a value for key, or returns the previously cached value. + # If a value has been previously cached for key then it is + # returned. Otherwise, block is yielded to and its return value + # which may be nil, is cached under key and returned. + # @yield + # @yieldreturn the value to cache for key def fetch(*key) - @cache[key] ||= yield + @cache.fetch(key) do + @cache[key] = yield + end end # Clears the cache. @@ -110,9 +127,11 @@ # Rest (sorted by name) register_lazy :AsciidoctorTemplate, 'tilt/asciidoc', 'ad', 'adoc', 'asciidoc' + register_lazy :BabelTemplate, 'tilt/babel', 'es6', 'babel', 'jsx' register_lazy :BuilderTemplate, 'tilt/builder', 'builder' register_lazy :CSVTemplate, 'tilt/csv', 'rcsv' register_lazy :CoffeeScriptTemplate, 'tilt/coffee', 'coffee' + register_lazy :CoffeeScriptLiterateTemplate, 'tilt/coffee', 'litcoffee' register_lazy :CreoleTemplate, 'tilt/creole', 'wiki', 'creole' register_lazy :EtanniTemplate, 'tilt/etanni', 'etn', 'etanni' register_lazy :HamlTemplate, 'tilt/haml', 'haml' @@ -121,6 +140,7 @@ register_lazy :MarkabyTemplate, 'tilt/markaby', 'mab' register_lazy :NokogiriTemplate, 'tilt/nokogiri', 'nokogiri' register_lazy :PlainTemplate, 'tilt/plain', 'html' + register_lazy :PrawnTemplate, 'tilt/prawn', 'prawn' register_lazy :RDocTemplate, 'tilt/rdoc', 'rdoc' register_lazy :RadiusTemplate, 'tilt/radius', 'radius' register_lazy :RedClothTemplate, 'tilt/redcloth', 'textile' @@ -134,4 +154,6 @@ register_lazy 'Slim::Template', 'slim', 'slim' register_lazy 'Tilt::HandlebarsTemplate', 'tilt/handlebars', 'handlebars', 'hbs' register_lazy 'Tilt::OrgTemplate', 'org-ruby', 'org' + register_lazy 'Opal::Processor', 'opal', 'opal', 'rb' + register_lazy 'Tilt::JbuilderTemplate', 'tilt/jbuilder', 'jbuilder' end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/man/index.txt new/man/index.txt --- old/man/index.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/man/index.txt 2016-01-05 13:57:20.000000000 +0100 @@ -0,0 +1,2 @@ +m4(1) http://man.cx/m4(1) +mustache(1) https://mustache.github.io/mustache.1.html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/man/tilt.1.ronn new/man/tilt.1.ronn --- old/man/tilt.1.ronn 1970-01-01 01:00:00.000000000 +0100 +++ new/man/tilt.1.ronn 2016-01-05 13:57:20.000000000 +0100 @@ -0,0 +1,59 @@ +tilt(1) -- process templates +============================ + +## SYNOPSIS + +`tilt` `-l`<br> +`tilt` [`-t` <pattern>] [`-y` <file>] [`-D` <name>=<value>] [`-d` <file>] + [`--vars=`<ruby>] <file> + +## DESCRIPTION + +Process template <file> and write output to stdout. With no <file> or +when <file> is '-', read template from stdin and use the --type option +to determine the template's type. + +## OPTIONS + +* `-l`, `--list`: + List template engines + file patterns and exit +* `-t`, `--type`=<pattern>: + Use this template engine; required if no <file> +* `-y`, `--layout`=<file>: + Use <file> as a layout template +* `-D`<name>=<value>: + Define variable <name> as <value> +* `-d`, `--define-file`=<file>: + Load YAML or JSON from <file> and use for variables +* `--vars`=<ruby>: + Evaluate <ruby> to Hash and use for variables +* `-h`, `--help`: + Show this help message + +## EXAMPLES + +Convert markdown to HTML: + + $ tilt foo.markdown > foo.html + +Process ERB template: + + $ echo "Answer: <%= 2 + 2 %>" | tilt -t erb + Answer: 4 + +Define variables: + + $ echo '{"n":40}' > data.json + $ echo "Answer: <%= 2 + n %>" | tilt -t erb -d data.json + Answer: 42 + + $ echo "Answer: <%= 2 + n %>" | tilt -t erb --vars="{:n=>40}" + Answer: 42 + $ echo "Answer: <%= 2 + n.to_i %>" | tilt -t erb -Dn=40 + Answer: 42 + +## SEE ALSO + +m4(1), mustache(1) + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2014-03-21 09:49:40.000000000 +0100 +++ new/metadata 2016-01-05 13:57:20.000000000 +0100 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: tilt version: !ruby/object:Gem::Version - version: 2.0.1 + version: 2.0.2 platform: ruby authors: - Ryan Tomayko autorequire: bindir: bin cert_chain: [] -date: 2014-03-21 00:00:00.000000000 Z +date: 2016-01-05 00:00:00.000000000 Z dependencies: [] description: Generic interface to multiple Ruby template engines email: [email protected] @@ -28,6 +28,7 @@ - docs/common.css - lib/tilt.rb - lib/tilt/asciidoc.rb +- lib/tilt/babel.rb - lib/tilt/bluecloth.rb - lib/tilt/builder.rb - lib/tilt/coffee.rb @@ -45,6 +46,7 @@ - lib/tilt/maruku.rb - lib/tilt/nokogiri.rb - lib/tilt/plain.rb +- lib/tilt/prawn.rb - lib/tilt/radius.rb - lib/tilt/rdiscount.rb - lib/tilt/rdoc.rb @@ -55,6 +57,8 @@ - lib/tilt/template.rb - lib/tilt/wikicloth.rb - lib/tilt/yajl.rb +- man/index.txt +- man/tilt.1.ronn - test/markaby/locals.mab - test/markaby/markaby.mab - test/markaby/markaby_other_static.mab @@ -63,6 +67,7 @@ - test/markaby/yielding.mab - test/test_helper.rb - test/tilt_asciidoctor_test.rb +- test/tilt_babeltemplate.rb - test/tilt_blueclothtemplate_test.rb - test/tilt_buildertemplate_test.rb - test/tilt_cache_test.rb @@ -84,6 +89,8 @@ - test/tilt_marukutemplate_test.rb - test/tilt_metadata_test.rb - test/tilt_nokogiritemplate_test.rb +- test/tilt_prawntemplate.prawn +- test/tilt_prawntemplate_test.rb - test/tilt_radiustemplate_test.rb - test/tilt_rdiscounttemplate_test.rb - test/tilt_rdoctemplate_test.rb @@ -122,7 +129,7 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.2.1 +rubygems_version: 2.2.2 signing_key: specification_version: 2 summary: Generic interface to multiple Ruby template engines @@ -148,6 +155,7 @@ - test/tilt_marukutemplate_test.rb - test/tilt_metadata_test.rb - test/tilt_nokogiritemplate_test.rb +- test/tilt_prawntemplate_test.rb - test/tilt_radiustemplate_test.rb - test/tilt_rdiscounttemplate_test.rb - test/tilt_rdoctemplate_test.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_asciidoctor_test.rb new/test/tilt_asciidoctor_test.rb --- old/test/tilt_asciidoctor_test.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/test/tilt_asciidoctor_test.rb 2016-01-05 13:57:20.000000000 +0100 @@ -6,7 +6,8 @@ class AsciidoctorTemplateTest < Minitest::Test HTML5_OUTPUT = "<div class=\"sect1\"><h2 id=\"_hello_world\">Hello World!</h2><div class=\"sectionbody\"></div></div>" - DOCBOOK_OUTPUT = "<section id=\"_hello_world\"><title>Hello World!</title></section>" + DOCBOOK45_OUTPUT = "<section id=\"_hello_world\"><title>Hello World!</title></section>" + DOCBOOK5_OUTPUT = "<section xml:id=\"_hello_world\"><title>Hello World!</title></section>" def strip_space(str) str.gsub(/>\s+</, '><').strip @@ -29,9 +30,14 @@ assert_equal HTML5_OUTPUT, strip_space(template.render) end - test "preparing and evaluating docbook templates on #render" do - template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook'}) { |t| "== Hello World!" } - assert_equal DOCBOOK_OUTPUT, strip_space(template.render) + test "preparing and evaluating docbook 4.5 templates on #render" do + template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook45'}) { |t| "== Hello World!" } + assert_equal DOCBOOK45_OUTPUT, strip_space(template.render) + end + + test "preparing and evaluating docbook 5 templates on #render" do + template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook5'}) { |t| "== Hello World!" } + assert_equal DOCBOOK5_OUTPUT, strip_space(template.render) end test "can be rendered more than once" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_babeltemplate.rb new/test/tilt_babeltemplate.rb --- old/test/tilt_babeltemplate.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/tilt_babeltemplate.rb 2016-01-05 13:57:20.000000000 +0100 @@ -0,0 +1,33 @@ +require 'test_helper' +require 'tilt' + +begin + require 'tilt/babel' + + class BabelTemplateTest < Minitest::Test + test "registered for '.es6' files" do + assert_equal Tilt::BabelTemplate, Tilt['es6'] + end + + test "registered for '.babel' files" do + assert_equal Tilt::BabelTemplate, Tilt['babel'] + end + + test "registered for '.jsx' files" do + assert_equal Tilt::BabelTemplate, Tilt['jsx'] + end + + test "basic ES6 features" do + template = Tilt::BabelTemplate.new { "square = (x) => x * x" } + assert_match "function", template.render + end + + test "JSX support" do + template = Tilt::BabelTemplate.new { "<Awesome ness={true} />" } + assert_match "React.createElement", template.render + end + end +rescue LoadError => boom + warn "Tilt::BabelTemplate (disabled)" +end + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_cache_test.rb new/test/tilt_cache_test.rb --- old/test/tilt_cache_test.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/test/tilt_cache_test.rb 2016-01-05 13:57:20.000000000 +0100 @@ -20,6 +20,17 @@ assert_same template, result end + test "caching nil" do + called = false + result = @cache.fetch("blah") {called = true; nil} + assert_equal true, called + assert_nil result + called = false + result = @cache.fetch("blah") {called = true; :blah} + assert_equal false, called + assert_nil result + end + test "clearing the cache with #clear" do template, other = nil result = @cache.fetch('hello') { template = Tilt::StringTemplate.new {''} } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_coffeescripttemplate_test.rb new/test/tilt_coffeescripttemplate_test.rb --- old/test/tilt_coffeescripttemplate_test.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/test/tilt_coffeescripttemplate_test.rb 2016-01-05 13:57:20.000000000 +0100 @@ -4,98 +4,135 @@ begin require 'tilt/coffee' - class CoffeeScriptTemplateTest < Minitest::Test - - test "is registered for '.coffee' files" do - assert_equal Tilt::CoffeeScriptTemplate, Tilt['test.coffee'] + module CoffeeScriptTests + def self.included(mod) + mod.class_eval do + test "bare is disabled by default" do + assert_equal false, @renderer.default_bare + end + + test "compiles and evaluates the template on #render" do + template = @renderer.new { |t| @code_without_variables } + assert_match "puts('Hello, World!');", template.render + end + + test "can be rendered more than once" do + template = @renderer.new { |t| @code_without_variables } + 3.times { assert_match "puts('Hello, World!');", template.render } + end + + test "disabling coffee-script wrapper" do + template = @renderer.new { @code_with_variables } + assert_match "(function() {", template.render + assert_match "puts(\"Hello, \" + name);\n", template.render + + template = @renderer.new(:bare => true) { @code_with_variables } + refute_match "(function() {", template.render + assert_equal "var name;\n\nname = \"Josh\";\n\nputs(\"Hello, \" + name);\n", template.render + + template2 = @renderer.new(:no_wrap => true) { @code_with_variables} + refute_match "(function() {", template.render + assert_equal "var name;\n\nname = \"Josh\";\n\nputs(\"Hello, \" + name);\n", template.render + end + + context "wrapper globally enabled" do + setup do + @bare = @renderer.default_bare + @renderer.default_bare = false + end + + teardown do + @renderer.default_bare = @bare + end + + test "no options" do + template = @renderer.new { |t| @code_with_variables } + assert_match "puts(\"Hello, \" + name);", template.render + assert_match "(function() {", template.render + end + + test "overridden by :bare" do + template = @renderer.new(:bare => true) { |t| @code_with_variables } + assert_match "puts(\"Hello, \" + name);", template.render + refute_match "(function() {", template.render + end + + test "overridden by :no_wrap" do + template = @renderer.new(:no_wrap => true) { |t| @code_with_variables } + assert_match "puts(\"Hello, \" + name);", template.render + refute_match "(function() {", template.render + end + end + + context "wrapper globally disabled" do + setup do + @bare = @renderer.default_bare + @renderer.default_bare = true + end + + teardown do + @renderer.default_bare = @bare + end + + test "no options" do + template = @renderer.new { |t| @code_with_variables } + assert_match "puts(\"Hello, \" + name);", template.render + refute_match "(function() {", template.render + end + + test "overridden by :bare" do + template = @renderer.new(:bare => false) { |t| @code_with_variables } + assert_match "puts(\"Hello, \" + name);", template.render + assert_match "(function() {", template.render + end + + test "overridden by :no_wrap" do + template = @renderer.new(:no_wrap => false) { |t| @code_with_variables } + assert_match "puts(\"Hello, \" + name);", template.render + assert_match "(function() {", template.render + end + end + end end + end - test "bare is disabled by default" do - assert_equal false, Tilt::CoffeeScriptTemplate.default_bare + class CoffeeScriptTemplateTest < Minitest::Test + setup do + @code_without_variables = "puts 'Hello, World!'\n" + @code_with_variables = 'name = "Josh"; puts "Hello, #{name}"' + @renderer = Tilt::CoffeeScriptTemplate end - test "compiles and evaluates the template on #render" do - template = Tilt::CoffeeScriptTemplate.new { |t| "puts 'Hello, World!'\n" } - assert_match "puts('Hello, World!');", template.render - end + include CoffeeScriptTests - test "can be rendered more than once" do - template = Tilt::CoffeeScriptTemplate.new { |t| "puts 'Hello, World!'\n" } - 3.times { assert_match "puts('Hello, World!');", template.render } + test "is registered for '.coffee' files" do + assert_equal @renderer, Tilt['test.coffee'] end + end - test "disabling coffee-script wrapper" do - str = 'name = "Josh"; puts "Hello #{name}"' + class LiterateCoffeeScriptTemplateTest < Minitest::Test + setup do + @code_without_variables = <<EOLIT +This is some comment. - template = Tilt::CoffeeScriptTemplate.new { str } - assert_match "(function() {", template.render - assert_match "puts(\"Hello \" + name);\n", template.render - - template = Tilt::CoffeeScriptTemplate.new(:bare => true) { str } - refute_match "(function() {", template.render - assert_equal "var name;\n\nname = \"Josh\";\n\nputs(\"Hello \" + name);\n", template.render - - template2 = Tilt::CoffeeScriptTemplate.new(:no_wrap => true) { str} - refute_match "(function() {", template.render - assert_equal "var name;\n\nname = \"Josh\";\n\nputs(\"Hello \" + name);\n", template.render - end + puts 'Hello, World!' - context "wrapper globally enabled" do - setup do - @bare = Tilt::CoffeeScriptTemplate.default_bare - Tilt::CoffeeScriptTemplate.default_bare = false - end +This is a comment too. +EOLIT + @code_with_variables = <<EOLIT +This is some comment. - teardown do - Tilt::CoffeeScriptTemplate.default_bare = @bare - end + name = "Josh"; puts "Hello, \#{name}" - test "no options" do - template = Tilt::CoffeeScriptTemplate.new { |t| 'name = "Josh"; puts "Hello, #{name}"' } - assert_match "puts(\"Hello, \" + name);", template.render - assert_match "(function() {", template.render - end - - test "overridden by :bare" do - template = Tilt::CoffeeScriptTemplate.new(:bare => true) { |t| 'name = "Josh"; puts "Hello, #{name}"' } - assert_match "puts(\"Hello, \" + name);", template.render - refute_match "(function() {", template.render - end - - test "overridden by :no_wrap" do - template = Tilt::CoffeeScriptTemplate.new(:no_wrap => true) { |t| 'name = "Josh"; puts "Hello, #{name}"' } - assert_match "puts(\"Hello, \" + name);", template.render - refute_match "(function() {", template.render - end +This is a comment too. +EOLIT + @renderer = Tilt::CoffeeScriptLiterateTemplate end - context "wrapper globally disabled" do - setup do - @bare = Tilt::CoffeeScriptTemplate.default_bare - Tilt::CoffeeScriptTemplate.default_bare = true - end - - teardown do - Tilt::CoffeeScriptTemplate.default_bare = @bare - end - - test "no options" do - template = Tilt::CoffeeScriptTemplate.new { |t| 'name = "Josh"; puts "Hello, #{name}"' } - assert_match "puts(\"Hello, \" + name);", template.render - refute_match "(function() {", template.render - end + include CoffeeScriptTests - test "overridden by :bare" do - template = Tilt::CoffeeScriptTemplate.new(:bare => false) { |t| 'name = "Josh"; puts "Hello, #{name}"' } - assert_match "puts(\"Hello, \" + name);", template.render - assert_match "(function() {", template.render - end - - test "overridden by :no_wrap" do - template = Tilt::CoffeeScriptTemplate.new(:no_wrap => false) { |t| 'name = "Josh"; puts "Hello, #{name}"' } - assert_match "puts(\"Hello, \" + name);", template.render - assert_match "(function() {", template.render - end + test "is registered for '.litcoffee' files" do + assert_equal @renderer, Tilt['test.litcoffee'] end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_csv_test.rb new/test/tilt_csv_test.rb --- old/test/tilt_csv_test.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/test/tilt_csv_test.rb 2016-01-05 13:57:20.000000000 +0100 @@ -47,6 +47,18 @@ end end + test "passing options to engine" do + template = Tilt::CSVTemplate.new(:col_sep => '|') { 'csv << [1,2,3]' } + assert_equal "1|2|3\n", template.render + end + + test "outvar option" do + outvar = '@_output' + scope = Object.new + template = Tilt::CSVTemplate.new(:outvar => outvar) { 'csv << [1,2,3]' } + output = template.render(scope) + assert_equal output, scope.instance_variable_get(outvar.to_sym) + end end rescue LoadError => boom diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_hamltemplate_test.rb new/test/tilt_hamltemplate_test.rb --- old/test/tilt_hamltemplate_test.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/test/tilt_hamltemplate_test.rb 2016-01-05 13:57:20.000000000 +0100 @@ -27,6 +27,17 @@ assert_equal "<p>Hey Joe!</p>\n", template.render(Object.new, :name => 'Joe') end + test 'evaluating in default/nil scope' do + template = Tilt::HamlTemplate.new { |t| '%p Hey unknown!' } + assert_equal "<p>Hey unknown!</p>\n", template.render + assert_equal "<p>Hey unknown!</p>\n", template.render(nil) + end + + test 'evaluating in invalid, frozen scope' do + template = Tilt::HamlTemplate.new { |t| '%p Hey unknown!' } + assert_raises(ArgumentError) { template.render(Object.new.freeze) } + end + test "evaluating in an object scope" do template = Tilt::HamlTemplate.new { "%p= 'Hey ' + @name + '!'" } scope = Object.new @@ -87,6 +98,17 @@ assert_equal "<p>Hey Joe!</p>\n", template.render(Scope.new, :name => 'Joe') end + test 'evaluating in default/nil scope' do + template = Tilt::HamlTemplate.new { |t| '%p Hey unknown!' } + assert_equal "<p>Hey unknown!</p>\n", template.render + assert_equal "<p>Hey unknown!</p>\n", template.render(nil) + end + + test 'evaluating in invalid, frozen scope' do + template = Tilt::HamlTemplate.new { |t| '%p Hey unknown!' } + assert_raises(ArgumentError) { template.render(Object.new.freeze) } + end + test "evaluating in an object scope" do template = Tilt::HamlTemplate.new { "%p= 'Hey ' + @name + '!'" } scope = Scope.new 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 2014-03-21 09:49:40.000000000 +0100 +++ new/test/tilt_markdown_test.rb 2016-01-05 13:57:20.000000000 +0100 @@ -91,8 +91,6 @@ class MarkdownRedcarpetTest < Minitest::Test include MarkdownTests template Tilt::RedcarpetTemplate - # Doesn't support escaping - undef test_escape_html_true def test_smarty_pants_true # Various versions of Redcarpet support various versions of Smart pants. @@ -100,6 +98,11 @@ assert_match /<p>Hello “World(''|”) – This is — a test …<\/p>/, html end + def test_renderer_options + html = nrender "Hello [World](http://example.com)", :smartypants => true, :no_links => true + assert_equal "<p>Hello [World](http://example.com)</p>", html + end + def test_fenced_code_blocks_with_lang code = <<-COD.gsub(/^\s+/,"") ```ruby diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_prawntemplate.prawn new/test/tilt_prawntemplate.prawn --- old/test/tilt_prawntemplate.prawn 1970-01-01 01:00:00.000000000 +0100 +++ new/test/tilt_prawntemplate.prawn 2016-01-05 13:57:20.000000000 +0100 @@ -0,0 +1 @@ +pdf.text "Hello Template!" \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_prawntemplate_test.rb new/test/tilt_prawntemplate_test.rb --- old/test/tilt_prawntemplate_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/test/tilt_prawntemplate_test.rb 2016-01-05 13:57:20.000000000 +0100 @@ -0,0 +1,75 @@ +require 'test_helper' +require 'tilt' + +begin + require 'tilt/prawn' + require 'pdf-reader' + + class PdfOutput + def initialize(pdf_raw) + @reader = PDF::Reader.new(StringIO.new(pdf_raw)) + end + + def text + @reader.pages.map(&:text).join + end + + def page_attributes(page_num=1) + @reader.page(page_num).attributes + end + end + + class PrawnTemplateTest < Minitest::Test + test "is registered for '.prawn' files" do + assert_equal Tilt::PrawnTemplate, Tilt['test.prawn'] + end + + test "compiles and evaluates the template on #render" do + template = Tilt::PrawnTemplate.new { |t| "pdf.text \"Hello PDF!\"" } + output = PdfOutput.new(template.render) + assert_includes output.text, "Hello PDF!" + end + + test "can be rendered more than once" do + template = Tilt::PrawnTemplate.new { |t| "pdf.text \"Hello PDF!\"" } + 3.times do + output = PdfOutput.new(template.render) + assert_includes output.text, "Hello PDF!" + end + end + + test "loads the template from a file and renders it correctly" do + template = Tilt::PrawnTemplate.new("#{Dir.pwd}/test/tilt_prawntemplate.prawn") + output = PdfOutput.new(template.render) + assert_includes output.text, "Hello Template!" + end + + test "loads the template from a file and can be rendered more than once" do + template = Tilt::PrawnTemplate.new("#{Dir.pwd}/test/tilt_prawntemplate.prawn") + 3.times do + output = PdfOutput.new(template.render) + assert_includes output.text, "Hello Template!" + end + end + + test "have the correct default page size & layout settings - (default: A4 portrait)" do + # NOTE! Dear North Americans, + # Please follow the ISO 216 international standard format (A4) that dominates everywhere else in the world + template = Tilt::PrawnTemplate.new { |t| "pdf.text \"Hello A4 portrait!\"" } + output = PdfOutput.new(template.render) + assert_includes output.text, "Hello A4 portrait!" + assert_equal [0, 0, 595.28, 841.89], output.page_attributes(1)[:MediaBox] + end + + test "allows page size & layout settings - A3 landscape" do + template = Tilt::PrawnTemplate.new( :page_size => 'A3', :page_layout => :landscape) { |t| "pdf.text \"Hello A3 landscape!\"" } + output = PdfOutput.new(template.render) + assert_includes output.text, "Hello A3 landscape!" + assert_equal [0, 0, 1190.55, 841.89], output.page_attributes(1)[:MediaBox] + end + + end + +rescue LoadError => boom + warn "Tilt::PrawnTemplate (disabled)" +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_redcarpettemplate_test.rb new/test/tilt_redcarpettemplate_test.rb --- old/test/tilt_redcarpettemplate_test.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/test/tilt_redcarpettemplate_test.rb 2016-01-05 13:57:20.000000000 +0100 @@ -25,11 +25,6 @@ end end - test "redcarpet2 is our default choice" do - template = Tilt::RedcarpetTemplate.new {} - assert_equal Tilt::RedcarpetTemplate::Redcarpet2, template.prepare.class - end - test "preparing and evaluating templates on #render" do template = Tilt::RedcarpetTemplate.new { |t| "# Hello World!" } assert_equal "<h1>Hello World!</h1>\n", template.render diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_template_test.rb new/test/tilt_template_test.rb --- old/test/tilt_template_test.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/test/tilt_template_test.rb 2016-01-05 13:57:20.000000000 +0100 @@ -75,20 +75,6 @@ MockTemplate.new { |template| "Hello World!" } end - class InitializingMockTemplate < Tilt::Template - @@initialized_count = 0 - def self.initialized_count - @@initialized_count - end - - def initialize_engine - @@initialized_count += 1 - end - - def prepare - end - end - class PreparingMockTemplate < Tilt::Template def prepare raise "data must be set" if data.nil? @@ -122,6 +108,12 @@ assert inst.prepared? end + test 'prepares and evaluates the template on #render with nil arg' do + inst = SimpleMockTemplate.new { |t| "Hello World!" } + assert_equal '<em>Hello World!</em>', inst.render(nil) + assert inst.prepared? + end + class SourceGeneratingMockTemplate < PreparingMockTemplate def precompiled_template(locals) "foo = [] ; foo << %Q{#{data}} ; foo.join" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/tilt_wikiclothtemplate_test.rb new/test/tilt_wikiclothtemplate_test.rb --- old/test/tilt_wikiclothtemplate_test.rb 2014-03-21 09:49:40.000000000 +0100 +++ new/test/tilt_wikiclothtemplate_test.rb 2016-01-05 13:57:20.000000000 +0100 @@ -19,12 +19,12 @@ test "compiles and evaluates the template on #render" do template = Tilt::WikiClothTemplate.new { |t| "= Hello World! =" } - assert_match /<h1>.*Hello World!.*<\/h1>/, template.render + assert_match /<h1>.*Hello World!.*<\/h1>/m, template.render end test "can be rendered more than once" do template = Tilt::WikiClothTemplate.new { |t| "= Hello World! =" } - 3.times { assert_match /<h1>.*Hello World!.*<\/h1>/, template.render } + 3.times { assert_match /<h1>.*Hello World!.*<\/h1>/m, template.render } end end rescue LoadError => boom diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tilt.gemspec new/tilt.gemspec --- old/tilt.gemspec 2014-03-21 09:49:40.000000000 +0100 +++ new/tilt.gemspec 2016-01-05 13:57:20.000000000 +0100 @@ -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.1' - s.date = '2014-03-21' + s.version = '2.0.2' + s.date = '2016-01-05' s.description = "Generic interface to multiple Ruby template engines" s.summary = s.description @@ -26,6 +26,7 @@ docs/common.css lib/tilt.rb lib/tilt/asciidoc.rb + lib/tilt/babel.rb lib/tilt/bluecloth.rb lib/tilt/builder.rb lib/tilt/coffee.rb @@ -43,6 +44,7 @@ lib/tilt/maruku.rb lib/tilt/nokogiri.rb lib/tilt/plain.rb + lib/tilt/prawn.rb lib/tilt/radius.rb lib/tilt/rdiscount.rb lib/tilt/rdoc.rb @@ -53,6 +55,8 @@ lib/tilt/template.rb lib/tilt/wikicloth.rb lib/tilt/yajl.rb + man/index.txt + man/tilt.1.ronn test/markaby/locals.mab test/markaby/markaby.mab test/markaby/markaby_other_static.mab @@ -61,6 +65,7 @@ test/markaby/yielding.mab test/test_helper.rb test/tilt_asciidoctor_test.rb + test/tilt_babeltemplate.rb test/tilt_blueclothtemplate_test.rb test/tilt_buildertemplate_test.rb test/tilt_cache_test.rb @@ -82,6 +87,8 @@ test/tilt_marukutemplate_test.rb test/tilt_metadata_test.rb test/tilt_nokogiritemplate_test.rb + test/tilt_prawntemplate.prawn + test/tilt_prawntemplate_test.rb test/tilt_radiustemplate_test.rb test/tilt_rdiscounttemplate_test.rb test/tilt_rdoctemplate_test.rb
