prawn_rails 0.0.6 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 308a79f72f3ef76ee6432be41c4dc6ac934838a6500cf3cce68315a3ce958e80
4
+ data.tar.gz: 7b99bfc316e2e134b60eaaa5d2ecc6d2551a61caeadabd4d8c1672ebe36aa0e6
5
+ SHA512:
6
+ metadata.gz: 7a33a04da1ce34b72a7d81026415e0dad6d3517c794f19278f228bd5d50ce6f29f1ad68d74f5f23998ee25d0884dae45bdd8137d0e15c2cce42d5922a85906f1
7
+ data.tar.gz: 757c58daa2cef54ab93c697fde75f2daac55a6b8605de16608be92577b2ce3e3cdb5a2e0bb1bab99fcdd5eb30da77b20cc120c774c98d81416c2f5218f2b68a7
data/README.rdoc CHANGED
@@ -18,6 +18,8 @@ which will be used whenever the user requests a page with a 'pdf' extension
18
18
 
19
19
  == Usage
20
20
 
21
+ === Basic Usage
22
+
21
23
  Prawn::Rails is designed to provide only a very thin wrapper around Prawn itself. A Prawn::Rails view should consist of only a call to the function prawn_document and a block. This will create an instance of Prawn::Document and yield it to the block.
22
24
  For a simple pdf view try:
23
25
 
@@ -29,6 +31,26 @@ views/.../simple.pdf.prawn
29
31
 
30
32
  This will create a simple PDF with only the text Hello World.
31
33
 
34
+ === Partials
35
+
36
+ While layouts do not yet work with Prawn::Rails, partials work fine. Rendering a partial is much like in a normal view. For example:
37
+
38
+ views/.../partial.pdf.prawn
39
+
40
+ prawn_document do |pdf|
41
+ render "frontpage", :pdf => pdf
42
+ pdf.text "something else"
43
+ end
44
+
45
+ views/.../_frontpage.pdf.prawn
46
+
47
+ pdf.text "frontpage action!!"
48
+ pdf.start_new_page
49
+
50
+ As you might expect this will result in a pdf with a leading page.
51
+
52
+ === Instance Variables
53
+
32
54
  Like normal Rails views, instance variables assigned in the controller are made available in the view. For example:
33
55
 
34
56
  home_controller.rb
@@ -47,6 +69,8 @@ views/.../index.pdf.prawn
47
69
 
48
70
  This will produce a pdf with Jane, John, and Jack all written on seperate lines.
49
71
 
72
+ === Rendering Options
73
+
50
74
  Notice we passed a hash into prawn_document. Any parameters placed in this hash will be passed to the constructor of Prawn::Document, with a few exceptions. The :renderer, :force_download, and :filename options will not be passed on, but instead will be used as described below.
51
75
 
52
76
  The :renderer option will be removed before creating the document and can be used to override the class to be used for rendering with a subclass of Prawn::Document like so:
@@ -71,7 +95,9 @@ application_helper.rb
71
95
 
72
96
  This would generate a canned report with just the lines Foo and Bar.
73
97
 
74
- The :force_download option does makes the browser display a 'save as' dialog rather than attempting to display the content in browser (this is achieved by setting the Content-Dispoition header).
98
+ === Force Saving
99
+
100
+ The :force_download option makes the browser display a 'save as' dialog rather than attempting to display the content in browser (this is achieved by setting the Content-Dispoition header).
75
101
  Note: due to problems with the Acrobat Reader plugin, this defaults to true if the :filename option is used.
76
102
 
77
103
  views/.../saveas.pdf.prawn
@@ -99,7 +125,7 @@ The one major gotcha at this point is that layouts do not work. Do not attempt
99
125
 
100
126
  == Examples
101
127
 
102
- For examples see: http://prawn-rails-demo.heroku.com
128
+ For examples see: http://prawn-rails-demo.herokuapp.com
103
129
 
104
130
 
105
131
  Copyright (c) 2010 Walton Hoops, released under the MIT license
data/Rakefile CHANGED
@@ -5,14 +5,14 @@ Jeweler::Tasks.new do |gem|
5
5
  gem.name = "prawn_rails"
6
6
  gem.author = "Walton Hoops"
7
7
  gem.email = "me@waltonhoops.com"
8
- gem.homepage = "http://github.com/Volundr/prawn-rails"
8
+ gem.homepage = "http://github.com/Whoops/prawn-rails"
9
9
  gem.platform = Gem::Platform::RUBY
10
10
  gem.summary = "Integrates Prawn into Rails in a natural way"
11
11
  gem.description = "The prawn_rails gem provides a Prawn based view engine for creating PDFs with rails."
12
12
  gem.has_rdoc = false
13
13
  gem.extra_rdoc_files = ["README.rdoc"]
14
14
  gem.license = "MIT"
15
- gem.add_dependency('rails', '>=3.0.0')
15
+ gem.add_dependency('railties', '>=3.0.0')
16
16
  gem.add_dependency('prawn', '>=0.11.1')
17
17
  end
18
18
  Jeweler::RubygemsDotOrgTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.12
data/lib/prawn_rails.rb CHANGED
@@ -7,42 +7,46 @@ end
7
7
 
8
8
  module Prawn
9
9
  module Rails
10
-
10
+
11
11
  module PrawnHelper
12
-
12
+
13
13
  def prawn_document(opts={})
14
14
  download = opts.delete(:force_download)
15
15
  filename = opts.delete(:filename)
16
16
  pdf = (opts.delete(:renderer) || Prawn::Document).new(opts)
17
17
  yield pdf if block_given?
18
-
18
+
19
19
  disposition(download, filename) if (download || filename)
20
-
21
- pdf
20
+
21
+ pdf.render
22
22
  end
23
-
23
+
24
24
  def disposition(download, filename)
25
25
  download = true if (filename && download == nil)
26
26
  disposition = download ? "attachment;" : "inline;"
27
27
  disposition += " filename=\"#{filename}\"" if filename
28
28
  headers["Content-Disposition"] = disposition
29
29
  end
30
-
30
+
31
31
  end
32
-
32
+
33
33
  class TemplateHandler
34
34
  class_attribute :default_format
35
35
  self.default_format = :pdf
36
-
37
- def self.call(template)
38
- "#{template.source.strip}.render"
36
+
37
+ def self.call(template, source = nil)
38
+ if source
39
+ "#{source.strip}"
40
+ else
41
+ "#{template.source.strip}"
42
+ end
39
43
  end
40
-
44
+
41
45
  end
42
-
46
+
43
47
  end
44
48
  end
45
49
 
46
- Mime::Type.register_alias "application/pdf", :pdf
50
+ Mime::Type.register_alias("application/pdf", :pdf) unless Mime::Type.lookup_by_extension(:pdf)
47
51
  ActionView::Template.register_template_handler(:prawn, Prawn::Rails::TemplateHandler)
48
52
  ActionView::Base.send(:include, Prawn::Rails::PrawnHelper)
data/prawn_rails.gemspec CHANGED
@@ -2,16 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: prawn_rails 0.0.12 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
- s.name = %q{prawn_rails}
8
- s.version = "0.0.6"
8
+ s.name = "prawn_rails".freeze
9
+ s.version = "0.0.12"
9
10
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Walton Hoops"]
12
- s.date = %q{2011-08-14}
13
- s.description = %q{The prawn_rails gem provides a Prawn based view engine for creating PDFs with rails.}
14
- s.email = %q{me@waltonhoops.com}
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Walton Hoops".freeze]
14
+ s.date = "2021-07-07"
15
+ s.description = "The prawn_rails gem provides a Prawn based view engine for creating PDFs with rails.".freeze
16
+ s.email = "me@waltonhoops.com".freeze
15
17
  s.extra_rdoc_files = [
16
18
  "README.rdoc"
17
19
  ]
@@ -25,25 +27,21 @@ Gem::Specification.new do |s|
25
27
  "prawn_rails.gemspec",
26
28
  "rails/init.rb"
27
29
  ]
28
- s.homepage = %q{http://github.com/Volundr/prawn-rails}
29
- s.licenses = ["MIT"]
30
- s.require_paths = ["lib"]
31
- s.rubygems_version = %q{1.6.2}
32
- s.summary = %q{Integrates Prawn into Rails in a natural way}
30
+ s.homepage = "http://github.com/Whoops/prawn-rails".freeze
31
+ s.licenses = ["MIT".freeze]
32
+ s.rubygems_version = "3.2.21".freeze
33
+ s.summary = "Integrates Prawn into Rails in a natural way".freeze
33
34
 
34
35
  if s.respond_to? :specification_version then
35
- s.specification_version = 3
36
+ s.specification_version = 4
37
+ end
36
38
 
37
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
38
- s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
39
- s.add_runtime_dependency(%q<prawn>, [">= 0.11.1"])
40
- else
41
- s.add_dependency(%q<rails>, [">= 3.0.0"])
42
- s.add_dependency(%q<prawn>, [">= 0.11.1"])
43
- end
39
+ if s.respond_to? :add_runtime_dependency then
40
+ s.add_runtime_dependency(%q<railties>.freeze, [">= 3.0.0"])
41
+ s.add_runtime_dependency(%q<prawn>.freeze, [">= 0.11.1"])
44
42
  else
45
- s.add_dependency(%q<rails>, [">= 3.0.0"])
46
- s.add_dependency(%q<prawn>, [">= 0.11.1"])
43
+ s.add_dependency(%q<railties>.freeze, [">= 3.0.0"])
44
+ s.add_dependency(%q<prawn>.freeze, [">= 0.11.1"])
47
45
  end
48
46
  end
49
47
 
metadata CHANGED
@@ -1,49 +1,51 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: prawn_rails
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.12
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Walton Hoops
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-08-14 00:00:00 -06:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: rails
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
11
+ date: 2021-07-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
22
17
  - - ">="
23
- - !ruby/object:Gem::Version
18
+ - !ruby/object:Gem::Version
24
19
  version: 3.0.0
25
20
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: prawn
29
21
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: prawn
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
33
31
  - - ">="
34
- - !ruby/object:Gem::Version
32
+ - !ruby/object:Gem::Version
35
33
  version: 0.11.1
36
34
  type: :runtime
37
- version_requirements: *id002
38
- description: The prawn_rails gem provides a Prawn based view engine for creating PDFs with rails.
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.11.1
41
+ description: The prawn_rails gem provides a Prawn based view engine for creating PDFs
42
+ with rails.
39
43
  email: me@waltonhoops.com
40
44
  executables: []
41
-
42
45
  extensions: []
43
-
44
- extra_rdoc_files:
46
+ extra_rdoc_files:
45
47
  - README.rdoc
46
- files:
48
+ files:
47
49
  - MIT-LICENSE
48
50
  - README.rdoc
49
51
  - Rakefile
@@ -52,33 +54,27 @@ files:
52
54
  - lib/prawn_rails.rb
53
55
  - prawn_rails.gemspec
54
56
  - rails/init.rb
55
- has_rdoc: true
56
- homepage: http://github.com/Volundr/prawn-rails
57
- licenses:
57
+ homepage: http://github.com/Whoops/prawn-rails
58
+ licenses:
58
59
  - MIT
59
- post_install_message:
60
+ metadata: {}
61
+ post_install_message:
60
62
  rdoc_options: []
61
-
62
- require_paths:
63
+ require_paths:
63
64
  - lib
64
- required_ruby_version: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
67
  - - ">="
68
- - !ruby/object:Gem::Version
69
- version: "0"
70
- required_rubygems_version: !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
73
72
  - - ">="
74
- - !ruby/object:Gem::Version
75
- version: "0"
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
76
75
  requirements: []
77
-
78
- rubyforge_project:
79
- rubygems_version: 1.6.2
80
- signing_key:
81
- specification_version: 3
76
+ rubygems_version: 3.2.21
77
+ signing_key:
78
+ specification_version: 4
82
79
  summary: Integrates Prawn into Rails in a natural way
83
80
  test_files: []
84
-