hexapdf 0.26.0 → 0.26.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/hexapdf/importer.rb +1 -1
- data/lib/hexapdf/serializer.rb +10 -0
- data/lib/hexapdf/version.rb +1 -1
- data/test/hexapdf/test_importer.rb +8 -0
- data/test/hexapdf/test_serializer.rb +8 -0
- data/test/hexapdf/test_writer.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '071877a8fbc781ac3d35f5432d6b7d83b80d5d7f981d3fd7110551e0e09bc18b'
|
4
|
+
data.tar.gz: a0ac1aa3be4d720561b9d58d197f547e9c3958fb0c252d8da27d9e9a356c0b7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7528b421de6360e09bf4caeb72caec3b71f317314c8e0389fca287ee00bfab0ee952d8cecced2df937ff2e8198655fe81ebd12a494fac94847ae28ca20169384
|
7
|
+
data.tar.gz: 52a0ab62632122772162fa1dbbb80e05b11956d187385c813f97f0a6c6c8b23c83f568cef2df81e93caf2ae558cda005ef0923de45f16d2c943cc9d86f92c868
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 0.26.1 - 2022-10-14
|
2
|
+
|
3
|
+
### Changed
|
4
|
+
|
5
|
+
* [HexaPDF::Serializer] to provide better error messages when encountering
|
6
|
+
unserializable objects
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
|
10
|
+
* [HexaPDF::Importer] to correctly expose previously mapped objects
|
11
|
+
|
12
|
+
|
1
13
|
## 0.26.0 - 2022-10-14
|
2
14
|
|
3
15
|
### Added
|
data/lib/hexapdf/importer.rb
CHANGED
@@ -117,7 +117,7 @@ module HexaPDF
|
|
117
117
|
when HexaPDF::Object
|
118
118
|
if object.type == :Catalog || object.type == :Pages
|
119
119
|
@mapper[object.data] = nil
|
120
|
-
elsif (mapped_object = @mapper[object.data]) && !mapped_object.null?
|
120
|
+
elsif (mapped_object = @mapper[object.data]&.__getobj__) && !mapped_object.null?
|
121
121
|
mapped_object
|
122
122
|
else
|
123
123
|
obj = object.dup
|
data/lib/hexapdf/serializer.rb
CHANGED
@@ -151,6 +151,16 @@ module HexaPDF
|
|
151
151
|
@io = nil
|
152
152
|
end
|
153
153
|
|
154
|
+
# Raises an error to provide better failure messages.
|
155
|
+
def serialize_basicobject(obj)
|
156
|
+
object_message = if @object.kind_of?(HexaPDF::Object)
|
157
|
+
"#{obj} (part of #{@object.oid},#{@object.gen})"
|
158
|
+
else
|
159
|
+
obj.inspect
|
160
|
+
end
|
161
|
+
raise HexaPDF::Error, "No serialization method for #{object_message}"
|
162
|
+
end
|
163
|
+
|
154
164
|
# Serializes the +nil+ value.
|
155
165
|
#
|
156
166
|
# See: PDF1.7 s7.3.9
|
data/lib/hexapdf/version.rb
CHANGED
@@ -78,6 +78,14 @@ describe HexaPDF::Importer do
|
|
78
78
|
assert_equal(["one", "two"], @obj[:array])
|
79
79
|
end
|
80
80
|
|
81
|
+
it "uses already mapped HexaPDF::Object instances instead of mapping them again" do
|
82
|
+
hash = @importer.import(@hash)
|
83
|
+
assert_kind_of(HexaPDF::Dictionary, hash)
|
84
|
+
obj = @importer.import(@obj)
|
85
|
+
assert_kind_of(HexaPDF::Dictionary, obj[:hash])
|
86
|
+
assert_same(hash, obj[:hash])
|
87
|
+
end
|
88
|
+
|
81
89
|
it "duplicates the stream if it is a string" do
|
82
90
|
src_obj = @source.add({}, stream: 'data')
|
83
91
|
dst_obj = @importer.import(src_obj)
|
@@ -31,6 +31,14 @@ describe HexaPDF::Serializer do
|
|
31
31
|
assert_serialized("(test)", s)
|
32
32
|
end
|
33
33
|
|
34
|
+
it "raises an error for unknown objects" do
|
35
|
+
obj = HexaPDF::Dictionary.new({x: 5, y: Object.new}, oid: 5, gen: 1)
|
36
|
+
error = assert_raises(HexaPDF::Error) { @serializer.serialize(obj) }
|
37
|
+
assert_match(/\(part of 5,1\)/, error.message)
|
38
|
+
error = assert_raises(HexaPDF::Error) { @serializer.serialize(Object.new) }
|
39
|
+
assert_match(/Object/, error.message)
|
40
|
+
end
|
41
|
+
|
34
42
|
it "serializes nil" do
|
35
43
|
assert_serialized("null", nil)
|
36
44
|
end
|
data/test/hexapdf/test_writer.rb
CHANGED
@@ -40,7 +40,7 @@ describe HexaPDF::Writer do
|
|
40
40
|
219
|
41
41
|
%%EOF
|
42
42
|
3 0 obj
|
43
|
-
<</Producer(HexaPDF version 0.26.
|
43
|
+
<</Producer(HexaPDF version 0.26.1)>>
|
44
44
|
endobj
|
45
45
|
xref
|
46
46
|
3 1
|
@@ -72,7 +72,7 @@ describe HexaPDF::Writer do
|
|
72
72
|
141
|
73
73
|
%%EOF
|
74
74
|
6 0 obj
|
75
|
-
<</Producer(HexaPDF version 0.26.
|
75
|
+
<</Producer(HexaPDF version 0.26.1)>>
|
76
76
|
endobj
|
77
77
|
2 0 obj
|
78
78
|
<</Length 10>>stream
|
@@ -206,7 +206,7 @@ describe HexaPDF::Writer do
|
|
206
206
|
<</Type/Page/MediaBox[0 0 595 842]/Parent 2 0 R/Resources<<>>>>
|
207
207
|
endobj
|
208
208
|
5 0 obj
|
209
|
-
<</Producer(HexaPDF version 0.26.
|
209
|
+
<</Producer(HexaPDF version 0.26.1)>>
|
210
210
|
endobj
|
211
211
|
4 0 obj
|
212
212
|
<</Root 1 0 R/Info 5 0 R/Size 6/Type/XRef/W[1 1 2]/Index[0 6]/Filter/FlateDecode/DecodeParms<</Columns 4/Predictor 12>>/Length 33>>stream
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexapdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.26.
|
4
|
+
version: 0.26.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Leitner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cmdparse
|
@@ -706,7 +706,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
706
706
|
- !ruby/object:Gem::Version
|
707
707
|
version: '0'
|
708
708
|
requirements: []
|
709
|
-
rubygems_version: 3.
|
709
|
+
rubygems_version: 3.3.3
|
710
710
|
signing_key:
|
711
711
|
specification_version: 4
|
712
712
|
summary: HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
|