receipts 2.0.0 → 2.1.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +18 -6
- data/lib/receipts/base.rb +1 -1
- data/lib/receipts/version.rb +1 -1
- data/lib/receipts.rb +15 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0b0deba0350c50dd06db780729513d9c65d020c9d625b3c61c174078738ef44
|
4
|
+
data.tar.gz: 6b508e3232031df8d6952b9c2da80d5910022b2b53ba29e54f84080c12d522da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f734ad542b0405e91370fd960ab93283bd493cdd0523900b6f97a26f91bc8a57834512c7778c551af55e1208c232020743d39b73428bafe118679439838479f0
|
7
|
+
data.tar.gz: baca857094d744fa1ff47617940a9a665df5fc7da11ebc25e4ac180b9a324b1f00f82f85cfbba09952708e596cbdbe425d73abfab4371f319e7882e3d8dac59e
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
### Unreleased
|
2
2
|
|
3
|
+
### 2.1.0
|
4
|
+
|
5
|
+
* Add `Receipts.default_font` - @excid3
|
6
|
+
|
3
7
|
### 2.0.0
|
4
8
|
|
5
9
|
* New, consistent layouts between Receipts, Invoices, and Statements - @excid3
|
6
10
|
* PDFs can now be completely customized - @excid3
|
7
11
|
* Add line_items to Receipts - @excid3
|
8
12
|
|
9
|
-
### 1.2
|
13
|
+
### 1.1.2
|
10
14
|
|
11
15
|
* Update design to give more room for longer product names, addresses, etc - @excid3
|
12
16
|
|
data/README.md
CHANGED
@@ -59,12 +59,24 @@ r = Receipts::Receipt.new(
|
|
59
59
|
)
|
60
60
|
|
61
61
|
# Returns a string of the raw PDF
|
62
|
-
r.render
|
62
|
+
r.render
|
63
63
|
|
64
64
|
# Writes the PDF to disk
|
65
65
|
r.render_file "examples/receipt.pdf"
|
66
66
|
```
|
67
67
|
|
68
|
+
### Configuration
|
69
|
+
|
70
|
+
You can specify the default font for all PDFs by defining the following in an initializer:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
Receipts.default_font = {
|
74
|
+
bold: Rails.root.join('app/assets/fonts/tradegothic/TradeGothic-Bold.ttf'),
|
75
|
+
normal: Rails.root.join('app/assets/fonts/tradegothic/TradeGothic.ttf'),
|
76
|
+
}
|
77
|
+
```
|
78
|
+
|
79
|
+
|
68
80
|
### Options
|
69
81
|
|
70
82
|
You can pass the following options to generate a PDF:
|
@@ -112,7 +124,7 @@ Here's an example of where each option is displayed.
|
|
112
124
|
|
113
125
|
### Formatting
|
114
126
|
|
115
|
-
`details` and `line_items` allow inline formatting with Prawn. This allows you to use HTML tags to format text: `<b>` `<i>` `<u>` `<strikethrough>` `<sub>` `<sup>` `<font>` `<color>` `<link>`
|
127
|
+
`details` and `line_items` allow inline formatting with Prawn. This allows you to use HTML tags to format text: `<b>` `<i>` `<u>` `<strikethrough>` `<sub>` `<sup>` `<font>` `<color>` `<link>`
|
116
128
|
|
117
129
|
See [the Prawn docs](https://prawnpdf.org/api-docs/2.3.0/Prawn/Text.html#text-instance_method) for more information.
|
118
130
|
|
@@ -192,13 +204,13 @@ class ChargesController < ApplicationController
|
|
192
204
|
def set_charge
|
193
205
|
@charge = current_user.charges.find(params[:id])
|
194
206
|
end
|
195
|
-
|
207
|
+
|
196
208
|
def send_pdf
|
197
209
|
# Render the PDF in memory and send as the response
|
198
210
|
send_data @charge.receipt.render,
|
199
|
-
|
200
|
-
|
201
|
-
|
211
|
+
filename: "#{@charge.created_at.strftime("%Y-%m-%d")}-gorails-receipt.pdf",
|
212
|
+
type: "application/pdf",
|
213
|
+
disposition: :inline # or :attachment to download
|
202
214
|
end
|
203
215
|
end
|
204
216
|
```
|
data/lib/receipts/base.rb
CHANGED
data/lib/receipts/version.rb
CHANGED
data/lib/receipts.rb
CHANGED
@@ -8,4 +8,19 @@ module Receipts
|
|
8
8
|
autoload :Invoice, "receipts/invoice"
|
9
9
|
autoload :Receipt, "receipts/receipt"
|
10
10
|
autoload :Statement, "receipts/statement"
|
11
|
+
|
12
|
+
@@default_font = nil
|
13
|
+
|
14
|
+
# Customize the default font hash
|
15
|
+
# default_font = {
|
16
|
+
# bold: "path/to/font",
|
17
|
+
# normal: "path/to/font",
|
18
|
+
# }
|
19
|
+
def self.default_font=(path)
|
20
|
+
@@default_font = path
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.default_font
|
24
|
+
@@default_font
|
25
|
+
end
|
11
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: receipts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prawn
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
|
-
rubygems_version: 3.
|
93
|
+
rubygems_version: 3.3.7
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Receipts for your Rails application that works with any payment provider.
|