prawn_rails 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
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
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
data/lib/prawn_rails.rb CHANGED
@@ -7,39 +7,39 @@ 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
-
36
+
37
37
  def self.call(template)
38
- "#{template.source.strip}.render"
38
+ "#{template.source.strip}"
39
39
  end
40
-
40
+
41
41
  end
42
-
42
+
43
43
  end
44
44
  end
45
45
 
data/prawn_rails.gemspec CHANGED
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{prawn_rails}
8
- s.version = "0.0.6"
7
+ s.name = "prawn_rails"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
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}
12
+ s.date = "2011-09-21"
13
+ s.description = "The prawn_rails gem provides a Prawn based view engine for creating PDFs with rails."
14
+ s.email = "me@waltonhoops.com"
15
15
  s.extra_rdoc_files = [
16
16
  "README.rdoc"
17
17
  ]
@@ -25,11 +25,11 @@ Gem::Specification.new do |s|
25
25
  "prawn_rails.gemspec",
26
26
  "rails/init.rb"
27
27
  ]
28
- s.homepage = %q{http://github.com/Volundr/prawn-rails}
28
+ s.homepage = "http://github.com/Volundr/prawn-rails"
29
29
  s.licenses = ["MIT"]
30
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}
31
+ s.rubygems_version = "1.8.10"
32
+ s.summary = "Integrates Prawn into Rails in a natural way"
33
33
 
34
34
  if s.respond_to? :specification_version then
35
35
  s.specification_version = 3
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn_rails
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 17
4
5
  prerelease:
5
- version: 0.0.6
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 7
10
+ version: 0.0.7
6
11
  platform: ruby
7
12
  authors:
8
13
  - Walton Hoops
@@ -10,8 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-08-14 00:00:00 -06:00
14
- default_executable:
18
+ date: 2011-09-21 00:00:00 Z
15
19
  dependencies:
16
20
  - !ruby/object:Gem::Dependency
17
21
  name: rails
@@ -21,6 +25,11 @@ dependencies:
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
28
+ hash: 7
29
+ segments:
30
+ - 3
31
+ - 0
32
+ - 0
24
33
  version: 3.0.0
25
34
  type: :runtime
26
35
  version_requirements: *id001
@@ -32,6 +41,11 @@ dependencies:
32
41
  requirements:
33
42
  - - ">="
34
43
  - !ruby/object:Gem::Version
44
+ hash: 49
45
+ segments:
46
+ - 0
47
+ - 11
48
+ - 1
35
49
  version: 0.11.1
36
50
  type: :runtime
37
51
  version_requirements: *id002
@@ -52,7 +66,6 @@ files:
52
66
  - lib/prawn_rails.rb
53
67
  - prawn_rails.gemspec
54
68
  - rails/init.rb
55
- has_rdoc: true
56
69
  homepage: http://github.com/Volundr/prawn-rails
57
70
  licenses:
58
71
  - MIT
@@ -66,17 +79,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
79
  requirements:
67
80
  - - ">="
68
81
  - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
69
85
  version: "0"
70
86
  required_rubygems_version: !ruby/object:Gem::Requirement
71
87
  none: false
72
88
  requirements:
73
89
  - - ">="
74
90
  - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
75
94
  version: "0"
76
95
  requirements: []
77
96
 
78
97
  rubyforge_project:
79
- rubygems_version: 1.6.2
98
+ rubygems_version: 1.8.10
80
99
  signing_key:
81
100
  specification_version: 3
82
101
  summary: Integrates Prawn into Rails in a natural way