assembly-objectfile 1.12.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e964d66148904c190829abd7d9c65d09459405f184a48a2350602d1f4c6b6a5f
4
- data.tar.gz: 85fca1341b29f0c3f5b3858b419e0273754de1a47140b5ae36d2cbf2a77feea4
3
+ metadata.gz: 8c85bb6c05fe0d46e9b2f37e90710043efce16322c5d58e0b0a9578fd21ece77
4
+ data.tar.gz: c7e3ac5e3f0a0aa2124f8ce3d6587de2d02923c733ee94b1c299ae171101f5a5
5
5
  SHA512:
6
- metadata.gz: f2cf693279f7c43392f92b3dd8bf28df4baca673276c3c96208b420c6ec26415b37b9498149a0ee6fe8ff4606046768582107f1e71b66199f04463b8f5dec918
7
- data.tar.gz: fcdc3f9041410416893e8ba1258c677a9eb0f6ede6eb833deb74f9dcb30e005d226d4486419a6fc2a1ae24b9e0ceda579e1acb7f189cf022af822fc32e275fa6
6
+ metadata.gz: fbad307e9a103af61b4a6b05b35bb6b98953774a2c9bd32cb1404f1a9ff6e3404fe78cfc48f9061bfffaa23c3610f2a6f19df5e08975a20c6ee387073cc1010d
7
+ data.tar.gz: 717e174ccf88a94880f4a832b2d281b351774299fb1273a96b4a1bb942e360cd20b0ba3ac68b7ad4f113e3bd3c78652c7670efcf7bcf8f9bcf068972ba5cd42d
@@ -0,0 +1,14 @@
1
+ version: 2.1
2
+ orbs:
3
+ ruby-rails: sul-dlss/ruby-rails@3.0.1
4
+ workflows:
5
+ build:
6
+ jobs:
7
+ - ruby-rails/lint-gem:
8
+ name: lint
9
+ - ruby-rails/test-gem:
10
+ name: test
11
+ before-test:
12
+ - run:
13
+ name: Install exiftool
14
+ command: curl -L http://cpanmin.us | perl - --sudo Image::ExifTool
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## How was this change tested? 🤨
6
6
 
7
- ⚡ ⚠ If this change has cross service impact, ***run [integration tests](https://github.com/sul-dlss/infrastructure-integration-test) that do accessioning*** and/or test in [stage|qa] environment, in addition to specs. ⚡
7
+ ⚡ ⚠ If this change has cross service impact, ***run [integration tests](https://github.com/sul-dlss/infrastructure-integration-test) that do file accessioning*** (e.g. create_preassembly_image_spec) and/or test in [stage|qa] environment, in addition to specs. ⚡
8
8
 
9
9
 
10
10
 
data/.rubocop.yml CHANGED
@@ -2,20 +2,12 @@ inherit_from: .rubocop_todo.yml
2
2
  require: rubocop-rspec
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.5
6
-
7
- RSpec/ContextWording:
8
- Enabled: false # too dogmatic
9
-
10
- RSpec/ExampleLength:
11
- Max: 25
12
-
13
- # we like 'expect(x).to receive' better than 'have_received'
14
- RSpec/MessageSpies:
15
- Enabled: false
16
-
17
- RSpec/NestedGroups:
18
- Max: 4 # default: 3
5
+ TargetRubyVersion: 3.0
6
+ DisplayCopNames: true
7
+ Exclude:
8
+ - 'Gemfile.lock'
9
+ - '**/*.md'
10
+ - 'vendor/**/*' # avoid running rubocop on cached bundler
19
11
 
20
12
  Metrics/BlockLength:
21
13
  Exclude:
@@ -135,3 +127,83 @@ Style/RedundantArgument: # (new in 1.4)
135
127
 
136
128
  Style/SwapValues: # (new in 1.1)
137
129
  Enabled: true
130
+
131
+ Gemspec/RequireMFA: # new in 1.23
132
+ Enabled: true
133
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
134
+ Enabled: true
135
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
136
+ Enabled: true
137
+ Lint/AmbiguousRange: # new in 1.19
138
+ Enabled: true
139
+ Lint/EmptyInPattern: # new in 1.16
140
+ Enabled: true
141
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
142
+ Enabled: true
143
+ Lint/RequireRelativeSelfPath: # new in 1.22
144
+ Enabled: true
145
+ Lint/UselessRuby2Keywords: # new in 1.23
146
+ Enabled: true
147
+ Naming/BlockForwarding: # new in 1.24
148
+ Enabled: true
149
+ Security/IoMethods: # new in 1.22
150
+ Enabled: true
151
+ Style/FileRead: # new in 1.24
152
+ Enabled: true
153
+ Style/FileWrite: # new in 1.24
154
+ Enabled: true
155
+ Style/InPatternThen: # new in 1.16
156
+ Enabled: true
157
+ Style/MapToHash: # new in 1.24
158
+ Enabled: true
159
+ Style/MultilineInPatternThen: # new in 1.16
160
+ Enabled: true
161
+ Style/NumberedParameters: # new in 1.22
162
+ Enabled: true
163
+ Style/NumberedParametersLimit: # new in 1.22
164
+ Enabled: true
165
+ Style/OpenStructUse: # new in 1.23
166
+ Enabled: true
167
+ Style/QuotedSymbols: # new in 1.16
168
+ Enabled: true
169
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
170
+ Enabled: true
171
+ Style/SelectByRegexp: # new in 1.22
172
+ Enabled: true
173
+ Style/StringChars: # new in 1.12
174
+ Enabled: true
175
+ RSpec/BeEq: # new in 2.9.0
176
+ Enabled: true
177
+ RSpec/BeNil: # new in 2.9.0
178
+ Enabled: true
179
+ RSpec/ExcessiveDocstringSpacing: # new in 2.5
180
+ Enabled: true
181
+ RSpec/IdenticalEqualityAssertion: # new in 2.4
182
+ Enabled: true
183
+ RSpec/SubjectDeclaration: # new in 2.5
184
+ Enabled: true
185
+ RSpec/FactoryBot/SyntaxMethods: # new in 2.7
186
+ Enabled: true
187
+ RSpec/Rails/AvoidSetupHook: # new in 2.4
188
+ Enabled: true
189
+
190
+ Lint/RefinementImportMethods: # new in 1.27
191
+ Enabled: true
192
+ Security/CompoundHash: # new in 1.28
193
+ Enabled: true
194
+ Style/EnvHome: # new in 1.29
195
+ Enabled: true
196
+ Style/FetchEnvVar: # new in 1.28
197
+ Enabled: true
198
+ Style/MapCompactWithConditionalBlock: # new in 1.30
199
+ Enabled: true
200
+ Style/NestedFileDirname: # new in 1.26
201
+ Enabled: true
202
+ Style/ObjectThen: # new in 1.28
203
+ Enabled: true
204
+ Style/RedundantInitialize: # new in 1.27
205
+ Enabled: true
206
+ RSpec/ChangeByZero: # new in 2.11.0
207
+ Enabled: true
208
+ RSpec/VerifiedDoubleReference: # new in 2.10.0
209
+ Enabled: true
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2021-04-26 18:43:37 UTC using RuboCop version 1.11.0.
3
+ # on 2022-02-28 21:11:02 UTC using RuboCop version 1.25.1.
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
@@ -48,7 +48,8 @@ Metrics/PerceivedComplexity:
48
48
  Max: 15
49
49
 
50
50
  # Offense count: 1
51
- # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms.
51
+ # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
52
+ # CheckDefinitionPathHierarchyRoots: lib, spec, test, src
52
53
  # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
53
54
  Naming/FileName:
54
55
  Exclude:
@@ -65,12 +66,18 @@ Naming/PredicateName:
65
66
  - 'spec/**/*'
66
67
  - 'lib/assembly-objectfile/object_fileable.rb'
67
68
 
68
- # Offense count: 9
69
- # Configuration parameters: Max.
70
- RSpec/ExampleLength:
69
+ # Offense count: 1
70
+ # Configuration parameters: Prefixes.
71
+ # Prefixes: when, with, without
72
+ RSpec/ContextWording:
71
73
  Exclude:
72
74
  - 'spec/content_metadata_spec.rb'
73
75
 
76
+ # Offense count: 32
77
+ # Configuration parameters: CountAsOne.
78
+ RSpec/ExampleLength:
79
+ Max: 34
80
+
74
81
  # Offense count: 2
75
82
  # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
76
83
  # Include: **/*_spec*rb*, **/spec/**/*
@@ -85,10 +92,14 @@ RSpec/InstanceVariable:
85
92
  Exclude:
86
93
  - 'spec/object_file_spec.rb'
87
94
 
88
- # Offense count: 40
95
+ # Offense count: 41
89
96
  RSpec/MultipleExpectations:
90
97
  Max: 29
91
98
 
99
+ # Offense count: 20
100
+ RSpec/NestedGroups:
101
+ Max: 4
102
+
92
103
  # Offense count: 2
93
104
  RSpec/RepeatedDescription:
94
105
  Exclude:
@@ -99,7 +110,7 @@ RSpec/RepeatedExample:
99
110
  Exclude:
100
111
  - 'spec/object_file_spec.rb'
101
112
 
102
- # Offense count: 8
113
+ # Offense count: 5
103
114
  RSpec/RepeatedExampleGroupDescription:
104
115
  Exclude:
105
116
  - 'spec/content_metadata_spec.rb'
@@ -110,9 +121,9 @@ Style/CommentedKeyword:
110
121
  Exclude:
111
122
  - 'lib/assembly-objectfile/content_metadata.rb'
112
123
 
113
- # Offense count: 122
124
+ # Offense count: 123
114
125
  # Cop supports --auto-correct.
115
- # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
126
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
116
127
  # URISchemes: http, https
117
128
  Layout/LineLength:
118
129
  Max: 277
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.com/sul-dlss/assembly-objectfile.svg?branch=main)](https://travis-ci.com/sul-dlss/assembly-objectfile)
1
+ [![CircleCI](https://circleci.com/gh/sul-dlss/assembly-objectfile/tree/main.svg?style=svg)](https://circleci.com/gh/sul-dlss/assembly-objectfile/tree/main)
2
2
  [![Test Coverage](https://api.codeclimate.com/v1/badges/2310962acce78d78e76c/test_coverage)](https://codeclimate.com/github/sul-dlss/assembly-objectfile/test_coverage)
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/2310962acce78d78e76c/maintainability)](https://codeclimate.com/github/sul-dlss/assembly-objectfile/maintainability)
4
4
  [![Gem Version](https://badge.fury.io/rb/assembly-objectfile.svg)](https://badge.fury.io/rb/assembly-objectfile)
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.summary = 'Ruby immplementation of file services needed to prepare objects to be accessioned in SULAIR digital library'
14
14
  s.description = 'Get exif data, file sizes and more.'
15
15
  s.license = 'ALv2'
16
+ s.metadata['rubygems_mfa_required'] = 'true'
16
17
 
17
18
  s.files = `git ls-files`.split("\n")
18
19
  s.test_files = `git ls-files -- spec/*`.split("\n")
@@ -20,7 +21,7 @@ Gem::Specification.new do |s|
20
21
  s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
22
  s.require_paths = ['lib']
22
23
 
23
- s.required_ruby_version = '>= 2.5', '< 4'
24
+ s.required_ruby_version = '>= 3.0'
24
25
 
25
26
  s.add_dependency 'activesupport', '>= 5.2.0'
26
27
  s.add_dependency 'deprecation'
@@ -33,7 +34,7 @@ Gem::Specification.new do |s|
33
34
  s.add_development_dependency 'json'
34
35
  s.add_development_dependency 'rake'
35
36
  s.add_development_dependency 'rspec', '~> 3.0'
36
- s.add_development_dependency 'rubocop'
37
+ s.add_development_dependency 'rubocop', '~> 1.25'
37
38
  s.add_development_dependency 'rubocop-rspec'
38
- s.add_development_dependency 'simplecov', '~> 0.17.0' # CodeClimate cannot use SimpleCov >= 0.18.0 for generating test coverage
39
+ s.add_development_dependency 'simplecov'
39
40
  end
@@ -91,8 +91,6 @@ module Assembly
91
91
  @exif ||= begin
92
92
  check_for_file
93
93
  MiniExiftool.new(path, replace_invalid_chars: '?')
94
- rescue StandardError
95
- nil
96
94
  end
97
95
  end
98
96
 
@@ -176,8 +174,7 @@ module Assembly
176
174
  @exif_mimetype ||= begin
177
175
  check_for_file
178
176
  prefer_exif = !Assembly::TRUSTED_MIMETYPES.include?(file_mimetype) # if it's not a "trusted" mimetype and there is exif data; get the mimetype from the exif
179
- exif.mimetype if
180
- exif&.mimetype && prefer_exif
177
+ exif.mimetype if exif&.mimetype && prefer_exif
181
178
  end
182
179
  end
183
180
 
@@ -272,7 +269,7 @@ exif&.mimetype && prefer_exif
272
269
 
273
270
  # private method to check for file existence before operating on it
274
271
  def check_for_file
275
- raise "input file #{path} does not exist" unless file_exists?
272
+ raise "input file #{path} does not exist or is a directory" unless file_exists?
276
273
  end
277
274
  end
278
275
  end
@@ -3,7 +3,7 @@
3
3
  # Main Assembly namespace
4
4
  module Assembly
5
5
  class ObjectFile
6
- # Project version number
7
- VERSION = '1.12.0'
6
+ # Gem version
7
+ VERSION = '1.13.0'
8
8
  end
9
9
  end
@@ -4,10 +4,10 @@ require 'spec_helper'
4
4
 
5
5
  describe Assembly::ObjectFile do
6
6
  it 'does not run if no input file is passed in' do
7
- @ai = described_class.new('')
8
- expect { @ai.filesize }.to raise_error(RuntimeError, 'input file does not exist')
9
- expect { @ai.sha1 }.to raise_error(RuntimeError, 'input file does not exist')
10
- expect { @ai.md5 }.to raise_error(RuntimeError, 'input file does not exist')
7
+ object_file = described_class.new('')
8
+ expect { object_file.filesize }.to raise_error(RuntimeError, 'input file does not exist or is a directory')
9
+ expect { object_file.sha1 }.to raise_error(RuntimeError, 'input file does not exist or is a directory')
10
+ expect { object_file.md5 }.to raise_error(RuntimeError, 'input file does not exist or is a directory')
11
11
  end
12
12
 
13
13
  it 'returns the common directory of a set of filenames passed into it, where the common part does not terminate on a directory' do
@@ -20,191 +20,191 @@ describe Assembly::ObjectFile do
20
20
 
21
21
  it 'tells us if an input file is an image' do
22
22
  expect(File.exist?(TEST_TIF_INPUT_FILE)).to be true
23
- @ai = described_class.new(TEST_TIF_INPUT_FILE)
24
- expect(@ai.image?).to eq(true)
25
- expect(@ai.exif).not_to be nil
26
- expect(@ai.mimetype).to eq('image/tiff')
27
- expect(@ai.file_mimetype).to eq('image/tiff')
28
- expect(@ai.extension_mimetype).to eq('image/tiff')
29
- expect(@ai.exif_mimetype).to eq('image/tiff')
30
- expect(@ai.object_type).to eq(:image)
31
- expect(@ai.valid_image?).to eq(true)
32
- expect(@ai.jp2able?).to eq(true)
23
+ object_file = described_class.new(TEST_TIF_INPUT_FILE)
24
+ expect(object_file.image?).to be(true)
25
+ expect(object_file.exif).not_to be_nil
26
+ expect(object_file.mimetype).to eq('image/tiff')
27
+ expect(object_file.file_mimetype).to eq('image/tiff')
28
+ expect(object_file.extension_mimetype).to eq('image/tiff')
29
+ expect(object_file.exif_mimetype).to eq('image/tiff')
30
+ expect(object_file.object_type).to eq(:image)
31
+ expect(object_file.valid_image?).to be(true)
32
+ expect(object_file.jp2able?).to be(true)
33
33
  end
34
34
 
35
35
  it 'tells us information about the input file' do
36
- @ai = described_class.new(TEST_TIF_INPUT_FILE)
37
- expect(@ai.filename).to eq('test.tif')
38
- expect(@ai.ext).to eq('.tif')
39
- expect(@ai.filename_without_ext).to eq('test')
40
- expect(@ai.dirname).to eq(File.dirname(TEST_TIF_INPUT_FILE))
36
+ object_file = described_class.new(TEST_TIF_INPUT_FILE)
37
+ expect(object_file.filename).to eq('test.tif')
38
+ expect(object_file.ext).to eq('.tif')
39
+ expect(object_file.filename_without_ext).to eq('test')
40
+ expect(object_file.dirname).to eq(File.dirname(TEST_TIF_INPUT_FILE))
41
41
  end
42
42
 
43
43
  it 'sets the correct mimetype of plain/text for .txt files' do
44
- @ai = described_class.new(TEST_RES1_TEXT)
45
- expect(@ai.mimetype).to eq('text/plain')
44
+ object_file = described_class.new(TEST_RES1_TEXT)
45
+ expect(object_file.mimetype).to eq('text/plain')
46
46
  end
47
47
 
48
48
  it 'sets the correct mimetype of plain/text for .xml files' do
49
- @ai = described_class.new(TEST_RES1_TEXT)
50
- expect(@ai.mimetype).to eq('text/plain')
49
+ object_file = described_class.new(TEST_RES1_TEXT)
50
+ expect(object_file.mimetype).to eq('text/plain')
51
51
  end
52
52
 
53
53
  it 'sets the correct mimetype of plain/text for .obj 3d files' do
54
- @ai = described_class.new(TEST_OBJ_FILE)
55
- expect(@ai.mimetype).to eq('text/plain')
54
+ object_file = described_class.new(TEST_OBJ_FILE)
55
+ expect(object_file.mimetype).to eq('text/plain')
56
56
  end
57
57
 
58
58
  it 'sets a mimetype of application/x-tgif for .obj 3d files if we prefer the mimetype extension gem over unix file system command' do
59
- @ai = described_class.new(TEST_OBJ_FILE, mime_type_order: %i[extension file exif])
60
- expect(@ai.mimetype).to eq('application/x-tgif')
59
+ object_file = described_class.new(TEST_OBJ_FILE, mime_type_order: %i[extension file exif])
60
+ expect(object_file.mimetype).to eq('application/x-tgif')
61
61
  end
62
62
 
63
63
  it 'ignores invald mimetype generation methods and still sets a mimetype of application/x-tgif for .obj 3d files if we prefer the mimetype extension gem over unix file system command' do
64
- @ai = described_class.new(TEST_OBJ_FILE, mime_type_order: %i[bogus extension file])
65
- expect(@ai.mimetype).to eq('application/x-tgif')
64
+ object_file = described_class.new(TEST_OBJ_FILE, mime_type_order: %i[bogus extension file])
65
+ expect(object_file.mimetype).to eq('application/x-tgif')
66
66
  end
67
67
 
68
68
  it 'sets the correct mimetype of plain/text for .ply 3d files' do
69
- @ai = described_class.new(TEST_PLY_FILE)
70
- expect(@ai.mimetype).to eq('text/plain')
69
+ object_file = described_class.new(TEST_PLY_FILE)
70
+ expect(object_file.mimetype).to eq('text/plain')
71
71
  end
72
72
 
73
73
  it 'overrides the mimetype generators and uses the manual mapping to set the correct mimetype of application/json for a .json file' do
74
- @ai = described_class.new(TEST_JSON_FILE)
75
- expect(@ai.exif_mimetype).to be_nil # exif returns nil
76
- expect(@ai.file_mimetype).to eq('text/plain') # unix file system command returns plain text
77
- expect(@ai.mimetype).to eq('application/json') # but our configured mapping overrides both and returns application/json
74
+ object_file = described_class.new(TEST_JSON_FILE)
75
+ expect(object_file.exif_mimetype).to be_nil # exif returns nil
76
+ expect(object_file.file_mimetype).to eq('text/plain') # unix file system command returns plain text
77
+ expect(object_file.mimetype).to eq('application/json') # but our configured mapping overrides both and returns application/json
78
78
  end
79
79
 
80
80
  it 'sets the correct mimetype of image/tiff for .tif files' do
81
- @ai = described_class.new(TEST_TIF_INPUT_FILE)
82
- expect(@ai.mimetype).to eq('image/tiff')
81
+ object_file = described_class.new(TEST_TIF_INPUT_FILE)
82
+ expect(object_file.mimetype).to eq('image/tiff')
83
83
  end
84
84
 
85
85
  it 'sets the correct mimetype of image/jp2 for .jp2 files' do
86
- @ai = described_class.new(TEST_JP2_INPUT_FILE)
87
- expect(@ai.mimetype).to eq('image/jp2')
86
+ object_file = described_class.new(TEST_JP2_INPUT_FILE)
87
+ expect(object_file.mimetype).to eq('image/jp2')
88
88
  end
89
89
 
90
90
  it 'sets the correct mimetype of application/pdf for .pdf files' do
91
- @ai = described_class.new(TEST_RES1_PDF)
92
- expect(@ai.mimetype).to eq('application/pdf')
91
+ object_file = described_class.new(TEST_RES1_PDF)
92
+ expect(object_file.mimetype).to eq('application/pdf')
93
93
  end
94
94
 
95
95
  it 'gives us the mimetype of a file even if the exif information is damaged' do
96
- @ai = described_class.new(TEST_FILE_NO_EXIF)
97
- expect(@ai.filename).to eq('file_with_no_exif.xml')
98
- expect(@ai.ext).to eq('.xml')
99
- expect(['text/html', 'application/xml'].include?(@ai.mimetype)).to be true # we could get either of these mimetypes depending on the OS
96
+ object_file = described_class.new(TEST_FILE_NO_EXIF)
97
+ expect(object_file.filename).to eq('file_with_no_exif.xml')
98
+ expect(object_file.ext).to eq('.xml')
99
+ expect(['text/html', 'application/xml'].include?(object_file.mimetype)).to be true # we could get either of these mimetypes depending on the OS
100
100
  end
101
101
 
102
102
  it 'gives us the DPG base name for a file' do
103
103
  test_file = File.join(TEST_INPUT_DIR, 'oo000oo0001_00_001.tif')
104
- @ai = described_class.new(test_file)
105
- expect(@ai.dpg_basename).to eq('oo000oo0001_001')
104
+ object_file = described_class.new(test_file)
105
+ expect(object_file.dpg_basename).to eq('oo000oo0001_001')
106
106
  end
107
107
 
108
108
  it 'gives us the DPG subfolder name for a file' do
109
109
  test_file = File.join(TEST_INPUT_DIR, 'oo000oo0001_05_001.tif')
110
- @ai = described_class.new(test_file)
111
- expect(@ai.dpg_folder).to eq('05')
110
+ object_file = described_class.new(test_file)
111
+ expect(object_file.dpg_folder).to eq('05')
112
112
  end
113
113
 
114
114
  it 'tells us that a jp2 file is not jp2able but does have a color profile' do
115
115
  expect(File.exist?(TEST_JP2_INPUT_FILE)).to be true
116
- @ai = described_class.new(TEST_JP2_INPUT_FILE)
117
- expect(@ai.image?).to eq(true)
118
- expect(@ai.object_type).to eq(:image)
119
- expect(@ai.valid_image?).to eq(true)
120
- expect(@ai.jp2able?).to eq(false)
121
- expect(@ai.has_color_profile?).to eq(true)
116
+ object_file = described_class.new(TEST_JP2_INPUT_FILE)
117
+ expect(object_file.image?).to be(true)
118
+ expect(object_file.object_type).to eq(:image)
119
+ expect(object_file.valid_image?).to be(true)
120
+ expect(object_file.jp2able?).to be(false)
121
+ expect(object_file.has_color_profile?).to be(true)
122
122
  end
123
123
 
124
124
  it 'tells us that a tiff file is jp2able and has a color profile' do
125
125
  expect(File.exist?(TEST_RES1_TIF1)).to be true
126
- @ai = described_class.new(TEST_RES1_TIF1)
127
- expect(@ai.image?).to eq(true)
128
- expect(@ai.object_type).to eq(:image)
129
- expect(@ai.valid_image?).to eq(true)
130
- expect(@ai.jp2able?).to eq(true)
131
- expect(@ai.has_color_profile?).to eq(true)
126
+ object_file = described_class.new(TEST_RES1_TIF1)
127
+ expect(object_file.image?).to be(true)
128
+ expect(object_file.object_type).to eq(:image)
129
+ expect(object_file.valid_image?).to be(true)
130
+ expect(object_file.jp2able?).to be(true)
131
+ expect(object_file.has_color_profile?).to be(true)
132
132
  end
133
133
 
134
134
  it 'tells us that a tiff file is not jp2able and is not valid since it has no profile' do
135
135
  expect(File.exist?(TEST_TIFF_NO_COLOR_FILE)).to be true
136
- @ai = described_class.new(TEST_TIFF_NO_COLOR_FILE)
137
- expect(@ai.image?).to eq(true)
138
- expect(@ai.object_type).to eq(:image)
139
- expect(@ai.valid_image?).to eq(true)
140
- expect(@ai.jp2able?).to eq(true)
141
- expect(@ai.has_color_profile?).to eq(false)
136
+ object_file = described_class.new(TEST_TIFF_NO_COLOR_FILE)
137
+ expect(object_file.image?).to be(true)
138
+ expect(object_file.object_type).to eq(:image)
139
+ expect(object_file.valid_image?).to be(true)
140
+ expect(object_file.jp2able?).to be(true)
141
+ expect(object_file.has_color_profile?).to be(false)
142
142
  end
143
143
 
144
144
  it 'computes checksums for an image file' do
145
145
  expect(File.exist?(TEST_TIF_INPUT_FILE)).to be true
146
- @ai = described_class.new(TEST_TIF_INPUT_FILE)
147
- expect(@ai.md5).to eq('a2400500acf21e43f5440d93be894101')
148
- expect(@ai.sha1).to eq('8d11fab63089a24c8b17063d29a4b0eac359fb41')
146
+ object_file = described_class.new(TEST_TIF_INPUT_FILE)
147
+ expect(object_file.md5).to eq('a2400500acf21e43f5440d93be894101')
148
+ expect(object_file.sha1).to eq('8d11fab63089a24c8b17063d29a4b0eac359fb41')
149
149
  end
150
150
 
151
151
  it 'indicates that the file is not found when a valid directory is supplied instead of a file or when an invalid file path is specified' do
152
152
  path = Assembly::PATH_TO_GEM
153
- @ai = described_class.new(path)
153
+ object_file = described_class.new(path)
154
154
  expect(File.exist?(path)).to be true
155
155
  expect(File.directory?(path)).to be true
156
- expect(@ai.file_exists?).to be false
156
+ expect(object_file.file_exists?).to be false
157
157
 
158
158
  path = File.join(Assembly::PATH_TO_GEM, 'bogus.txt')
159
- @ai = described_class.new(path)
159
+ object_file = described_class.new(path)
160
160
  expect(File.exist?(path)).to be false
161
161
  expect(File.directory?(path)).to be false
162
- expect(@ai.file_exists?).to be false
162
+ expect(object_file.file_exists?).to be false
163
163
  end
164
164
 
165
165
  it 'sets attributes correctly when initializing' do
166
- @ai = described_class.new('/some/file.txt')
167
- expect(@ai.path).to eq('/some/file.txt')
168
- expect(@ai.label).to be_nil
169
- expect(@ai.file_attributes).to be_nil
170
- expect(@ai.provider_sha1).to be_nil
171
- expect(@ai.provider_md5).to be_nil
172
- expect(@ai.relative_path).to be_nil
173
-
174
- @ai = described_class.new('/some/file.txt', label: 'some label', file_attributes: { 'shelve' => 'yes', 'publish' => 'yes', 'preserve' => 'no' }, relative_path: '/tmp')
175
- expect(@ai.path).to eq('/some/file.txt')
176
- expect(@ai.label).to eq('some label')
177
- expect(@ai.file_attributes).to eq('shelve' => 'yes', 'publish' => 'yes', 'preserve' => 'no')
178
- expect(@ai.provider_sha1).to be_nil
179
- expect(@ai.provider_md5).to be_nil
180
- expect(@ai.relative_path).to eq('/tmp')
166
+ object_file = described_class.new('/some/file.txt')
167
+ expect(object_file.path).to eq('/some/file.txt')
168
+ expect(object_file.label).to be_nil
169
+ expect(object_file.file_attributes).to be_nil
170
+ expect(object_file.provider_sha1).to be_nil
171
+ expect(object_file.provider_md5).to be_nil
172
+ expect(object_file.relative_path).to be_nil
173
+
174
+ object_file = described_class.new('/some/file.txt', label: 'some label', file_attributes: { 'shelve' => 'yes', 'publish' => 'yes', 'preserve' => 'no' }, relative_path: '/tmp')
175
+ expect(object_file.path).to eq('/some/file.txt')
176
+ expect(object_file.label).to eq('some label')
177
+ expect(object_file.file_attributes).to eq('shelve' => 'yes', 'publish' => 'yes', 'preserve' => 'no')
178
+ expect(object_file.provider_sha1).to be_nil
179
+ expect(object_file.provider_md5).to be_nil
180
+ expect(object_file.relative_path).to eq('/tmp')
181
181
  end
182
182
 
183
183
  it 'sets md5_provider attribute' do
184
- ai = described_class.new('/some/file.txt', provider_md5: 'XYZ')
185
- expect(ai.provider_md5).to eq('XYZ')
184
+ object_file = described_class.new('/some/file.txt', provider_md5: 'XYZ')
185
+ expect(object_file.provider_md5).to eq('XYZ')
186
186
  end
187
187
 
188
188
  it 'tells us if an input file is not an image' do
189
189
  non_image_file = File.join(Assembly::PATH_TO_GEM, 'spec/object_file_spec.rb')
190
190
  expect(File.exist?(non_image_file)).to be true
191
- @ai = described_class.new(non_image_file)
192
- expect(@ai.image?).to eq(false)
193
- expect(@ai.object_type).not_to eq(:image)
194
- expect(@ai.valid_image?).to eq(false)
191
+ object_file = described_class.new(non_image_file)
192
+ expect(object_file.image?).to be(false)
193
+ expect(object_file.object_type).not_to eq(:image)
194
+ expect(object_file.valid_image?).to be(false)
195
195
 
196
196
  non_image_file = File.join(Assembly::PATH_TO_GEM, 'spec/test_data/input/file_with_no_exif.xml')
197
197
  expect(File.exist?(non_image_file)).to be true
198
- @ai = described_class.new(non_image_file)
199
- expect(@ai.image?).to eq(false)
200
- expect(@ai.object_type).not_to eq(:image)
201
- expect(@ai.valid_image?).to eq(false)
198
+ object_file = described_class.new(non_image_file)
199
+ expect(object_file.image?).to be(false)
200
+ expect(object_file.object_type).not_to eq(:image)
201
+ expect(object_file.valid_image?).to be(false)
202
202
  end
203
203
 
204
204
  it 'tells us the size of an input file' do
205
205
  expect(File.exist?(TEST_TIF_INPUT_FILE)).to be true
206
- @ai = described_class.new(TEST_TIF_INPUT_FILE)
207
- expect(@ai.filesize).to eq(63_542)
206
+ object_file = described_class.new(TEST_TIF_INPUT_FILE)
207
+ expect(object_file.filesize).to eq(63_542)
208
208
  end
209
209
 
210
210
  it 'tells us the mimetype and encoding of an input file' do
@@ -214,4 +214,9 @@ describe Assembly::ObjectFile do
214
214
  expect(@ai.file_mimetype).to eq('image/tiff')
215
215
  expect(@ai.encoding).to eq('binary')
216
216
  end
217
+
218
+ it 'raises MiniExiftool::Error if exiftool raises one' do
219
+ object_file = described_class.new('spec/test_data/empty.txt')
220
+ expect { object_file.exif }.to raise_error(MiniExiftool::Error)
221
+ end
217
222
  end
File without changes
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: 1.12.0
4
+ version: 1.13.0
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-02-18 00:00:00.000000000 Z
14
+ date: 2022-06-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -157,16 +157,16 @@ dependencies:
157
157
  name: rubocop
158
158
  requirement: !ruby/object:Gem::Requirement
159
159
  requirements:
160
- - - ">="
160
+ - - "~>"
161
161
  - !ruby/object:Gem::Version
162
- version: '0'
162
+ version: '1.25'
163
163
  type: :development
164
164
  prerelease: false
165
165
  version_requirements: !ruby/object:Gem::Requirement
166
166
  requirements:
167
- - - ">="
167
+ - - "~>"
168
168
  - !ruby/object:Gem::Version
169
- version: '0'
169
+ version: '1.25'
170
170
  - !ruby/object:Gem::Dependency
171
171
  name: rubocop-rspec
172
172
  requirement: !ruby/object:Gem::Requirement
@@ -185,16 +185,16 @@ dependencies:
185
185
  name: simplecov
186
186
  requirement: !ruby/object:Gem::Requirement
187
187
  requirements:
188
- - - "~>"
188
+ - - ">="
189
189
  - !ruby/object:Gem::Version
190
- version: 0.17.0
190
+ version: '0'
191
191
  type: :development
192
192
  prerelease: false
193
193
  version_requirements: !ruby/object:Gem::Requirement
194
194
  requirements:
195
- - - "~>"
195
+ - - ">="
196
196
  - !ruby/object:Gem::Version
197
- version: 0.17.0
197
+ version: '0'
198
198
  description: Get exif data, file sizes and more.
199
199
  email:
200
200
  - pmangiafico@stanford.edu
@@ -202,13 +202,13 @@ executables: []
202
202
  extensions: []
203
203
  extra_rdoc_files: []
204
204
  files:
205
+ - ".circleci/config.yml"
205
206
  - ".github/ISSUE_TEMPLATE/bug_report.md"
206
207
  - ".github/pull_request_template.md"
207
208
  - ".gitignore"
208
209
  - ".rubocop.yml"
209
210
  - ".rubocop_todo.yml"
210
211
  - ".rvmrc.example"
211
- - ".travis.yml"
212
212
  - Gemfile
213
213
  - LICENSE
214
214
  - README.md
@@ -233,6 +233,7 @@ files:
233
233
  - spec/content_metadata_spec.rb
234
234
  - spec/object_file_spec.rb
235
235
  - spec/spec_helper.rb
236
+ - spec/test_data/empty.txt
236
237
  - spec/test_data/input/.empty
237
238
  - spec/test_data/input/file_with_no_exif.xml
238
239
  - spec/test_data/input/oo000oo0001/00/oo000oo0001_00_001.tif
@@ -273,7 +274,8 @@ files:
273
274
  homepage: https://github.com/sul-dlss/assembly-objectfile
274
275
  licenses:
275
276
  - ALv2
276
- metadata: {}
277
+ metadata:
278
+ rubygems_mfa_required: 'true'
277
279
  post_install_message:
278
280
  rdoc_options: []
279
281
  require_paths:
@@ -282,10 +284,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
282
284
  requirements:
283
285
  - - ">="
284
286
  - !ruby/object:Gem::Version
285
- version: '2.5'
286
- - - "<"
287
- - !ruby/object:Gem::Version
288
- version: '4'
287
+ version: '3.0'
289
288
  required_rubygems_version: !ruby/object:Gem::Requirement
290
289
  requirements:
291
290
  - - ">="
@@ -301,6 +300,7 @@ test_files:
301
300
  - spec/content_metadata_spec.rb
302
301
  - spec/object_file_spec.rb
303
302
  - spec/spec_helper.rb
303
+ - spec/test_data/empty.txt
304
304
  - spec/test_data/input/.empty
305
305
  - spec/test_data/input/file_with_no_exif.xml
306
306
  - spec/test_data/input/oo000oo0001/00/oo000oo0001_00_001.tif
data/.travis.yml DELETED
@@ -1,20 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.5.7
4
- - 2.6.5
5
- addons:
6
- apt:
7
- packages:
8
- - libimage-exiftool-perl
9
- before_script:
10
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
11
- - chmod +x ./cc-test-reporter
12
- - ./cc-test-reporter before-build
13
- script:
14
- - bundle exec rubocop
15
- - bundle exec rake
16
- after_script:
17
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
18
-
19
- notifications:
20
- email: false