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.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README.rdoc +15 -16
  4. data/Rakefile +1 -8
  5. data/lib/prawnto.rb +1 -0
  6. data/lib/prawnto/compile_support.rb +10 -5
  7. data/lib/prawnto/model_renderer.rb +3 -2
  8. data/lib/prawnto/template_handlers/base.rb +4 -5
  9. data/lib/prawnto/template_handlers/partials.rb +11 -3
  10. metadata +60 -165
  11. data/.gitignore +0 -8
  12. data/.travis.yml +0 -3
  13. data/Appraisals +0 -7
  14. data/Gemfile +0 -13
  15. data/Guardfile +0 -15
  16. data/prawnto.gemspec +0 -22
  17. data/rails/init.rb +0 -1
  18. data/script/rails +0 -6
  19. data/spec/assets/default_render-0.12.0.pdf +0 -83
  20. data/spec/assets/default_render-0.6.3.pdf +0 -85
  21. data/spec/assets/dsl_render-0.12.0.pdf +0 -83
  22. data/spec/assets/dsl_render-0.6.3.pdf +0 -85
  23. data/spec/assets/partial_render-0.12.0.pdf +0 -83
  24. data/spec/assets/partial_render-0.6.3.pdf +0 -85
  25. data/spec/assets/yield_block_in_helper_test-0.12.0.pdf +0 -76
  26. data/spec/assets/yield_block_in_helper_test-0.6.3.pdf +0 -78
  27. data/spec/dummy/.rspec +0 -1
  28. data/spec/dummy/.sass-cache/387f7b3fde13680ae5a79212c089f81d2d418f1e/application.css.scssc +0 -0
  29. data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/_shared.css.scssc +0 -0
  30. data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/ab_tests.css.scssc +0 -0
  31. data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/application.css.scssc +0 -0
  32. data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/metrics.css.scssc +0 -0
  33. data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/reports.css.scssc +0 -0
  34. data/spec/dummy/Rakefile +0 -7
  35. data/spec/dummy/app/assets/javascripts/application.js +0 -10
  36. data/spec/dummy/app/assets/javascripts/highcharts.js +0 -170
  37. data/spec/dummy/app/assets/stylesheets/application.css.scss +0 -78
  38. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  39. data/spec/dummy/app/controllers/test_controller.rb +0 -27
  40. data/spec/dummy/app/helpers/application_helper.rb +0 -18
  41. data/spec/dummy/app/mailers/.gitkeep +0 -0
  42. data/spec/dummy/app/mailers/pdf_emailer.rb +0 -14
  43. data/spec/dummy/app/models/.gitkeep +0 -0
  44. data/spec/dummy/app/models/super_model.rb +0 -8
  45. data/spec/dummy/app/views/layouts/application.html.erb +0 -23
  46. data/spec/dummy/app/views/pdf_emailer/email_with_attachment.text.erb +0 -1
  47. data/spec/dummy/app/views/test/_simple_partial.pdf.prawn +0 -1
  48. data/spec/dummy/app/views/test/default_render.pdf.prawn +0 -3
  49. data/spec/dummy/app/views/test/dsl_render.pdf.prawn +0 -3
  50. data/spec/dummy/app/views/test/instance_var_test.pdf.prawn +0 -15
  51. data/spec/dummy/app/views/test/partial_render.pdf.prawn +0 -3
  52. data/spec/dummy/app/views/test/yield_block_in_helper_test.pdf.prawn +0 -4
  53. data/spec/dummy/config.ru +0 -4
  54. data/spec/dummy/config/application.rb +0 -49
  55. data/spec/dummy/config/boot.rb +0 -10
  56. data/spec/dummy/config/environment.rb +0 -5
  57. data/spec/dummy/config/environments/development.rb +0 -30
  58. data/spec/dummy/config/environments/production.rb +0 -60
  59. data/spec/dummy/config/environments/test.rb +0 -39
  60. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  61. data/spec/dummy/config/initializers/inflections.rb +0 -10
  62. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  63. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  64. data/spec/dummy/config/initializers/session_store.rb +0 -8
  65. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  66. data/spec/dummy/config/locales/en.yml +0 -5
  67. data/spec/dummy/config/routes.rb +0 -9
  68. data/spec/dummy/lib/assets/.gitkeep +0 -0
  69. data/spec/dummy/public/404.html +0 -26
  70. data/spec/dummy/public/422.html +0 -26
  71. data/spec/dummy/public/500.html +0 -26
  72. data/spec/dummy/public/favicon.ico +0 -0
  73. data/spec/dummy/script/delayed_job +0 -5
  74. data/spec/dummy/script/rails +0 -6
  75. data/spec/integrations/pdf_emailer_spec.rb +0 -21
  76. data/spec/integrations/super_model_spec.rb +0 -16
  77. data/spec/integrations/test_controller_spec.rb +0 -51
  78. data/spec/spec_helper.rb +0 -32
  79. data/spec/units/action_controller_mixin_spec.rb +0 -48
  80. data/spec/units/compile_support_spec.rb +0 -50
  81. data/spec/units/template_handlers/partials_spec.rb +0 -68
  82. data/spec/units/template_handlers/renderer_spec.rb +0 -4
@@ -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>
@@ -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
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
4
- require 'delayed/command'
5
- Delayed::Command.new(ARGV).daemonize
@@ -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
@@ -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
@@ -1,4 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Prawnto::TemplateHandlers::Renderer do
4
- end