prawnto_2 0.2.4.beta → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +15 -16
- data/Rakefile +1 -8
- data/lib/prawnto.rb +1 -0
- data/lib/prawnto/compile_support.rb +10 -5
- data/lib/prawnto/model_renderer.rb +3 -2
- data/lib/prawnto/template_handlers/base.rb +4 -5
- data/lib/prawnto/template_handlers/partials.rb +11 -3
- metadata +60 -165
- data/.gitignore +0 -8
- data/.travis.yml +0 -3
- data/Appraisals +0 -7
- data/Gemfile +0 -13
- data/Guardfile +0 -15
- data/prawnto.gemspec +0 -22
- data/rails/init.rb +0 -1
- data/script/rails +0 -6
- data/spec/assets/default_render-0.12.0.pdf +0 -83
- data/spec/assets/default_render-0.6.3.pdf +0 -85
- data/spec/assets/dsl_render-0.12.0.pdf +0 -83
- data/spec/assets/dsl_render-0.6.3.pdf +0 -85
- data/spec/assets/partial_render-0.12.0.pdf +0 -83
- data/spec/assets/partial_render-0.6.3.pdf +0 -85
- data/spec/assets/yield_block_in_helper_test-0.12.0.pdf +0 -76
- data/spec/assets/yield_block_in_helper_test-0.6.3.pdf +0 -78
- data/spec/dummy/.rspec +0 -1
- data/spec/dummy/.sass-cache/387f7b3fde13680ae5a79212c089f81d2d418f1e/application.css.scssc +0 -0
- data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/_shared.css.scssc +0 -0
- data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/ab_tests.css.scssc +0 -0
- data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/application.css.scssc +0 -0
- data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/metrics.css.scssc +0 -0
- data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/reports.css.scssc +0 -0
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/javascripts/application.js +0 -10
- data/spec/dummy/app/assets/javascripts/highcharts.js +0 -170
- data/spec/dummy/app/assets/stylesheets/application.css.scss +0 -78
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/controllers/test_controller.rb +0 -27
- data/spec/dummy/app/helpers/application_helper.rb +0 -18
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/mailers/pdf_emailer.rb +0 -14
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/super_model.rb +0 -8
- data/spec/dummy/app/views/layouts/application.html.erb +0 -23
- data/spec/dummy/app/views/pdf_emailer/email_with_attachment.text.erb +0 -1
- data/spec/dummy/app/views/test/_simple_partial.pdf.prawn +0 -1
- data/spec/dummy/app/views/test/default_render.pdf.prawn +0 -3
- data/spec/dummy/app/views/test/dsl_render.pdf.prawn +0 -3
- data/spec/dummy/app/views/test/instance_var_test.pdf.prawn +0 -15
- data/spec/dummy/app/views/test/partial_render.pdf.prawn +0 -3
- data/spec/dummy/app/views/test/yield_block_in_helper_test.pdf.prawn +0 -4
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -49
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -30
- data/spec/dummy/config/environments/production.rb +0 -60
- data/spec/dummy/config/environments/test.rb +0 -39
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/inflections.rb +0 -10
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -9
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -26
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/delayed_job +0 -5
- data/spec/dummy/script/rails +0 -6
- data/spec/integrations/pdf_emailer_spec.rb +0 -21
- data/spec/integrations/super_model_spec.rb +0 -16
- data/spec/integrations/test_controller_spec.rb +0 -51
- data/spec/spec_helper.rb +0 -32
- data/spec/units/action_controller_mixin_spec.rb +0 -48
- data/spec/units/compile_support_spec.rb +0 -50
- data/spec/units/template_handlers/partials_spec.rb +0 -68
- data/spec/units/template_handlers/renderer_spec.rb +0 -4
data/spec/dummy/public/422.html
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/422.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The change you wanted was rejected.</h1>
|
23
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
data/spec/dummy/public/500.html
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/500.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>We're sorry, but something went wrong.</h1>
|
23
|
-
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
File without changes
|
data/spec/dummy/script/rails
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
-
|
4
|
-
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
-
require File.expand_path('../../config/boot', __FILE__)
|
6
|
-
require 'rails/commands'
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require File.expand_path("../spec_helper.rb", File.dirname(__FILE__))
|
2
|
-
|
3
|
-
describe PdfEmailer do
|
4
|
-
describe "email_with_attachment" do
|
5
|
-
before(:all) do
|
6
|
-
@email = PdfEmailer.email_with_attachment.deliver
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should have the plain text on the body" do
|
10
|
-
@email.encoded.should include "text\/plain"
|
11
|
-
@email.encoded.should include "Please see attached PDF"
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should have the PDF attached" do
|
15
|
-
@email.encoded.should include "application\/pdf"
|
16
|
-
@email.encoded.should include "Content-Disposition: attachment;"
|
17
|
-
@email.encoded.should include "filename=hello_world.pdf"
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require File.expand_path("../spec_helper.rb", File.dirname(__FILE__))
|
2
|
-
|
3
|
-
describe SuperModel do
|
4
|
-
|
5
|
-
describe "#to_pdf" do
|
6
|
-
before do
|
7
|
-
@model = SuperModel.new
|
8
|
-
end
|
9
|
-
|
10
|
-
it do
|
11
|
-
asset_binary = File.open(asset_path('default_render')).read.bytes.to_a
|
12
|
-
@model.to_pdf.bytes.to_a.should == asset_binary
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require File.expand_path("../spec_helper.rb", File.dirname(__FILE__))
|
2
|
-
|
3
|
-
describe TestController do
|
4
|
-
|
5
|
-
describe "simple" do
|
6
|
-
it "returns correct PDF" do
|
7
|
-
get "/default_render.pdf"
|
8
|
-
response.should be_success
|
9
|
-
|
10
|
-
asset_binary = File.open(asset_path("default_render")).read.bytes.to_a
|
11
|
-
body_binary = response.body.bytes.to_a
|
12
|
-
body_binary.should == asset_binary
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
it "shares values/changes of instance vars between view and helpers" do
|
17
|
-
expect { get "/instance_var_test.pdf" }.should_not raise_error
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should render items in a block passed to a helper" do
|
21
|
-
get "/yield_block_in_helper_test.pdf"
|
22
|
-
asset_binary = File.open(asset_path("yield_block_in_helper_test")).read.bytes.to_a
|
23
|
-
body_binary = response.body.bytes.to_a
|
24
|
-
body_binary.should == asset_binary
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
describe "dsl" do
|
30
|
-
it "returns correct PDF" do
|
31
|
-
get "/dsl_render.pdf"
|
32
|
-
response.should be_success
|
33
|
-
|
34
|
-
asset_binary = File.open(asset_path("dsl_render")).read.bytes.to_a
|
35
|
-
body_binary = response.body.bytes.to_a
|
36
|
-
body_binary.should == asset_binary
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "partials" do
|
41
|
-
it "renders partials" do
|
42
|
-
get "/partial_render.pdf"
|
43
|
-
response.should be_success
|
44
|
-
|
45
|
-
asset_binary = File.open(asset_path("partial_render")).read.bytes.to_a
|
46
|
-
body_binary = response.body.bytes.to_a
|
47
|
-
body_binary.should == asset_binary
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'spork'
|
3
|
-
|
4
|
-
Spork.prefork do
|
5
|
-
# Configure Rails Environment
|
6
|
-
ENV["RAILS_ENV"] = "test"
|
7
|
-
|
8
|
-
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
9
|
-
require 'rspec/rails'
|
10
|
-
|
11
|
-
Rails.backtrace_cleaner.remove_silencers!
|
12
|
-
|
13
|
-
RSpec.configure do |config|
|
14
|
-
config.mock_with :mocha
|
15
|
-
|
16
|
-
config.infer_base_class_for_anonymous_controllers = false
|
17
|
-
end
|
18
|
-
|
19
|
-
TEST_ASSETS = File.expand_path("assets", File.dirname(__FILE__)).to_s
|
20
|
-
end
|
21
|
-
|
22
|
-
Spork.each_run do
|
23
|
-
# This code will be run each time you run your specs.
|
24
|
-
end
|
25
|
-
|
26
|
-
# Helper to provide asset path given the "base name" of the file.
|
27
|
-
# For example, if +file+ is "default_render", asset_path returns
|
28
|
-
# "/path/to/prawnto/spec/assets/default_render-#{prawn version}.pdf"
|
29
|
-
def asset_path(file)
|
30
|
-
prawn_version = Gem.loaded_specs["prawn"].version.to_s.inspect
|
31
|
-
TEST_ASSETS + "/#{file}-#{prawn_version.gsub('"','')}.pdf"
|
32
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe TestController do
|
4
|
-
|
5
|
-
class PrawntoControllerWithInlineTrue < TestController
|
6
|
-
prawnto :inline=>true, :prawn=>{:page_orientation=>:landscape}
|
7
|
-
end
|
8
|
-
|
9
|
-
it "Controller should start with the defaults" do
|
10
|
-
@controller = TestController.new
|
11
|
-
@controller.send(:compute_prawnto_options).should == {:inline=>true, :prawn => {}}
|
12
|
-
end
|
13
|
-
|
14
|
-
describe ".prawnto" do
|
15
|
-
it "should store prawn_hash" do
|
16
|
-
PrawntoControllerWithInlineTrue.prawn_hash.should == {:page_orientation=>:landscape}
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should store prawnto_hash" do
|
20
|
-
PrawntoControllerWithInlineTrue.prawnto_hash.should == {:inline=>true}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#prawnto" do
|
25
|
-
before do
|
26
|
-
@controller = TestController.new
|
27
|
-
@controller.send(:prawnto, {:inline=>false})
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should affect that controller" do
|
31
|
-
@controller.send(:compute_prawnto_options).should == {:inline=>false, :prawn => {}}
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should not affect the controller class" do
|
35
|
-
PrawntoControllerWithInlineTrue.new.send(:compute_prawnto_options).should == {:inline=>true, :prawn=>{:page_orientation=>:landscape}}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "#compute_prawnto_options" do
|
40
|
-
it "should merge the class settings and the instance settings" do
|
41
|
-
@controller = TestController.new
|
42
|
-
@controller.send(:prawnto, {:inline=>false, :prawn=>{:page_orientation=>:landscape, :page_size=>'A4'}})
|
43
|
-
@controller.send(:compute_prawnto_options).should == {:inline=>false, :prawn=>{:page_orientation=>:landscape, :page_size=>'A4'}}
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Prawnto::CompileSupport do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@request = mock()
|
7
|
-
@request.stubs(:ssl?).returns(false)
|
8
|
-
@headers = mock()
|
9
|
-
@controller = mock()
|
10
|
-
@controller.stubs(:request).returns(@request)
|
11
|
-
@controller.stubs(:headers).returns(@headers)
|
12
|
-
@controller.stubs(:compute_prawnto_options).returns({:inline => true})
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#set_disposition" do
|
16
|
-
before do
|
17
|
-
Prawnto::CompileSupport.any_instance.stubs(:set_pragma).returns(true)
|
18
|
-
Prawnto::CompileSupport.any_instance.stubs(:set_cache_control).returns(true)
|
19
|
-
Prawnto::CompileSupport.any_instance.stubs(:set_content_type).returns(Mime::PDF)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "default" do
|
23
|
-
@headers.expects("[]=").with("Content-Disposition", "inline").once
|
24
|
-
Prawnto::CompileSupport.new(@controller)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "inline with filename" do
|
28
|
-
@controller.stubs(:compute_prawnto_options).returns({:filename => "xxx.pdf", :inline => true})
|
29
|
-
@headers.expects("[]=").with("Content-Disposition", "inline;filename=\"xxx.pdf\"").once
|
30
|
-
Prawnto::CompileSupport.new(@controller)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "attachment with filename" do
|
34
|
-
@controller.stubs(:compute_prawnto_options).returns({:filename => "xxx.pdf", :inline => false})
|
35
|
-
@headers.expects("[]=").with("Content-Disposition", "attachment;filename=\"xxx.pdf\"").once
|
36
|
-
Prawnto::CompileSupport.new(@controller)
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "#set_pragma" do
|
42
|
-
pending
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#set_cache_control" do
|
46
|
-
pending
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "prawnto/template_handlers/partials.rb"
|
3
|
-
|
4
|
-
class PartialTester
|
5
|
-
attr_accessor :pdf
|
6
|
-
include Prawnto::TemplateHandlers::Partials
|
7
|
-
end
|
8
|
-
describe "Prawnto::TemplateHandlers::Partials" do
|
9
|
-
subject do
|
10
|
-
PartialTester.new
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#get_file_path" do
|
14
|
-
before { Rails.stubs(:root).returns("") }
|
15
|
-
|
16
|
-
it "should find partial in the same folder" do
|
17
|
-
Dir.expects("[]").with("/app/views/test/_p1.{*.}prawn").returns("some/path")
|
18
|
-
path = subject.send :get_file_path, "test/p1"
|
19
|
-
end
|
20
|
-
|
21
|
-
it "won't insert underscore if provided" do
|
22
|
-
Dir.expects("[]").with("/app/views/test/_p1.{*.}prawn").returns("some/path")
|
23
|
-
path = subject.send :get_file_path, "test/_p1"
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should look in the current folder first"
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "#partial_source" do
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "#render_partial" do
|
33
|
-
let(:prawn_object) { mock("prawn_object") }
|
34
|
-
let(:nested_prawn_object) { mock("nested_prawn_object") }
|
35
|
-
let(:prawn_document) {mock("prawn_document") }
|
36
|
-
before {
|
37
|
-
subject.stubs(:partial_source).returns("pdf.prawn_method")
|
38
|
-
subject.pdf = prawn_document
|
39
|
-
}
|
40
|
-
|
41
|
-
it "should default to rendering off the prawn document" do
|
42
|
-
prawn_document.expects(:prawn_method)
|
43
|
-
subject.partial! "some/path"
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should default to rendering off the prawn document" do
|
47
|
-
prawn_object.expects(:prawn_method)
|
48
|
-
subject.partial! "some/path", prawn_object
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should return to the original pdf object upon completion" do
|
52
|
-
prawn_object.stubs(:prawn_method)
|
53
|
-
subject.partial! "some/path", prawn_object
|
54
|
-
subject.pdf.should == prawn_document
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should handle nested partials" do
|
58
|
-
subject.stubs(:nested_prawn_object).returns(nested_prawn_object)
|
59
|
-
subject.stubs(:partial_source).with("partial1").returns("partial! 'partial2', nested_prawn_object")
|
60
|
-
subject.stubs(:partial_source).with("partial2").returns("pdf.nested_prawn_method")
|
61
|
-
|
62
|
-
nested_prawn_object.expects("nested_prawn_method")
|
63
|
-
subject.partial! "partial1", prawn_object
|
64
|
-
subject.pdf.should == prawn_document
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
end
|