receipts 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 875a1ff6a3a1dcca7a1de7c21362ce0837426c3f5b3299cd9f15f38daf97cfa2
4
- data.tar.gz: 2aed77f22588a1675b558eccbe1122cc94912e04fa692aacaa7a40b16429495e
3
+ metadata.gz: a0b0deba0350c50dd06db780729513d9c65d020c9d625b3c61c174078738ef44
4
+ data.tar.gz: 6b508e3232031df8d6952b9c2da80d5910022b2b53ba29e54f84080c12d522da
5
5
  SHA512:
6
- metadata.gz: f54fc0957bccf87ebd1ae377d275f9dfe0f39a8b2cd0e8c4b5a96635183abd24f229eea142631a98d5a61156fc87cd366864e35a044a53e60ec072de08ada3e5
7
- data.tar.gz: 87745a1fe2f9cb84c69a00d816e254c4cc7b2dfee02457ece89d9e543a39b65813bfd427e7fa789e5a56feea1a3837ac3e8cc5d4574e4894805b535de76cf630
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.0
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
- filename: "#{@charge.created_at.strftime("%Y-%m-%d")}-gorails-receipt.pdf",
200
- type: "application/pdf",
201
- disposition: :inline # or :attachment to download
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
@@ -8,7 +8,7 @@ module Receipts
8
8
 
9
9
  def initialize(attributes = {})
10
10
  super(page_size: "LETTER")
11
- setup_fonts attributes[:font]
11
+ setup_fonts attributes.fetch(:font, Receipts.default_font)
12
12
 
13
13
  @title = attributes.fetch(:title, self.class.title)
14
14
 
@@ -1,3 +1,3 @@
1
1
  module Receipts
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
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.0.0
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-01-30 00:00:00.000000000 Z
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.2.32
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.