invoice_printer 2.0.0.beta1 → 2.0.0.beta2

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: 1a929bb5d414cc64bf5f30a97baa8b7b39e9a3bb12eb03efe96eab827bc417b4
4
- data.tar.gz: a1ab11498fed952e4d008aa93d00e2ab2be4b73a65cb38d03e04aa226d027e5e
3
+ metadata.gz: 253de7f5df575343e45fad182f3a6e62fca98cac0758da832361f15b1a11ddbb
4
+ data.tar.gz: fe9755f88c5b148829050a565d9bcb043e3e1b36c64b7bbd2e5519fd3a4542fb
5
5
  SHA512:
6
- metadata.gz: e93b4d97f28e264dd6385776a49852614ad454fdbe80d00e2d66d3dd98c7614a9c74953a02d30744eb5a148ce250e6418c20a7107a32d0400062e5311f79ac49
7
- data.tar.gz: 2c1907bb3b0e0fc111139f9fdf808dd869c0dc41d359cee43cd1178919670c312be30361c362e74a0a76f8771b6d925a1edaff358348bba68676e3e821ec316b
6
+ metadata.gz: 4a603e7f39acc192dbd81efe372538df190ae4ac90eb15b0a8103477030663162bdcdfd5647cfc98455e756028109b5eb3c91e0a312e5862d72ea88d2a5f3b5e
7
+ data.tar.gz: 63e01b1748787113d5d70d4dca62aa20501588ae9b9a74fe1a8944d61a5c78e8a9c66a4208d5d78fa01ba0df1029b6ec4f01ae3b207eadf49d293bae9cea5c33
@@ -233,6 +233,8 @@ InvoicePrinter.print(
233
233
  )
234
234
  ```
235
235
 
236
+ If you don't have a font around, you can install `dejavu-fonts` gem and specify "dejavu" as the font path.
237
+
236
238
  We recommend you DejaVuSans and Overpass fonts.
237
239
 
238
240
  ### Background
@@ -94,11 +94,7 @@ module InvoicePrinter
94
94
  end
95
95
 
96
96
  if used? @font
97
- if File.exist?(@font)
98
- set_fonts(@font) if @font
99
- else
100
- raise FontFileNotFound, "Font file not found at #{@font}"
101
- end
97
+ use_font(@font)
102
98
  end
103
99
 
104
100
  # Version 2.1 deprecation warnings
@@ -146,8 +142,36 @@ module InvoicePrinter
146
142
 
147
143
  private
148
144
 
145
+ def use_font(font)
146
+ if File.exist?(@font)
147
+ set_font_from_path(@font)
148
+ elsif @font == 'dejavu'
149
+ set_dejavu_font
150
+ else
151
+ raise FontFileNotFound, "Font file not found at #{font}"
152
+ end
153
+ end
154
+
155
+ # DejaVu from dejavu-fonts gem
156
+ def set_dejavu_font
157
+ require 'dejavu-fonts'
158
+ font_name = 'dejavu'
159
+
160
+ @pdf.font_families.update(
161
+ "#{font_name}" => {
162
+ normal: DejaVu::Fonts.paths[:normal],
163
+ italic: DejaVu::Fonts.paths[:italic],
164
+ bold: DejaVu::Fonts.paths[:bold],
165
+ bold_italic: DejaVu::Fonts.paths[:bold_italic]
166
+ }
167
+ )
168
+ @pdf.font(font_name)
169
+ rescue
170
+ raise FontFileNotFound, "Font file not found for #{font}"
171
+ end
172
+
149
173
  # Add font family in Prawn for a given +font+ file
150
- def set_fonts(font)
174
+ def set_font_from_path(font)
151
175
  font_name = Pathname.new(font).basename
152
176
  @pdf.font_families.update(
153
177
  "#{font_name}" => {
@@ -447,7 +471,6 @@ module InvoicePrinter
447
471
  end
448
472
 
449
473
  # Match the height of next box if needed
450
- # TODO: it's smaller without sublabels
451
474
  min_height = 60
452
475
  if used?(@document.issue_date) || used?(@document.due_date)
453
476
  min_height = (used?(@document.issue_date) && used?(@document.due_date)) ? 75 : 60
@@ -467,7 +490,8 @@ module InvoicePrinter
467
490
  at: [10, y(483) - @push_down],
468
491
  width: x(234)
469
492
  )
470
- @pdf.stroke_rounded_rectangle([0, 508 - @push_down], 270, 45, 6)
493
+
494
+ @pdf.stroke_rounded_rectangle([0, y(508) - @push_down], x(266), @payment_box_height, 6)
471
495
  else
472
496
  @payment_box_height = 60
473
497
  @push_iban = 0
@@ -654,6 +678,7 @@ module InvoicePrinter
654
678
  height = @payment_box_height if @payment_box_height > height
655
679
 
656
680
  @pdf.stroke_rounded_rectangle([x(274), y(508) - @push_down], x(266), height, 6)
681
+ @push_items_table += 12 if @push_items_table <= 18
657
682
  end
658
683
  end
659
684
 
@@ -1,3 +1,3 @@
1
1
  module InvoicePrinter
2
- VERSION = '2.0.0.beta1'
2
+ VERSION = '2.0.0.beta2'
3
3
  end
@@ -73,6 +73,6 @@ class ApiTest < Minitest::Test
73
73
  body = JSON.parse last_response.body
74
74
 
75
75
  assert last_response.ok?
76
- assert_equal body, { 'result' => 'ok', 'data' => Base64.encode64(output) }
76
+ assert_equal body, { 'result' => 'ok', 'data' => Base64.strict_encode64(output) }
77
77
  end
78
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invoice_printer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta1
4
+ version: 2.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Strzibny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-18 00:00:00.000000000 Z
11
+ date: 2019-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json