assembly-objectfile 2.1.0 → 2.1.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 +4 -4
- data/.rubocop_todo.yml +2 -2
- data/Gemfile.lock +2 -2
- data/lib/assembly/object_file/version.rb +1 -1
- data/lib/assembly/object_file.rb +8 -1
- data/lib/assembly-objectfile.rb +2 -4
- data/spec/assembly/object_file_spec.rb +11 -10
- data/spec/spec_helper.rb +2 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76dac08191a4c118cf16e4736b9538c9d2a60811cf9547e0ad395ab468b1b51a
|
4
|
+
data.tar.gz: b9fec1e99d03941f658cd6716e1c00db37ce2f2042816e4ba8f77246b102d1f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '082fc021ca4f4dde1f3eaaac937e66862d8ea36f5198bdece9866a72e5be068021665e10bd40b8ea2835d848c062886982ed41033935120525c8d4e57efadafd'
|
7
|
+
data.tar.gz: cf2e4facd4248532c5f92c741f80b5e8d27e04b8cc23e3b7959b59118cceaf8122d03aa92af8faf99c8000bb4298b74d9ab86001744c6f852cd148ceda21d675
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2022-07-
|
3
|
+
# on 2022-07-20 17:16:46 UTC using RuboCop version 1.31.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -9,4 +9,4 @@
|
|
9
9
|
# Offense count: 1
|
10
10
|
# Configuration parameters: CountComments, CountAsOne.
|
11
11
|
Metrics/ClassLength:
|
12
|
-
Max:
|
12
|
+
Max: 122
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
assembly-objectfile (2.1.
|
4
|
+
assembly-objectfile (2.1.1)
|
5
5
|
activesupport (>= 5.2.0)
|
6
6
|
mime-types (> 3)
|
7
7
|
mini_exiftool
|
@@ -76,7 +76,7 @@ GEM
|
|
76
76
|
simplecov_json_formatter (~> 0.1)
|
77
77
|
simplecov-html (0.12.3)
|
78
78
|
simplecov_json_formatter (0.1.4)
|
79
|
-
tzinfo (2.0.
|
79
|
+
tzinfo (2.0.5)
|
80
80
|
concurrent-ruby (~> 1.0)
|
81
81
|
unicode-display_width (2.2.0)
|
82
82
|
|
data/lib/assembly/object_file.rb
CHANGED
@@ -104,6 +104,13 @@ module Assembly
|
|
104
104
|
@exif ||= begin
|
105
105
|
check_for_file
|
106
106
|
MiniExiftool.new(path, replace_invalid_chars: '?')
|
107
|
+
rescue MiniExiftool::Error
|
108
|
+
# MiniExiftool will throw an exception when it tries to initialize for problematic files,
|
109
|
+
# but the exception it throws does not tell you the file that caused the problem.
|
110
|
+
# Instead, we will raise our own exception with more context in logging/reporting upstream.
|
111
|
+
# Note: if the file that causes the problem should NOT use exiftool to determine mimetype, add it to the skipped
|
112
|
+
# mimetypes in Assembly::TRUSTED_MIMETYPES to bypass initialization of MiniExiftool for mimetype generation
|
113
|
+
raise MiniExiftool::Error, "error initializing MiniExiftool for #{path}"
|
107
114
|
end
|
108
115
|
end
|
109
116
|
|
@@ -255,7 +262,7 @@ module Assembly
|
|
255
262
|
check_for_file
|
256
263
|
# if it's not a "trusted" mimetype and there is exif data; get the mimetype from the exif
|
257
264
|
prefer_exif = !Assembly::TRUSTED_MIMETYPES.include?(file_mimetype)
|
258
|
-
exif.mimetype if exif&.mimetype
|
265
|
+
exif.mimetype if prefer_exif && exif&.mimetype
|
259
266
|
end
|
260
267
|
end
|
261
268
|
|
data/lib/assembly-objectfile.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Assembly
|
4
|
-
# the path to the gem, used to access profiles stored with the gem
|
5
|
-
PATH_TO_GEM = File.expand_path("#{File.dirname(__FILE__)}/..")
|
6
|
-
|
7
4
|
# If input image is not one of these mime types, it will not be regarded as a valid image
|
8
5
|
# for the purpose of generating a JP2 derivative
|
9
6
|
VALID_IMAGE_MIMETYPES = ['image/jpeg', 'image/tiff', 'image/tif', 'image/png'].freeze
|
@@ -12,7 +9,8 @@ module Assembly
|
|
12
9
|
# one of these is returned by the file command, then a check will be made to see if exif data exists...
|
13
10
|
# if so, the mimetype returned by the exif data will be used if no exif data exists, then the
|
14
11
|
# mimetype returned by the unix file command will be used
|
15
|
-
TRUSTED_MIMETYPES = ['text/plain', 'plain/text', 'application/pdf', 'text/html', 'application/xml'
|
12
|
+
TRUSTED_MIMETYPES = ['text/plain', 'plain/text', 'application/pdf', 'text/html', 'application/xml',
|
13
|
+
'application/octet-stream'].freeze
|
16
14
|
|
17
15
|
# This is a manual override mapping of file extension to mimetype; if a file with the given extension
|
18
16
|
# is found, the mapped mimetype will be returned and no further methods will be used - this is used
|
@@ -113,7 +113,7 @@ describe Assembly::ObjectFile do
|
|
113
113
|
|
114
114
|
context 'with ruby file' do
|
115
115
|
it 'false' do
|
116
|
-
non_image_file = File.join(
|
116
|
+
non_image_file = File.join(PATH_TO_GEM, 'spec/assembly/object_file_spec.rb')
|
117
117
|
object_file = described_class.new(non_image_file)
|
118
118
|
expect(object_file.image?).to be(false)
|
119
119
|
end
|
@@ -121,7 +121,7 @@ describe Assembly::ObjectFile do
|
|
121
121
|
|
122
122
|
context 'with xml' do
|
123
123
|
it 'false' do
|
124
|
-
non_image_file = File.join(
|
124
|
+
non_image_file = File.join(PATH_TO_GEM, 'spec/test_data/input/file_with_no_exif.xml')
|
125
125
|
object_file = described_class.new(non_image_file)
|
126
126
|
expect(object_file.image?).to be(false)
|
127
127
|
end
|
@@ -145,7 +145,7 @@ describe Assembly::ObjectFile do
|
|
145
145
|
|
146
146
|
context 'with ruby file' do
|
147
147
|
it ':text' do
|
148
|
-
non_image_file = File.join(
|
148
|
+
non_image_file = File.join(PATH_TO_GEM, 'spec/assembly/object_file_spec.rb')
|
149
149
|
object_file = described_class.new(non_image_file)
|
150
150
|
expect(object_file.object_type).to eq(:text)
|
151
151
|
end
|
@@ -153,7 +153,7 @@ describe Assembly::ObjectFile do
|
|
153
153
|
|
154
154
|
context 'with xml' do
|
155
155
|
it ':application' do
|
156
|
-
non_image_file = File.join(
|
156
|
+
non_image_file = File.join(PATH_TO_GEM, 'spec/test_data/input/file_with_no_exif.xml')
|
157
157
|
object_file = described_class.new(non_image_file)
|
158
158
|
expect(object_file.object_type).to eq(:application)
|
159
159
|
end
|
@@ -191,7 +191,7 @@ describe Assembly::ObjectFile do
|
|
191
191
|
|
192
192
|
context 'with ruby file' do
|
193
193
|
it 'false' do
|
194
|
-
non_image_file = File.join(
|
194
|
+
non_image_file = File.join(PATH_TO_GEM, 'spec/assembly/object_file_spec.rb')
|
195
195
|
object_file = described_class.new(non_image_file)
|
196
196
|
expect(object_file.valid_image?).to be(false)
|
197
197
|
end
|
@@ -199,7 +199,7 @@ describe Assembly::ObjectFile do
|
|
199
199
|
|
200
200
|
context 'with xml' do
|
201
201
|
it 'false' do
|
202
|
-
non_image_file = File.join(
|
202
|
+
non_image_file = File.join(PATH_TO_GEM, 'spec/test_data/input/file_with_no_exif.xml')
|
203
203
|
object_file = described_class.new(non_image_file)
|
204
204
|
expect(object_file.valid_image?).to be(false)
|
205
205
|
end
|
@@ -359,7 +359,7 @@ describe Assembly::ObjectFile do
|
|
359
359
|
|
360
360
|
describe '#file_exists?' do
|
361
361
|
it 'false when a valid directory is specified instead of a file' do
|
362
|
-
path =
|
362
|
+
path = PATH_TO_GEM
|
363
363
|
object_file = described_class.new(path)
|
364
364
|
expect(File.exist?(path)).to be true
|
365
365
|
expect(File.directory?(path)).to be true
|
@@ -367,7 +367,7 @@ describe Assembly::ObjectFile do
|
|
367
367
|
end
|
368
368
|
|
369
369
|
it 'false when a non-existent file is specified' do
|
370
|
-
path = File.join(
|
370
|
+
path = File.join(PATH_TO_GEM, 'file_not_there.txt')
|
371
371
|
object_file = described_class.new(path)
|
372
372
|
expect(File.exist?(path)).to be false
|
373
373
|
expect(File.directory?(path)).to be false
|
@@ -410,9 +410,10 @@ describe Assembly::ObjectFile do
|
|
410
410
|
expect(object_file.exif.class).to eq MiniExiftool
|
411
411
|
end
|
412
412
|
|
413
|
-
it 'raises MiniExiftool::Error if exiftool raises one' do
|
413
|
+
it 'raises MiniExiftool::Error with file path if exiftool raises one' do
|
414
414
|
object_file = described_class.new('spec/test_data/empty.txt')
|
415
|
-
expect { object_file.exif }.to raise_error(MiniExiftool::Error
|
415
|
+
expect { object_file.exif }.to raise_error(MiniExiftool::Error,
|
416
|
+
"error initializing MiniExiftool for #{object_file.path}")
|
416
417
|
end
|
417
418
|
end
|
418
419
|
|
data/spec/spec_helper.rb
CHANGED
@@ -10,13 +10,10 @@ RSpec.configure do |config|
|
|
10
10
|
config.order = 'random'
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
TEST_INPUT_DIR = File.join(
|
15
|
-
TEST_OUTPUT_DIR = File.join(TEST_DATA_DIR, 'output')
|
13
|
+
PATH_TO_GEM = File.expand_path("#{File.dirname(__FILE__)}/..")
|
14
|
+
TEST_INPUT_DIR = File.join(PATH_TO_GEM, 'spec', 'test_data', 'input')
|
16
15
|
TEST_TIF_INPUT_FILE = File.join(TEST_INPUT_DIR, 'test.tif')
|
17
|
-
TEST_JPEG_INPUT_FILE = File.join(TEST_INPUT_DIR, 'test.jpg')
|
18
16
|
TEST_JP2_INPUT_FILE = File.join(TEST_INPUT_DIR, 'test.jp2')
|
19
|
-
TEST_JP2_OUTPUT_FILE = File.join(TEST_OUTPUT_DIR, 'test.jp2')
|
20
17
|
|
21
18
|
TEST_TIFF_NO_COLOR_FILE = File.join(TEST_INPUT_DIR, 'test_no_color_profile.tif')
|
22
19
|
|
@@ -30,5 +27,3 @@ TEST_JSON_FILE = File.join(TEST_INPUT_DIR, 'test.json')
|
|
30
27
|
|
31
28
|
TEST_OBJ_FILE = File.join(TEST_INPUT_DIR, 'someobject.obj')
|
32
29
|
TEST_PLY_FILE = File.join(TEST_INPUT_DIR, 'someobject.ply')
|
33
|
-
|
34
|
-
TEST_DRUID = 'nx288wh8889'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assembly-objectfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Mangiafico
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-07-
|
14
|
+
date: 2022-07-20 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|