prawnto_2 0.2.0.beta3 → 0.2.0.beta4
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.
- data/.travis.yml +3 -0
- data/README.rdoc +9 -2
- data/lib/prawnto/model_renderer.rb +14 -5
- data/prawnto.gemspec +1 -1
- data/spec/dummy/app/models/super_model.rb +1 -1
- metadata +6 -5
data/.travis.yml
ADDED
data/README.rdoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
= Prawnto (prawnto_2)
|
2
2
|
|
3
|
+
{<img src="https://secure.travis-ci.org/forrest/prawnto.png" />}[http://travis-ci.org/forrest/prawnto]
|
4
|
+
|
3
5
|
A rails plugin providing templating abilities for generating pdf files leveraging the kick-ass prawn library (http://prawn.majesticseacreature.com/)
|
4
6
|
|
5
7
|
This is my attempt to merge the various forks of the prawnto gem, and <b>update it for Rails 3.1+</b>. I want to thank the many developers who's code I collected together for the gem. Main credit goes to the developer of the initial Prawnto plugin - smecsia.
|
@@ -23,8 +25,10 @@ Then run:
|
|
23
25
|
Now make a view:
|
24
26
|
|
25
27
|
<action name>.pdf.prawn
|
28
|
+
|
29
|
+
---
|
26
30
|
|
27
|
-
|
31
|
+
= Usage
|
28
32
|
|
29
33
|
More Details will be coming to {wiki}[http://github.com/forrest/prawnto/wiki].
|
30
34
|
|
@@ -62,10 +66,13 @@ Sometimes you need to be able to render a PDF from anywhere (Background process
|
|
62
66
|
...
|
63
67
|
def to_pdf
|
64
68
|
@x = 1
|
65
|
-
Prawnto::ModelRenderer.to_string "test/default_render", self
|
69
|
+
Prawnto::ModelRenderer.to_string "test/default_render.pdf", self
|
66
70
|
end
|
67
71
|
end
|
68
72
|
|
73
|
+
<b>Gotcha:</b> Rails isn't always using the correct formatting. If you're having troubles, add the <code>.pdf</code> to the end of the requested template.
|
74
|
+
|
75
|
+
---
|
69
76
|
|
70
77
|
== Tips
|
71
78
|
|
@@ -1,17 +1,26 @@
|
|
1
1
|
module Prawnto
|
2
2
|
module ModelRenderer
|
3
|
+
|
4
|
+
class CustomController < ApplicationController
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
self.request = ActionDispatch::Request.new({})
|
8
|
+
self.response = ActionDispatch::Response.new()
|
9
|
+
self.params = {:format => :pdf}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
3
13
|
# template : invoices/show.pdf
|
4
14
|
# instance_variables : {"@account" => account} - variables set in before filters
|
5
15
|
def self.to_string(template, calling_object = nil)
|
6
|
-
instance =
|
7
|
-
|
8
|
-
instance.response = ActionDispatch::Response.new()
|
9
|
-
|
16
|
+
instance = CustomController.new
|
17
|
+
|
10
18
|
if calling_object
|
11
19
|
instance.prawnto :inline => true, :instance_variables_from => calling_object
|
12
20
|
end
|
13
21
|
|
14
|
-
return instance.render_to_string(template, :template => false).html_safe
|
22
|
+
return instance.render_to_string(:action => template, :template => false, :format => :pdf).html_safe
|
15
23
|
end
|
24
|
+
|
16
25
|
end
|
17
26
|
end
|
data/prawnto.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prawnto_2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.beta4
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-01-22 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70215973019900 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70215973019900
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: prawn
|
27
|
-
requirement: &
|
27
|
+
requirement: &70215973019200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 0.12.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70215973019200
|
36
36
|
description: Simple PDF generation using the prawn library.
|
37
37
|
email:
|
38
38
|
- development@forrestzeisler.com
|
@@ -42,6 +42,7 @@ extra_rdoc_files:
|
|
42
42
|
- README.rdoc
|
43
43
|
files:
|
44
44
|
- .gitignore
|
45
|
+
- .travis.yml
|
45
46
|
- Gemfile
|
46
47
|
- MIT-LICENSE
|
47
48
|
- README.rdoc
|