invoice_printer 2.0.0.beta2 → 2.0.0.beta3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 253de7f5df575343e45fad182f3a6e62fca98cac0758da832361f15b1a11ddbb
4
- data.tar.gz: fe9755f88c5b148829050a565d9bcb043e3e1b36c64b7bbd2e5519fd3a4542fb
3
+ metadata.gz: d0b5acb10995e69d8aba7d44d9e7d71ce5e9b9104cf5883fec574ada600501b0
4
+ data.tar.gz: 3ccaa20f6baeee71cf879cdf74687e6da7ab6441fa5583199fa547d3e5afd34f
5
5
  SHA512:
6
- metadata.gz: 4a603e7f39acc192dbd81efe372538df190ae4ac90eb15b0a8103477030663162bdcdfd5647cfc98455e756028109b5eb3c91e0a312e5862d72ea88d2a5f3b5e
7
- data.tar.gz: 63e01b1748787113d5d70d4dca62aa20501588ae9b9a74fe1a8944d61a5c78e8a9c66a4208d5d78fa01ba0df1029b6ec4f01ae3b207eadf49d293bae9cea5c33
6
+ metadata.gz: 84cf91f9a5f2445dbe62491e7f51c05e4bfaf3d9c5d58881db035a964c2114a9d02fca485f300b15fc8cb87efea05d2c24d60822c1f9c01145dd1eeba62c22cd
7
+ data.tar.gz: aa5566034f52a87d9c7ee432fc485fd233407a82f591ded208a880f0d214aea3c39cc6241add8bfffbcb3abe07311214cb47ff0daec20f1e7ea4ad5a92b131c8
data/Dockerfile CHANGED
@@ -24,8 +24,11 @@ RUN apk update && apk upgrade
24
24
  # Install Ruby and build dependencies
25
25
  RUN apk add build-base bash ruby ruby-etc ruby-dev
26
26
 
27
+ # Install support for builtin fonts
28
+ RUN gem install invoice_printer_fonts --no-document
29
+
27
30
  # Install gem from RubyGems.org
28
- RUN gem install invoice_printer_server --version 2.0.0.beta1 --no-document
31
+ RUN gem install invoice_printer_server --version 2.0.0.beta3 --no-document
29
32
 
30
33
  # Clean APK cache
31
34
  RUN rm -rf /var/cache/apk/*
@@ -18,7 +18,7 @@ def show_help
18
18
 
19
19
  -d, --document document as JSON
20
20
  -l, --labels labels as JSON
21
- --font path to font
21
+ --font path to font or builtin font name
22
22
  -s, --stamp path to stamp
23
23
  --logo path to logotype
24
24
  --background path to background image
@@ -12,7 +12,7 @@ Options:
12
12
 
13
13
  -d, --document document as JSON
14
14
  -l, --labels labels as JSON
15
- --font path to font
15
+ --font path to font or builtin font name
16
16
  -s, --stamp path to stamp
17
17
  --logo path to logotype
18
18
  --background path to background image
@@ -12,6 +12,10 @@ Or the server version as:
12
12
 
13
13
  $ gem install invoice_printer_server
14
14
 
15
+ To have builtin fonts available install:
16
+
17
+ $ gem install invoice_printer_fonts
18
+
15
19
  ### With Bundler
16
20
 
17
21
  Add this line to your application's Gemfile:
@@ -26,6 +30,12 @@ For the server:
26
30
  gem 'invoice_printer_server'
27
31
  ```
28
32
 
33
+ To have builtin fonts available add:
34
+
35
+ ```ruby
36
+ gem 'invoice_printer_fonts'
37
+ ```
38
+
29
39
  And then execute:
30
40
 
31
41
  $ bundle
@@ -233,9 +233,9 @@ 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.
236
+ If you don't have a font around, you can install `invoice_printer_fonts` gem and specify the supported font name instead.
237
237
 
238
- We recommend you DejaVuSans and Overpass fonts.
238
+ Supported builtin fonts are: `overpass`, `opensans`, and `ruboto`. Note that searching the path takes preference.
239
239
 
240
240
  ### Background
241
241
 
@@ -28,6 +28,8 @@ $ sudo docker run -d -p 9393:9393 -t docker.io/strzibnyj/invoice_printer_server
28
28
  ```
29
29
  The server will then be available on `0.0.0.0:9393`.
30
30
 
31
+ Docker image already contains the optional `invoice_printer_fonts` gem.
32
+
31
33
  ### As a mountable Rack app
32
34
 
33
35
  If you want you can always run the server from your custom program or mount it directly from a Rack app.
@@ -56,7 +58,7 @@ Options:
56
58
 
57
59
  - `document` - JSON representation of the document
58
60
  - `labels` - JSON for labels
59
- - `font` - path to font file
61
+ - `font` - path to font file or builtin font name
60
62
  - `stamp` - path to stamp file
61
63
  - `logo` - path to logotype file
62
64
  - `background` - path to background file
@@ -96,7 +98,7 @@ Options:
96
98
 
97
99
  - `document` - JSON representation of the document
98
100
  - `labels` - JSON for labels
99
- - `font` - path to font file
101
+ - `font` - path to font file or builtin font name
100
102
  - `stamp` - path to stamp file
101
103
  - `logo` - path to logotype file
102
104
  - `background` - path to background file
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This is an example of a Czech invoice.
3
- #
4
- # Due to the special characters it requires Overpass-Regular.ttf font to be
5
- # present in this directory.
6
3
 
7
4
  lib = File.expand_path('../../lib', __FILE__)
8
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -81,7 +78,7 @@ invoice = InvoicePrinter::Document.new(
81
78
  InvoicePrinter.print(
82
79
  document: invoice,
83
80
  labels: labels,
84
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
81
+ font: 'overpass',
85
82
  logo: 'prawn.png',
86
83
  file_name: 'czech_invoice.pdf'
87
84
  )
@@ -89,7 +86,7 @@ InvoicePrinter.print(
89
86
  InvoicePrinter.print(
90
87
  document: invoice,
91
88
  labels: labels,
92
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
89
+ font: 'overpass',
93
90
  logo: 'prawn.png',
94
91
  file_name: 'czech_invoice_a4.pdf',
95
92
  page_size: :a4
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This is an example of a Czech invoice.
3
- #
4
- # Due to the special characters it requires Overpass-Regular.ttf font to be
5
- # present in this directory.
6
3
 
7
4
  lib = File.expand_path('../../lib', __FILE__)
8
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -81,7 +78,7 @@ invoice = InvoicePrinter::Document.new(
81
78
  InvoicePrinter.print(
82
79
  document: invoice,
83
80
  labels: labels,
84
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
81
+ font: 'overpass',
85
82
  logo: 'prawn.png',
86
83
  file_name: 'czech_invoice_long.pdf'
87
84
  )
@@ -89,7 +86,7 @@ InvoicePrinter.print(
89
86
  InvoicePrinter.print(
90
87
  document: invoice,
91
88
  labels: labels,
92
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
89
+ font: 'overpass',
93
90
  logo: 'prawn.png',
94
91
  file_name: 'czech_invoice_long_a4.pdf',
95
92
  page_size: :a4
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This is an example of a international invoice with Czech labels and English translation.
3
- #
4
- # Due to the special characters it requires Overpass-Regular.ttf font to be
5
- # present in this directory.
6
3
 
7
4
  lib = File.expand_path('../../lib', __FILE__)
8
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -82,7 +79,7 @@ invoice = InvoicePrinter::Document.new(
82
79
  InvoicePrinter.print(
83
80
  document: invoice,
84
81
  labels: labels,
85
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
82
+ font: 'overpass',
86
83
  logo: 'prawn.png',
87
84
  file_name: 'international_invoice.pdf'
88
85
  )
@@ -90,7 +87,7 @@ InvoicePrinter.print(
90
87
  InvoicePrinter.print(
91
88
  document: invoice,
92
89
  labels: labels,
93
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
90
+ font: 'overpass',
94
91
  logo: 'prawn.png',
95
92
  file_name: 'international_invoice_a4.pdf',
96
93
  page_size: :a4
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This is an example of a international invoice with Czech labels and English translation.
3
- #
4
- # Due to the special characters it requires Overpass-Regular.ttf font to be
5
- # present in this directory.
6
3
 
7
4
  lib = File.expand_path('../../lib', __FILE__)
8
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -78,7 +75,7 @@ invoice = InvoicePrinter::Document.new(
78
75
  InvoicePrinter.print(
79
76
  document: invoice,
80
77
  labels: labels,
81
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
78
+ font: File.expand_path('../../../assets/fonts/overpass/Overpass-Regular.ttf', __FILE__),
82
79
  logo: 'logo.png',
83
80
  file_name: 'promo.pdf'
84
81
  )
@@ -86,7 +83,7 @@ InvoicePrinter.print(
86
83
  InvoicePrinter.print(
87
84
  document: invoice,
88
85
  labels: labels,
89
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
86
+ font: File.expand_path('../../../assets/fonts/overpass/Overpass-Regular.ttf', __FILE__),
90
87
  logo: 'logo.png',
91
88
  file_name: 'promo_a4.pdf',
92
89
  page_size: :a4
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This is an example of a Czech invoice.
3
- #
4
- # Due to the special characters it requires Overpass-Regular.ttf font to be
5
- # present in this directory.
6
3
 
7
4
  lib = File.expand_path('../../lib', __FILE__)
8
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -96,7 +93,7 @@ invoice = InvoicePrinter::Document.new(
96
93
  InvoicePrinter.print(
97
94
  document: invoice,
98
95
  labels: labels,
99
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
96
+ font: 'overpass',
100
97
  logo: 'prawn.png',
101
98
  file_name: 'provider_purchaser_lines.pdf'
102
99
  )
@@ -104,7 +101,7 @@ InvoicePrinter.print(
104
101
  InvoicePrinter.print(
105
102
  document: invoice,
106
103
  labels: labels,
107
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
104
+ font: 'overpass',
108
105
  logo: 'prawn.png',
109
106
  file_name: 'provider_purchaser_lines_a4.pdf',
110
107
  page_size: :a4
@@ -2,11 +2,22 @@ lib = File.expand_path('../lib', __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'invoice_printer/version'
4
4
 
5
- SERVER_FILES = [
5
+ ONLY_SERVER_FILES = [
6
6
  'bin/invoice_printer_server',
7
7
  'lib/invoice_printer/server.rb'
8
8
  ]
9
9
 
10
+ ONLY_FONTS_FILES = [
11
+ 'FONTS_LICENSE.txt',
12
+ 'assets/fonts/overpass/OFL-1.1.txt',
13
+ 'assets/fonts/overpass/Overpass-Regular.ttf',
14
+ 'assets/fonts/opensans/Apache-2.0.txt',
15
+ 'assets/fonts/opensans/OpenSans-Regular.ttf',
16
+ 'assets/fonts/roboto/Apache-2.0.txt',
17
+ 'assets/fonts/roboto/Roboto-Regular.ttf',
18
+ 'lib/invoice_printer/fonts.rb'
19
+ ]
20
+
10
21
  Gem::Specification.new do |spec|
11
22
  spec.name = 'invoice_printer'
12
23
  spec.version = InvoicePrinter::VERSION
@@ -20,7 +31,8 @@ Gem::Specification.new do |spec|
20
31
  # Remove server files
21
32
  # Remove .pdf files as they take a lot of space
22
33
  package_files = `git ls-files -z`.split("\x0")
23
- .reject{ |file| SERVER_FILES.include?(file) }
34
+ .reject{ |file| ONLY_SERVER_FILES.include?(file) }
35
+ .reject{ |file| ONLY_FONTS_FILES.include?(file) }
24
36
  .reject{ |file| file.match /.*\.pdf/ }
25
37
 
26
38
  spec.files = package_files
@@ -0,0 +1,39 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'invoice_printer/version'
4
+
5
+ FONTS_FILES = [
6
+ 'LICENSE.txt',
7
+ 'FONTS_LICENSE.txt',
8
+ 'assets/fonts/overpass/OFL-1.1.txt',
9
+ 'assets/fonts/overpass/Overpass-Regular.ttf',
10
+ 'assets/fonts/opensans/Apache-2.0.txt',
11
+ 'assets/fonts/opensans/OpenSans-Regular.ttf',
12
+ 'assets/fonts/roboto/Apache-2.0.txt',
13
+ 'assets/fonts/roboto/Roboto-Regular.ttf',
14
+ 'lib/invoice_printer/fonts.rb'
15
+ ]
16
+
17
+ Gem::Specification.new do |spec|
18
+ spec.name = 'invoice_printer_fonts'
19
+ spec.version = InvoicePrinter::VERSION
20
+ spec.authors = ['Josef Strzibny']
21
+ spec.email = ['strzibny@strzibny.name']
22
+ spec.summary = 'Super simple PDF invoicing in pure Ruby'
23
+ spec.description = 'Super simple and fast PDF invoicing in pure Ruby (based on Prawn library).'
24
+ spec.homepage = 'https://github.com/strzibny/invoice_printer'
25
+ spec.license = 'MIT'
26
+
27
+ # Include only font files
28
+ spec.files = FONTS_FILES
29
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
30
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
31
+ spec.require_paths = ['lib']
32
+
33
+ spec.required_ruby_version = '>= 2.4'
34
+
35
+ spec.add_dependency 'invoice_printer', InvoicePrinter::VERSION
36
+
37
+ spec.add_development_dependency 'bundler', '>= 1.7'
38
+ spec.add_development_dependency 'rake', '>= 10.0'
39
+ end
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'invoice_printer/version'
4
4
 
5
5
  SERVER_FILES = [
6
+ 'LICENSE.txt',
6
7
  'bin/invoice_printer_server',
7
8
  'lib/invoice_printer/server.rb',
8
9
  'lib/invoice_printer/version.rb'
@@ -145,28 +145,20 @@ module InvoicePrinter
145
145
  def use_font(font)
146
146
  if File.exist?(@font)
147
147
  set_font_from_path(@font)
148
- elsif @font == 'dejavu'
149
- set_dejavu_font
150
148
  else
151
- raise FontFileNotFound, "Font file not found at #{font}"
149
+ set_builtin_font(@font)
152
150
  end
153
151
  end
154
152
 
155
- # DejaVu from dejavu-fonts gem
156
- def set_dejavu_font
157
- require 'dejavu-fonts'
158
- font_name = 'dejavu'
153
+ def set_builtin_font(font)
154
+ require 'invoice_printer/fonts'
159
155
 
160
156
  @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
- }
157
+ "#{font}" => InvoicePrinter::Fonts.paths_for(font)
167
158
  )
168
- @pdf.font(font_name)
169
- rescue
159
+ @pdf.font(font)
160
+
161
+ rescue StandardError
170
162
  raise FontFileNotFound, "Font file not found for #{font}"
171
163
  end
172
164
 
@@ -1,3 +1,3 @@
1
1
  module InvoicePrinter
2
- VERSION = '2.0.0.beta2'
2
+ VERSION = '2.0.0.beta3'
3
3
  end
@@ -11,7 +11,7 @@ class ExamplesTest < Minitest::Test
11
11
  end
12
12
 
13
13
  def teardown
14
- FileUtils.rm_rf @test_dir if File.exists?(@test_dir)
14
+ FileUtils.rm_rf @test_dir if File.exist?(@test_dir)
15
15
  end
16
16
 
17
17
  # 1, copy example to the test directory
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invoice_printer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta2
4
+ version: 2.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Strzibny
@@ -117,6 +117,7 @@ files:
117
117
  - examples/simple_invoice.rb
118
118
  - examples/stamp.png
119
119
  - invoice_printer.gemspec
120
+ - invoice_printer_fonts.gemspec
120
121
  - invoice_printer_server.gemspec
121
122
  - lib/invoice_printer.rb
122
123
  - lib/invoice_printer/document.rb