zugpferd 0.9.0 → 0.9.1

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: 5cfc91b900af3d8c0586831fabc3963e99d538383739e298d146d5e9d83714c8
4
- data.tar.gz: 806154beec1f4525e01745f15c9a9fdd6acc9eb5f74292e521e28667c59119b8
3
+ metadata.gz: 8a81cafc9a97815b530265d94e7335922f49e342e9993768f0d1e062cbe2c210
4
+ data.tar.gz: 87593306b6c7a678fc81c398aab52069bd5235133e008803df21bf7f9f993ea3
5
5
  SHA512:
6
- metadata.gz: 753cc63a0cd46279822c2d60a72b5efda5ff21ecc1bca9b098b8b62b3c5197db50f858d922b25c474fab6681e5d40491d17faf2bdeefb271e2cd4cb4d3aabe07
7
- data.tar.gz: 2d5a186b249dce95d253ab55bfd961af4f0a639de2adf7a15134ec4534c565f08c5098597e8e484c0eb5f5851f68e6f5096f6713a6a1599f2b4c7b480c044913
6
+ metadata.gz: a768c2a3c9690853bd836d6a50d966f6b0241b8f5892d4ff90241a77d75f272fe011d9f76bfb6589aa3b10996b5cb830b7ee923608d687b3d9c7370ae3bdfea4
7
+ data.tar.gz: 839733c3e4d20e121b2aae12229942f4220839eadaea33be03d20d8061d1b5a74002300773e142e16bcaafe1cc3888c812c63753e51c071be7faeca89c3ff611
@@ -0,0 +1,21 @@
1
+ %!PS
2
+ % Adds the Associated Files array to the Catalog for Ghostscript before 10.04.0.
3
+ %
4
+ % PDF/A-3 requires /AF in the Catalog for an embedded file, ISO 19005-3,
5
+ % clause 6.8. zugferd.ps no longer adds it, because Ghostscript 10.04.0 and
6
+ % later emit it themselves. Older versions emit nothing, so validators reject
7
+ % the output.
8
+ %
9
+ % Ghostscript runs this file after zugferd.ps. Named pdfmark objects live for
10
+ % the whole run, so {AFArray} from zugferd.ps is still defined here. The guards
11
+ % mirror zugferd.ps: without the XML file or the ICC profile it creates no
12
+ % {AFArray}.
13
+ /ZUGFeRDXMLFile where {
14
+ pop
15
+ /ZUGFeRDProfile where {
16
+ pop
17
+ revision 10040 lt {
18
+ [ {Catalog} << /AF {AFArray} >> /PUT pdfmark
19
+ } if
20
+ } if
21
+ } if
@@ -70,6 +70,11 @@ module Zugpferd
70
70
  File.join(vendor_dir, "default_rgb.icc")
71
71
  end
72
72
 
73
+ # Sets /AF in the Catalog where Ghostscript before 10.04.0 does not.
74
+ def catalog_af_ps_path
75
+ File.expand_path("catalog_af.ps", __dir__)
76
+ end
77
+
73
78
  def write_xml_tempfile(xml)
74
79
  tmpfile = Tempfile.new(["zugferd", ".xml"])
75
80
  tmpfile.binmode
@@ -118,6 +123,7 @@ module Zugpferd
118
123
  cmd << "-o"
119
124
  cmd << output_path
120
125
  cmd << ps_path
126
+ cmd << catalog_af_ps_path
121
127
  cmd << pdf_path
122
128
  cmd
123
129
  end
@@ -38,7 +38,8 @@ module Zugpferd
38
38
  uri = URI("#{@base_uri}/api/info")
39
39
  response = Net::HTTP.get_response(uri)
40
40
  response.code == "200"
41
- rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, SocketError, Net::OpenTimeout
41
+ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, SocketError, Net::OpenTimeout,
42
+ EOFError, Errno::ECONNRESET, Net::ReadTimeout
42
43
  false
43
44
  end
44
45
 
@@ -65,18 +66,21 @@ module Zugpferd
65
66
  end
66
67
 
67
68
  data = JSON.parse(response.body)
68
- job = data.dig("report", "jobs", 0) || data.dig("report", "batchSummary") || {}
69
- validation = job["validationResult"] || job
69
+ # veraPDF 1.30 returns validationResult as a list. A single object,
70
+ # the shape this method used to expect, is still accepted.
71
+ results = data.dig("report", "jobs", 0, "validationResult")
72
+ results = [results] if results.is_a?(Hash)
73
+ results = Array(results)
70
74
 
71
- compliant = validation["compliant"] == true
72
- failures = extract_failures(validation)
75
+ compliant = results.any? && results.all? { |r| r["compliant"] == true }
76
+ failures = results.flat_map { |r| extract_failures(r) }
73
77
 
74
78
  Result.new(compliant: compliant, failures: failures)
75
79
  end
76
80
 
77
81
  def extract_failures(validation)
78
- details = validation["details"] || validation["rulesSummary"] || {}
79
- rules = details["rules"] || []
82
+ details = validation["details"] || {}
83
+ rules = details["ruleSummaries"] || []
80
84
 
81
85
  rules.select { |r| r["status"] == "failed" }.map do |rule|
82
86
  {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zugpferd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Zeitler
@@ -98,6 +98,7 @@ files:
98
98
  - lib/zugpferd/model/tax_subtotal.rb
99
99
  - lib/zugpferd/model/trade_party.rb
100
100
  - lib/zugpferd/pdf.rb
101
+ - lib/zugpferd/pdf/catalog_af.ps
101
102
  - lib/zugpferd/pdf/embedder.rb
102
103
  - lib/zugpferd/pdf/extractor.rb
103
104
  - lib/zugpferd/ubl/mapping.rb