prawnto_2 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README.rdoc +14 -15
  4. data/Rakefile +1 -8
  5. data/lib/prawnto.rb +1 -0
  6. data/lib/prawnto/compile_support.rb +1 -1
  7. metadata +44 -179
  8. data/.gitignore +0 -8
  9. data/.travis.yml +0 -5
  10. data/Appraisals +0 -7
  11. data/Gemfile +0 -13
  12. data/Guardfile +0 -15
  13. data/prawnto.gemspec +0 -22
  14. data/rails/init.rb +0 -1
  15. data/script/rails +0 -6
  16. data/spec/assets/1.8/default_render-0.12.0.pdf +0 -83
  17. data/spec/assets/1.8/default_render-0.6.3.pdf +0 -83
  18. data/spec/assets/1.8/dsl_render-0.12.0.pdf +0 -83
  19. data/spec/assets/1.8/dsl_render-0.6.3.pdf +0 -85
  20. data/spec/assets/1.8/partial_render-0.12.0.pdf +0 -83
  21. data/spec/assets/1.8/partial_render-0.6.3.pdf +0 -85
  22. data/spec/assets/1.8/yield_block_in_helper_test-0.12.0.pdf +0 -76
  23. data/spec/assets/1.8/yield_block_in_helper_test-0.6.3.pdf +0 -78
  24. data/spec/assets/1.9/default_render-0.12.0.pdf +0 -83
  25. data/spec/assets/1.9/default_render-0.6.3.pdf +0 -85
  26. data/spec/assets/1.9/dsl_render-0.12.0.pdf +0 -83
  27. data/spec/assets/1.9/dsl_render-0.6.3.pdf +0 -85
  28. data/spec/assets/1.9/partial_render-0.12.0.pdf +0 -83
  29. data/spec/assets/1.9/partial_render-0.6.3.pdf +0 -85
  30. data/spec/assets/1.9/yield_block_in_helper_test-0.12.0.pdf +0 -76
  31. data/spec/assets/1.9/yield_block_in_helper_test-0.6.3.pdf +0 -78
  32. data/spec/dummy/.rspec +0 -1
  33. data/spec/dummy/.sass-cache/387f7b3fde13680ae5a79212c089f81d2d418f1e/application.css.scssc +0 -0
  34. data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/_shared.css.scssc +0 -0
  35. data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/ab_tests.css.scssc +0 -0
  36. data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/application.css.scssc +0 -0
  37. data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/metrics.css.scssc +0 -0
  38. data/spec/dummy/.sass-cache/6a18c557e07dbc07a14d0809be02d4f21f1dbe91/reports.css.scssc +0 -0
  39. data/spec/dummy/Rakefile +0 -7
  40. data/spec/dummy/app/assets/javascripts/application.js +0 -10
  41. data/spec/dummy/app/assets/javascripts/highcharts.js +0 -170
  42. data/spec/dummy/app/assets/stylesheets/application.css.scss +0 -78
  43. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  44. data/spec/dummy/app/controllers/test_controller.rb +0 -32
  45. data/spec/dummy/app/helpers/application_helper.rb +0 -18
  46. data/spec/dummy/app/mailers/.gitkeep +0 -0
  47. data/spec/dummy/app/mailers/pdf_emailer.rb +0 -14
  48. data/spec/dummy/app/models/.gitkeep +0 -0
  49. data/spec/dummy/app/models/super_model.rb +0 -8
  50. data/spec/dummy/app/views/layouts/application.html.erb +0 -23
  51. data/spec/dummy/app/views/pdf_emailer/email_with_attachment.text.erb +0 -1
  52. data/spec/dummy/app/views/test/_simple_partial.pdf.prawn +0 -1
  53. data/spec/dummy/app/views/test/default_render.pdf.prawn +0 -3
  54. data/spec/dummy/app/views/test/dsl_render.pdf.prawn +0 -3
  55. data/spec/dummy/app/views/test/instance_var_test.pdf.prawn +0 -15
  56. data/spec/dummy/app/views/test/partial_render.pdf.prawn +0 -3
  57. data/spec/dummy/app/views/test/yield_block_in_helper_test.pdf.prawn +0 -4
  58. data/spec/dummy/config.ru +0 -4
  59. data/spec/dummy/config/application.rb +0 -49
  60. data/spec/dummy/config/boot.rb +0 -10
  61. data/spec/dummy/config/environment.rb +0 -5
  62. data/spec/dummy/config/environments/development.rb +0 -30
  63. data/spec/dummy/config/environments/production.rb +0 -60
  64. data/spec/dummy/config/environments/test.rb +0 -39
  65. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  66. data/spec/dummy/config/initializers/inflections.rb +0 -10
  67. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  68. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  69. data/spec/dummy/config/initializers/session_store.rb +0 -8
  70. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  71. data/spec/dummy/config/locales/en.yml +0 -5
  72. data/spec/dummy/config/routes.rb +0 -8
  73. data/spec/dummy/lib/assets/.gitkeep +0 -0
  74. data/spec/dummy/public/404.html +0 -26
  75. data/spec/dummy/public/422.html +0 -26
  76. data/spec/dummy/public/500.html +0 -26
  77. data/spec/dummy/public/favicon.ico +0 -0
  78. data/spec/dummy/public/index.html +0 -13
  79. data/spec/dummy/script/delayed_job +0 -5
  80. data/spec/dummy/script/rails +0 -6
  81. data/spec/integrations/pdf_emailer_spec.rb +0 -21
  82. data/spec/integrations/super_model_spec.rb +0 -16
  83. data/spec/integrations/test_controller_spec.rb +0 -60
  84. data/spec/spec_helper.rb +0 -33
  85. data/spec/units/action_controller_mixin_spec.rb +0 -48
  86. data/spec/units/compile_support_spec.rb +0 -50
  87. data/spec/units/template_handlers/partials_spec.rb +0 -68
  88. data/spec/units/template_handlers/renderer_spec.rb +0 -4
@@ -1,10 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new inflection rules using the following format
4
- # (all these examples are active by default):
5
- # ActiveSupport::Inflector.inflections do |inflect|
6
- # inflect.plural /^(ox)$/i, '\1en'
7
- # inflect.singular /^(ox)en/i, '\1'
8
- # inflect.irregular 'person', 'people'
9
- # inflect.uncountable %w( fish sheep )
10
- # end
@@ -1,5 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new mime types for use in respond_to blocks:
4
- # Mime::Type.register "text/richtext", :rtf
5
- # Mime::Type.register_alias "text/html", :iphone
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = '8f4cbaa2b5177e95c5ec90b258ddd53b6c7efdcb4fa0a5bb098f5fd9d034b82ad56889231e2c2cdba5dc821042bdc4f9919cb94f1522b49f4e1a0a08d6b2d166'
@@ -1,8 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
4
-
5
- # Use the database for sessions instead of the cookie-based default,
6
- # which shouldn't be used to store highly confidential information
7
- # (create the session table with "rails generate session_migration")
8
- # Dummy::Application.config.session_store :active_record_store
@@ -1,14 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
- #
3
- # This file contains settings for ActionController::ParamsWrapper which
4
- # is enabled by default.
5
-
6
- # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
- ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters :format => [:json]
9
- end
10
-
11
- # Disable root element in JSON by default.
12
- ActiveSupport.on_load(:active_record) do
13
- self.include_root_in_json = false
14
- end
@@ -1,5 +0,0 @@
1
- # Sample localization file for English. Add more files in this directory for other locales.
2
- # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
-
4
- en:
5
- hello: "Hello world"
@@ -1,8 +0,0 @@
1
- Rails.application.routes.draw do
2
- get "/default_render" => "test#default_render"
3
- get "/partial_render" => "test#partial_render"
4
- get "/dsl_render" => "test#dsl_render"
5
- get "/instance_var_test" => "test#instance_var_test"
6
- get "/yield_block_in_helper_test" => "test#yield_block_in_helper_test"
7
- get "/filename_test" => "test#filename_test"
8
- end
File without changes
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</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/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -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,13 +0,0 @@
1
- <html>
2
- <head></head>
3
- <body>
4
- <h1>Prawnto_2 test methods</h1>
5
-
6
- <a href="/default_render.pdf">default_render</a><br/>
7
- <a href="/partial_render.pdf">partial_render</a><br/>
8
- <a href="/dsl_render.pdf">dsl_render</a><br/>
9
- <a href="/instance_var_test.pdf">instance_var_test</a><br/>
10
- <a href="/yield_block_in_helper_test.pdf">yield_block_in_helper_test</a><br/>
11
- <a href="/filename_test.pdf">filename_test</a><br/>
12
- </body>
13
- </html>
@@ -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,60 +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
- describe "complex headers" do
52
- it "should return a file with a specified filename" do
53
- get "/filename_test.pdf"
54
- response.should be_success
55
- response.header["Content-Disposition"].should == "attachment;filename=\"fancy_name.pdf\""
56
- end
57
-
58
- end
59
-
60
- end
@@ -1,33 +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
- ruby_version_folder = RUBY_VERSION.split(".")[0..1].join(".")
32
- TEST_ASSETS + "/#{ruby_version_folder}/#{file}-#{prawn_version.gsub('"','')}.pdf"
33
- 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