Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

sinatra 0.9.2 compatibility

  • Loading branch information...
commit 7db3b5a2008c8de58f6979c16c4cfea3f85f58be 1 parent 06e5f42
S. Brent Faulkner authored
View
3  CHANGES
@@ -0,0 +1,3 @@
+= 0.9.2 / unreleased
+
+* This version is compatible with the Sinatra 0.9.2 release candidate.
View
3  TODO
@@ -0,0 +1,3 @@
+= TODO
+
+* Switch to Rack::Test
View
2  VERSION.yml
@@ -1,4 +1,4 @@
---
:major: 0
:minor: 9
-:patch: 1
+:patch: 2
View
15 lib/sinatra/prawn.rb
@@ -1,4 +1,5 @@
require 'sinatra/base'
+require 'prawn'
module Sinatra
module Prawn
@@ -6,20 +7,20 @@ module Prawn
# Takes the name of a template to render as a Symbol and returns a String with the rendered output.
#
# Options for prawn may be specified in Sinatra using set :prawn, { ... }
- def prawn(template=nil, options={}, &block)
- require 'prawn' unless defined? ::Prawn
+ def prawn(template=nil, options={}, locals = {}, &block)
options, template = template, nil if template.is_a?(Hash)
template = lambda { block } if template.nil?
options[:layout] = false
- options[:options] ||= self.class.prawn if self.class.respond_to? :prawn
- render :prawn, template, options
+ render :prawn, template, options, locals
end
protected
- def render_prawn(template, data, options, &block)
- pdf = ::Prawn::Document.new(options[:options] || {})
+ def render_prawn(template, data, options, locals, &block)
+ filename = options.delete(:filename) || '<PRAWN>'
+ line = options.delete(:line) || 1
+ pdf = ::Prawn::Document.new(options)
if data.respond_to?(:to_str)
- eval data.to_str, binding, '<PRAWN>', 1
+ eval data.to_str, binding, filename, line
elsif data.kind_of?(Proc)
data.call(pdf)
end
View
25 sinatra-prawn.gemspec
@@ -2,20 +2,37 @@
Gem::Specification.new do |s|
s.name = %q{sinatra-prawn}
- s.version = "0.9.1"
+ s.version = "0.9.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["S. Brent Faulkner"]
- s.date = %q{2009-03-11}
+ s.date = %q{2009-04-28}
s.description = %q{Sinatra extension to add support for pdf rendering with Prawn templates.}
s.email = %q{brentf@unwwwired.net}
- s.files = ["README.rdoc", "VERSION.yml", "lib/sinatra", "lib/sinatra/prawn.rb", "test/sinatra_prawn_test.rb", "test/test_helper.rb", "test/views", "test/views/hello.prawn"]
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README.rdoc"
+ ]
+ s.files = [
+ "LICENSE",
+ "README.rdoc",
+ "Rakefile",
+ "VERSION.yml",
+ "lib/sinatra/prawn.rb",
+ "test/sinatra_prawn_test.rb",
+ "test/test_helper.rb",
+ "test/views/hello.prawn"
+ ]
s.has_rdoc = true
s.homepage = %q{http://github.com/sbfaulkner/sinatra-prawn}
- s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
+ s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.1}
s.summary = %q{Sinatra extension to add support for pdf rendering with Prawn templates.}
+ s.test_files = [
+ "test/sinatra_prawn_test.rb",
+ "test/test_helper.rb"
+ ]
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
View
6 test/sinatra_prawn_test.rb
@@ -1,8 +1,6 @@
require File.dirname(__FILE__) + '/test_helper'
class SinatraPrawnTest < Test::Unit::TestCase
- include Sinatra::Test
-
def prawn_app(&block)
mock_app {
helpers Sinatra::Prawn
@@ -44,8 +42,10 @@ def test_renders_prawn_files_in_views_path
def test_raises_error_if_template_not_found
mock_app {
helpers Sinatra::Prawn
+ set :environment, :test
+ set :raise_errors, true
get('/') { prawn :no_such_template }
}
- assert_raise(Errno::ENOENT) { get('/') }
+ assert_raises(Errno::ENOENT) { get('/') }
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.