invoice_printer 1.0.0 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +62 -5
- data/bin/invoice_printer +140 -0
- data/examples/complex_invoice.rb +11 -1
- data/examples/czech_invoice.rb +12 -0
- data/examples/international_invoice.rb +9 -0
- data/examples/long_invoice.rb +9 -1
- data/examples/promo.rb +9 -0
- data/examples/simple_invoice.rb +7 -0
- data/invoice_printer.gemspec +1 -0
- data/lib/invoice_printer/document/item.rb +37 -21
- data/lib/invoice_printer/document.rb +130 -90
- data/lib/invoice_printer/pdf_document.rb +153 -108
- data/lib/invoice_printer/version.rb +1 -1
- data/lib/invoice_printer.rb +6 -4
- data/test/cli_test.rb +76 -0
- data/test/examples_test.rb +5 -0
- data/test/inputs_test.rb +9 -0
- data/test/invoice_printer_test.rb +13 -2
- metadata +9 -5
data/test/examples_test.rb
CHANGED
@@ -21,13 +21,18 @@ class ExamplesTest < Minitest::Test
|
|
21
21
|
@examples.each do |example|
|
22
22
|
example_file = File.join(@test_dir, File.basename(example))
|
23
23
|
original_pdf = example.gsub('.rb', '.pdf')
|
24
|
+
original_a4_pdf = example.gsub('.rb', '_a4.pdf')
|
24
25
|
result_pdf = example_file.gsub('.rb', '.pdf')
|
26
|
+
result_a4_pdf = example_file.gsub('.rb', '_a4.pdf')
|
25
27
|
|
26
28
|
Dir.chdir(@test_dir) do
|
27
29
|
`ruby -I../../lib #{example_file}`
|
28
30
|
|
29
31
|
similarity = (File.read(original_pdf) == File.read(result_pdf))
|
30
32
|
assert_equal true, similarity, "#{original_pdf} does not match #{result_pdf}"
|
33
|
+
|
34
|
+
similarity = (File.read(original_a4_pdf) == File.read(result_a4_pdf))
|
35
|
+
assert_equal true, similarity, "#{original_a4_pdf} does not match #{result_a4_pdf}"
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
data/test/inputs_test.rb
CHANGED
@@ -47,4 +47,13 @@ class InputsTest < Minitest::Test
|
|
47
47
|
InvoicePrinter.render(document: invoice, logo: 'missing.png')
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
def test_missing_stamp_raises_an_exception
|
52
|
+
invoice = InvoicePrinter::Document.new(default_document_params)
|
53
|
+
|
54
|
+
assert_raises(InvoicePrinter::PDFDocument::StampFileNotFound) do
|
55
|
+
InvoicePrinter.render(document: invoice, stamp: 'missing.png')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
50
59
|
end
|
@@ -4,10 +4,21 @@ class InvoicePrinterTest < Minitest::Test
|
|
4
4
|
include InvoicePrinterHelpers
|
5
5
|
|
6
6
|
def test_render_document
|
7
|
-
invoice
|
7
|
+
invoice = InvoicePrinter::Document.new(default_document_params)
|
8
8
|
rendered_pdf = InvoicePrinter.render(document: invoice)
|
9
9
|
pdf_analysis = PDF::Inspector::Text.analyze(rendered_pdf)
|
10
|
-
strings
|
10
|
+
strings = InvoicePrinter::PDFDocument.new(document: invoice).to_a
|
11
|
+
|
12
|
+
assert_equal strings, pdf_analysis.strings
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_render_document_from_json
|
16
|
+
invoice = InvoicePrinter::Document.new(default_document_params)
|
17
|
+
invoice_json = JSON.parse(invoice.to_json)
|
18
|
+
invoice_from_json = InvoicePrinter::Document.from_json(invoice_json)
|
19
|
+
rendered_pdf = InvoicePrinter.render(document: invoice_from_json)
|
20
|
+
pdf_analysis = PDF::Inspector::Text.analyze(rendered_pdf)
|
21
|
+
strings = InvoicePrinter::PDFDocument.new(document: invoice).to_a
|
11
22
|
|
12
23
|
assert_equal strings, pdf_analysis.strings
|
13
24
|
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: 1.0.
|
4
|
+
version: 1.1.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josef Strzibny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -83,7 +83,8 @@ dependencies:
|
|
83
83
|
description: Super simple and fast PDF invoicing in pure Ruby (based on Prawn library).
|
84
84
|
email:
|
85
85
|
- strzibny@strzibny.name
|
86
|
-
executables:
|
86
|
+
executables:
|
87
|
+
- invoice_printer
|
87
88
|
extensions: []
|
88
89
|
extra_rdoc_files: []
|
89
90
|
files:
|
@@ -92,6 +93,7 @@ files:
|
|
92
93
|
- LICENSE.txt
|
93
94
|
- README.md
|
94
95
|
- Rakefile
|
96
|
+
- bin/invoice_printer
|
95
97
|
- examples/background.png
|
96
98
|
- examples/complex_invoice.rb
|
97
99
|
- examples/czech_invoice.rb
|
@@ -110,6 +112,7 @@ files:
|
|
110
112
|
- lib/invoice_printer/pdf_document.rb
|
111
113
|
- lib/invoice_printer/version.rb
|
112
114
|
- test/background_test.rb
|
115
|
+
- test/cli_test.rb
|
113
116
|
- test/dates_box_test.rb
|
114
117
|
- test/examples_test.rb
|
115
118
|
- test/inputs_test.rb
|
@@ -136,9 +139,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
139
|
version: '0'
|
137
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
141
|
requirements:
|
139
|
-
- - "
|
142
|
+
- - ">"
|
140
143
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
144
|
+
version: 1.3.1
|
142
145
|
requirements: []
|
143
146
|
rubyforge_project:
|
144
147
|
rubygems_version: 2.6.13
|
@@ -147,6 +150,7 @@ specification_version: 4
|
|
147
150
|
summary: Super simple PDF invoicing in pure Ruby
|
148
151
|
test_files:
|
149
152
|
- test/background_test.rb
|
153
|
+
- test/cli_test.rb
|
150
154
|
- test/dates_box_test.rb
|
151
155
|
- test/examples_test.rb
|
152
156
|
- test/inputs_test.rb
|