prawn_cocktail 0.0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -13,7 +13,7 @@ NOTE: Work in progress; well used but untested.
13
13
  ## TODO
14
14
 
15
15
  * Tests.
16
- * Look into what dependencies to declare. Rails? Active Support?
16
+ * Syntax to declare page size shorthands?
17
17
  * Include instead of inherit? Consider `class_attribute`.
18
18
 
19
19
  ## Usage
@@ -23,7 +23,7 @@ NOTE: Work in progress; well used but untested.
23
23
  Your controllers get a `send_pdf` method:
24
24
 
25
25
  ``` ruby
26
- class InvoiceController < ApplicationController
26
+ class InvoicesController < ApplicationController
27
27
  def show
28
28
  invoice = Invoice.find(params[:id])
29
29
  document = InvoiceDocument.new(invoice)
@@ -32,7 +32,7 @@ class InvoiceController < ApplicationController
32
32
  end
33
33
  ```
34
34
 
35
- ### View
35
+ ### Document/view
36
36
 
37
37
  Against Rails conventions, but in line with the idea of [two-step views](http://martinfowler.com/eaaCatalog/twoStepView.html), we think of these as "views" as opposed to "templates".
38
38
 
@@ -73,15 +73,15 @@ If the data becomes complex, you are advised to extract one or many builder clas
73
73
  Put the Prawn code in a template named after the view:
74
74
 
75
75
  ``` ruby
76
- # app/documents/views/invoice_document.pdf.rb
76
+ # app/views/documents/invoice_document.pdf.rb
77
77
 
78
78
  meta page_size: "A4"
79
79
 
80
80
  content do |data|
81
81
  text "Invoice #{data.number}"
82
- move_down 1.cm
82
+ move_down 10
83
83
  text "Amount: #{data.amount}"
84
- move_down 1.cm
84
+ move_down 10
85
85
  text data.customer_name
86
86
  end
87
87
  ```
@@ -104,7 +104,7 @@ end
104
104
  ```
105
105
 
106
106
  ``` ruby
107
- # app/documents/views/invoice_document.pdf.rb
107
+ # app/views/documents/invoice_document.pdf.rb
108
108
 
109
109
  content do |data|
110
110
  common_header
@@ -133,20 +133,18 @@ If you want to run some code in every document, use an `initialize_document` blo
133
133
  ``` ruby
134
134
  class BaseDocument < PrawnCocktail::Document
135
135
  initialize_document do
136
- FONT_DIR ||= Rails.root.join("app/views/documents/fonts")
137
-
138
- font_families.update(
139
- "Helvetica Neue" => {
140
- bold: FONT_DIR.join("HelveticaNeueLTCom-Md.ttf").to_s,
141
- normal: FONT_DIR.join("HelveticaNeueLTCom-Lt.ttf").to_s
142
- })
143
-
144
- font "Helvetica Neue"
136
+ font "Courier"
145
137
  end
146
138
  end
147
139
  ```
148
140
 
149
- This is incidentally how helper modules are implemented. They simply extend the document instance in such a block.
141
+ This is incidentally how helpers are implemented:
142
+
143
+ ```
144
+ def self.helper(mod)
145
+ initialize_document { extend mod }
146
+ end
147
+ ```
150
148
 
151
149
  ## Installation
152
150
 
@@ -48,7 +48,7 @@ module PrawnCocktail
48
48
  end
49
49
 
50
50
  def template_path
51
- "app/documents/views/#{@template}.pdf.rb"
51
+ "app/views/documents/#{@template}.pdf.rb"
52
52
  end
53
53
 
54
54
  def app_root
@@ -1,3 +1,3 @@
1
1
  module PrawnCocktail
2
- VERSION = "0.0.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -17,4 +17,5 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ["lib"]
18
18
 
19
19
  gem.add_dependency "prawn"
20
+ gem.add_dependency "rails"
20
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn_cocktail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-18 00:00:00.000000000 Z
12
+ date: 2013-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: prawn
16
- requirement: &70234014918140 !ruby/object:Gem::Requirement
16
+ requirement: &70299039222780 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,18 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70234014918140
24
+ version_requirements: *70299039222780
25
+ - !ruby/object:Gem::Dependency
26
+ name: rails
27
+ requirement: &70299039222180 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70299039222180
25
36
  description:
26
37
  email:
27
38
  - henrik@barsoom.se