assembly-objectfile 2.1.2 → 2.1.4

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: '0931aac97a88ba77ac0cfa8ff018d19fddcfe909c81cd82e9dfc13dca12ed4f4'
4
- data.tar.gz: 4eb596c2799586b3298cd1019be16606b4a371a175c4630b1ac826296dacb5bb
3
+ metadata.gz: 808727d8b4ab8ff12dd01249accf0d2a88e6821349d23950c2b8aaa2a1913391
4
+ data.tar.gz: 406feb2ba9a205ec1bb3bd9aafa8a95b87ebb6f815cbb025f6e437467ab5e2dc
5
5
  SHA512:
6
- metadata.gz: a252cfc25b6e2a11f50a6eb2976997fdcbf387ba3855fbca03d188a2f7e9572ca1a3ed605da191700551e34a685deb9dec810e63dfbff59bf9bfd09f6a6a9504
7
- data.tar.gz: db0fdbf6583455bce118aa14bc29692d90fbb35c1e9746f3748548094ff53e0f33fe79c08cf5baace3869a08e4f9e3080d1906b810ce38d64022efa573e8c500
6
+ metadata.gz: de4086ae3355a75b2bdcdf95e077215b9076b607792648404004176e09c7d724dc3c3b441a89a69149f86717461651eb89c9e0d1e83582897214ba9bce600144
7
+ data.tar.gz: 125078c8caf3b6f2d4fb9d17a6bd41ae622894586648cfc43a67530744cfa474505b1ddc32f3ecf51079bbcdb88978c504522a05bf3d185221da523befc9d1d0
data/.circleci/config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  version: 2.1
2
2
  orbs:
3
- ruby-rails: sul-dlss/ruby-rails@3.1.2
3
+ ruby-rails: sul-dlss/ruby-rails@3.2.0
4
4
  workflows:
5
5
  build:
6
6
  jobs:
data/.gitignore CHANGED
@@ -2,8 +2,7 @@
2
2
  *.gem
3
3
  .DS_Store
4
4
  .bundle
5
- config/certs/*
6
- config/environments/*
5
+ .rspec_status
7
6
  coverage/*
8
7
  doc/*
9
8
  log/*
data/.rubocop.yml CHANGED
@@ -1,14 +1,26 @@
1
- inherit_from: .rubocop_todo.yml
2
1
  require: rubocop-rspec
3
2
 
3
+ inherit_from: .rubocop_todo.yml
4
+
4
5
  AllCops:
5
6
  TargetRubyVersion: 3.0
7
+ SuggestExtensions: false
6
8
  DisplayCopNames: true
9
+ Include:
10
+ - './Rakefile' # rake only
11
+ - '**/*.rb'
7
12
  Exclude:
13
+ # autogenerated files (that we don't change) should go here
8
14
  - 'Gemfile.lock'
9
15
  - '**/*.md'
16
+ - spec/spec_helper.rb
10
17
  - 'vendor/**/*' # avoid running rubocop on cached bundler
11
18
 
19
+ Bundler/GemComment:
20
+ OnlyFor:
21
+ - restrictive_version_specifiers
22
+ - branch
23
+
12
24
  Layout/LineLength:
13
25
  Max: 120
14
26
 
@@ -26,125 +38,93 @@ Metrics/BlockLength:
26
38
  - '**/*.gemspec'
27
39
 
28
40
  RSpec/ExampleLength:
29
- Max: 10
41
+ Enabled: false
30
42
 
31
43
  RSpec/MultipleExpectations:
32
- Max: 10
44
+ Max: 6 # default 1
45
+ Exclude:
46
+ - spec/features/**/*_spec.rb
47
+
48
+ RSpec/MultipleMemoizedHelpers:
49
+ Enabled: false
33
50
 
34
51
  RSpec/NestedGroups:
35
- Max: 4
52
+ Max: 4 # default: 3
36
53
 
37
54
  Gemspec/DeprecatedAttributeAssignment: # (new in 1.10)
38
55
  Enabled: true
39
-
40
56
  Layout/SpaceAroundMethodCallOperator:
41
57
  Enabled: true
42
-
43
58
  Layout/EmptyLinesAroundAttributeAccessor:
44
59
  Enabled: true
45
-
46
60
  Layout/SpaceBeforeBrackets: # (new in 1.7)
47
61
  Enabled: true
48
-
49
62
  Lint/AmbiguousAssignment: # (new in 1.7)
50
63
  Enabled: true
51
-
52
64
  Lint/DeprecatedConstants: # (new in 1.8)
53
65
  Enabled: true
54
-
55
66
  Lint/DuplicateBranch: # (new in 1.3)
56
67
  Enabled: true
57
-
58
68
  Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
59
69
  Enabled: true
60
-
61
70
  Lint/EmptyBlock: # (new in 1.1)
62
71
  Enabled: true
63
-
64
72
  Lint/EmptyClass: # (new in 1.3)
65
73
  Enabled: true
66
-
67
74
  Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
68
75
  Enabled: true
69
-
70
76
  Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
71
77
  Enabled: true
72
-
73
78
  Lint/NumberedParameterAssignment: # (new in 1.9)
74
79
  Enabled: true
75
-
76
80
  Lint/OrAssignmentToConstant: # (new in 1.9)
77
81
  Enabled: true
78
-
79
82
  Lint/RedundantDirGlobSort: # (new in 1.8)
80
83
  Enabled: true
81
-
82
84
  Lint/SymbolConversion: # (new in 1.9)
83
85
  Enabled: true
84
-
85
86
  Lint/ToEnumArguments: # (new in 1.1)
86
87
  Enabled: true
87
-
88
88
  Lint/TripleQuotes: # (new in 1.9)
89
89
  Enabled: true
90
-
91
90
  Lint/UnexpectedBlockArity: # (new in 1.5)
92
91
  Enabled: true
93
-
94
92
  Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
95
93
  Enabled: true
96
-
97
94
  Lint/RaiseException:
98
95
  Enabled: true
99
-
100
96
  Lint/StructNewOverride:
101
97
  Enabled: true
102
-
103
98
  Style/ExponentialNotation:
104
99
  Enabled: true
105
-
106
100
  Style/HashEachMethods:
107
101
  Enabled: true
108
-
109
102
  Style/HashTransformKeys:
110
103
  Enabled: true
111
-
112
104
  Style/HashTransformValues:
113
105
  Enabled: true
114
-
115
106
  Style/SlicingWithRange:
116
107
  Enabled: true
117
-
118
108
  Style/ArgumentsForwarding: # (new in 1.1)
119
109
  Enabled: true
120
-
121
110
  Style/CollectionCompact: # (new in 1.2)
122
111
  Enabled: true
123
-
124
112
  Style/DocumentDynamicEvalDefinition: # (new in 1.1)
125
113
  Enabled: true
126
-
127
114
  Style/EndlessMethod: # (new in 1.8)
128
115
  Enabled: true
129
-
130
116
  Style/HashConversion: # (new in 1.10)
131
117
  Enabled: true
132
-
133
118
  Style/HashExcept: # (new in 1.7)
134
119
  Enabled: true
135
-
136
120
  Style/IfWithBooleanLiteralBranches: # (new in 1.9)
137
121
  Enabled: true
138
-
139
122
  Style/NegatedIfElseCondition: # (new in 1.2)
140
123
  Enabled: true
141
-
142
124
  Style/NilLambda: # (new in 1.3)
143
125
  Enabled: true
144
-
145
126
  Style/RedundantArgument: # (new in 1.4)
146
127
  Enabled: true
147
-
148
128
  Style/SwapValues: # (new in 1.1)
149
129
  Enabled: true
150
130
 
@@ -240,3 +220,16 @@ RSpec/Capybara/SpecificMatcher: # new in 2.12
240
220
  Enabled: true
241
221
  RSpec/Rails/HaveHttpStatus: # new in 2.12
242
222
  Enabled: true
223
+
224
+ Lint/RequireRangeParentheses: # new in 1.32
225
+ Enabled: true
226
+ Style/EmptyHeredoc: # new in 1.32
227
+ Enabled: true
228
+ Style/MagicCommentFormat: # new in 1.35
229
+ Enabled: true
230
+ RSpec/ClassCheck: # new in 2.13
231
+ Enabled: true
232
+ RSpec/NoExpectationExample: # new in 2.13
233
+ Enabled: true
234
+ RSpec/Capybara/SpecificFinders: # new in 2.13
235
+ Enabled: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- assembly-objectfile (2.1.2)
4
+ assembly-objectfile (2.1.4)
5
5
  activesupport (>= 5.2.0)
6
6
  mime-types (> 3)
7
7
  mini_exiftool
@@ -9,7 +9,7 @@ PATH
9
9
  GEM
10
10
  remote: http://rubygems.org/
11
11
  specs:
12
- activesupport (7.0.3.1)
12
+ activesupport (7.0.4.3)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 1.6, < 2)
15
15
  minitest (>= 5.1)
@@ -17,68 +17,74 @@ GEM
17
17
  ast (2.4.2)
18
18
  byebug (11.1.3)
19
19
  coderay (1.1.3)
20
- concurrent-ruby (1.1.10)
20
+ concurrent-ruby (1.2.2)
21
21
  diff-lcs (1.5.0)
22
22
  docile (1.4.0)
23
- i18n (1.12.0)
23
+ i18n (1.13.0)
24
24
  concurrent-ruby (~> 1.0)
25
- json (2.6.2)
25
+ json (2.6.3)
26
26
  method_source (1.0.0)
27
27
  mime-types (3.4.1)
28
28
  mime-types-data (~> 3.2015)
29
- mime-types-data (3.2022.0105)
29
+ mime-types-data (3.2023.0218.1)
30
30
  mini_exiftool (2.10.2)
31
- minitest (5.16.3)
32
- parallel (1.22.1)
33
- parser (3.1.2.1)
31
+ minitest (5.18.0)
32
+ parallel (1.23.0)
33
+ parser (3.2.2.1)
34
34
  ast (~> 2.4.1)
35
- pry (0.13.1)
35
+ pry (0.14.2)
36
36
  coderay (~> 1.1)
37
37
  method_source (~> 1.0)
38
- pry-byebug (3.9.0)
38
+ pry-byebug (3.10.1)
39
39
  byebug (~> 11.0)
40
- pry (~> 0.13.0)
40
+ pry (>= 0.13, < 0.15)
41
41
  rainbow (3.1.1)
42
42
  rake (13.0.6)
43
- regexp_parser (2.5.0)
43
+ regexp_parser (2.8.0)
44
44
  rexml (3.2.5)
45
- rspec (3.11.0)
46
- rspec-core (~> 3.11.0)
47
- rspec-expectations (~> 3.11.0)
48
- rspec-mocks (~> 3.11.0)
49
- rspec-core (3.11.0)
50
- rspec-support (~> 3.11.0)
51
- rspec-expectations (3.11.0)
45
+ rspec (3.12.0)
46
+ rspec-core (~> 3.12.0)
47
+ rspec-expectations (~> 3.12.0)
48
+ rspec-mocks (~> 3.12.0)
49
+ rspec-core (3.12.2)
50
+ rspec-support (~> 3.12.0)
51
+ rspec-expectations (3.12.3)
52
52
  diff-lcs (>= 1.2.0, < 2.0)
53
- rspec-support (~> 3.11.0)
54
- rspec-mocks (3.11.1)
53
+ rspec-support (~> 3.12.0)
54
+ rspec-mocks (3.12.5)
55
55
  diff-lcs (>= 1.2.0, < 2.0)
56
- rspec-support (~> 3.11.0)
57
- rspec-support (3.11.0)
58
- rubocop (1.35.0)
56
+ rspec-support (~> 3.12.0)
57
+ rspec-support (3.12.0)
58
+ rubocop (1.50.2)
59
59
  json (~> 2.3)
60
60
  parallel (~> 1.10)
61
- parser (>= 3.1.2.1)
61
+ parser (>= 3.2.0.0)
62
62
  rainbow (>= 2.2.2, < 4.0)
63
63
  regexp_parser (>= 1.8, < 3.0)
64
64
  rexml (>= 3.2.5, < 4.0)
65
- rubocop-ast (>= 1.20.1, < 2.0)
65
+ rubocop-ast (>= 1.28.0, < 2.0)
66
66
  ruby-progressbar (~> 1.7)
67
- unicode-display_width (>= 1.4.0, < 3.0)
68
- rubocop-ast (1.21.0)
69
- parser (>= 3.1.1.0)
70
- rubocop-rspec (2.12.1)
71
- rubocop (~> 1.31)
72
- ruby-progressbar (1.11.0)
73
- simplecov (0.21.2)
67
+ unicode-display_width (>= 2.4.0, < 3.0)
68
+ rubocop-ast (1.28.1)
69
+ parser (>= 3.2.1.0)
70
+ rubocop-capybara (2.18.0)
71
+ rubocop (~> 1.41)
72
+ rubocop-factory_bot (2.22.0)
73
+ rubocop (~> 1.33)
74
+ rubocop-rspec (2.22.0)
75
+ rubocop (~> 1.33)
76
+ rubocop-capybara (~> 2.17)
77
+ rubocop-factory_bot (~> 2.22)
78
+ ruby-progressbar (1.13.0)
79
+ simplecov (0.22.0)
74
80
  docile (~> 1.1)
75
81
  simplecov-html (~> 0.11)
76
82
  simplecov_json_formatter (~> 0.1)
77
83
  simplecov-html (0.12.3)
78
84
  simplecov_json_formatter (0.1.4)
79
- tzinfo (2.0.5)
85
+ tzinfo (2.0.6)
80
86
  concurrent-ruby (~> 1.0)
81
- unicode-display_width (2.2.0)
87
+ unicode-display_width (2.4.2)
82
88
 
83
89
  PLATFORMS
84
90
  ruby
@@ -94,4 +100,4 @@ DEPENDENCIES
94
100
  simplecov
95
101
 
96
102
  BUNDLED WITH
97
- 2.3.17
103
+ 2.4.13
@@ -4,6 +4,6 @@
4
4
  module Assembly
5
5
  class ObjectFile
6
6
  # Gem version
7
- VERSION = '2.1.2'
7
+ VERSION = '2.1.4'
8
8
  end
9
9
  end
@@ -11,8 +11,8 @@ module Assembly
11
11
  # @return [String] longest common initial path of filenames passed in
12
12
  #
13
13
  # Example:
14
- # puts Assembly::ObjectFile.common_prefix(['/Users/peter/00/test.tif','/Users/peter/05/test.jp2'])
15
- # # => '/Users/peter/0'
14
+ # puts Assembly::ObjectFile.common_path(['/Users/peter/00/test.tif','/Users/peter/05/test.jp2'])
15
+ # # => '/Users/peter/'
16
16
  def self.common_path(strings)
17
17
  return nil if strings.empty?
18
18
 
@@ -27,7 +27,7 @@ module Assembly
27
27
  end
28
28
  end
29
29
 
30
- attr_accessor :file_attributes, :label, :path, :provider_md5, :provider_sha1, :relative_path, :mime_type_order
30
+ attr_accessor :file_attributes, :label, :path, :provider_md5, :relative_path, :mime_type_order
31
31
 
32
32
  VALID_MIMETYPE_METHODS = %i[override exif file extension].freeze
33
33
 
@@ -39,7 +39,6 @@ module Assembly
39
39
  # @option params [String] :label a resource label (files bundled together will just get the first
40
40
  # file's label attribute if set)
41
41
  # @option params [String] :provider_md5 pre-computed MD5 checksum
42
- # @option params [String] :provider_sha1 pre-computed SHA1 checksum
43
42
  # @option params [String] :relative_path if you want the file ids in the content metadata it can be set,
44
43
  # otherwise content metadata will get the full path
45
44
  # @option params [Array] :mime_type_order can be set to the order in which you want mimetypes to be determined
@@ -55,7 +54,6 @@ module Assembly
55
54
  @file_attributes = params[:file_attributes]
56
55
  @relative_path = params[:relative_path]
57
56
  @provider_md5 = params[:provider_md5]
58
- @provider_sha1 = params[:provider_sha1]
59
57
  @mime_type_order = params[:mime_type_order] || default_mime_type_order
60
58
  end
61
59
 
@@ -90,13 +88,13 @@ module Assembly
90
88
  # @return [String] computed md5 checksum
91
89
  def md5
92
90
  check_for_file unless @md5
93
- @md5 ||= Digest::MD5.file(path).hexdigest
91
+ @md5 ||= Digest(:MD5).file(path).hexdigest
94
92
  end
95
93
 
96
94
  # @return [String] computed sha1 checksum
97
95
  def sha1
98
96
  check_for_file unless @sha1
99
- @sha1 ||= Digest::SHA1.file(path).hexdigest
97
+ @sha1 ||= Digest(:SHA1).file(path).hexdigest
100
98
  end
101
99
 
102
100
  # Returns mimetype information for the current file based on the ordering set in default_mime_type_order
@@ -121,12 +119,17 @@ module Assembly
121
119
  lookup.nil? ? :other : lookup.media_type.to_sym
122
120
  end
123
121
 
124
- # @return [Boolean] true if the mime-types gem recognizes it as an image (from file extension lookup)
122
+ # @return [Boolean] true if the mime-types gem recognizes it as an image
125
123
  def image?
126
- object_type == :image
124
+ return false if object_type != :image
125
+
126
+ # We exclude TARGA images here because we've seen where the file is a disk image and
127
+ # when we look for a mime type it is `image/x-tga', however it is not
128
+ # recognizable by exiftool. See https://github.com/sul-dlss/assembly-objectfile/issues/98
129
+ mimetype != 'image/x-tga'
127
130
  end
128
131
 
129
- # @return [Boolean] true if the mime-types gem recognizes it as an image (from file extension lookup)
132
+ # @return [Boolean] true if the mime-types gem recognizes it as an image
130
133
  # AND it is a jp2 or jp2able?
131
134
  def valid_image?
132
135
  return false unless image?
@@ -3,6 +3,19 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Assembly::ObjectFile do
6
+ let(:root_path) { File.expand_path("#{File.dirname(__dir__)}/..") }
7
+ let(:fixture_input_dir) { File.join(root_path, 'spec', 'fixtures', 'input') }
8
+ let(:tif_fixture_file) { File.join(fixture_input_dir, 'test.tif') }
9
+ let(:jp2_fixture_file) { File.join(fixture_input_dir, 'test.jp2') }
10
+ let(:tiff_no_color_fixture_file) { File.join(fixture_input_dir, 'test_no_color_profile.tif') }
11
+ let(:resource1_tif_fixture_file) { File.join(fixture_input_dir, 'res1_image1.tif') }
12
+ let(:resource1_text_fixture_file) { File.join(fixture_input_dir, 'res1_textfile.txt') }
13
+ let(:resource1_pdf_fixture_file) { File.join(fixture_input_dir, 'res1_transcript.pdf') }
14
+ let(:no_exif_fixture_file) { File.join(fixture_input_dir, 'file_with_no_exif.xml') }
15
+ let(:json_fixture_file) { File.join(fixture_input_dir, 'test.json') }
16
+ let(:obj_fixture_file) { File.join(fixture_input_dir, 'someobject.obj') }
17
+ let(:ply_fixture_file) { File.join(fixture_input_dir, 'someobject.ply') }
18
+
6
19
  describe '.common_path' do
7
20
  context 'when common path is 2 nodes out of 4' do
8
21
  it 'returns the common directory' do
@@ -33,7 +46,6 @@ describe Assembly::ObjectFile do
33
46
  expect(object_file.path).to eq('/some/file.txt')
34
47
  expect(object_file.label).to be_nil
35
48
  expect(object_file.file_attributes).to be_nil
36
- expect(object_file.provider_sha1).to be_nil
37
49
  expect(object_file.provider_md5).to be_nil
38
50
  expect(object_file.relative_path).to be_nil
39
51
  end
@@ -52,7 +64,6 @@ describe Assembly::ObjectFile do
52
64
  expect(object_file.path).to eq('/some/file.txt')
53
65
  expect(object_file.label).to eq('some label')
54
66
  expect(object_file.file_attributes).to eq('shelve' => 'yes', 'publish' => 'yes', 'preserve' => 'no')
55
- expect(object_file.provider_sha1).to be_nil
56
67
  expect(object_file.provider_md5).to be_nil
57
68
  expect(object_file.relative_path).to eq('/tmp')
58
69
  end
@@ -69,83 +80,90 @@ describe Assembly::ObjectFile do
69
80
 
70
81
  describe '#filename' do
71
82
  it 'returns File.basename' do
72
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
83
+ object_file = described_class.new(tif_fixture_file)
73
84
  expect(object_file.filename).to eq('test.tif')
74
- expect(object_file.filename).to eq(File.basename(TEST_TIF_INPUT_FILE))
85
+ expect(object_file.filename).to eq(File.basename(tif_fixture_file))
75
86
  end
76
87
  end
77
88
 
78
89
  describe '#ext' do
79
90
  it 'returns the file extension' do
80
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
91
+ object_file = described_class.new(tif_fixture_file)
81
92
  expect(object_file.ext).to eq('.tif')
82
93
  end
83
94
  end
84
95
 
85
96
  describe '#dirname' do
86
97
  it 'returns the File.dirname' do
87
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
88
- expect(object_file.dirname).to eq(File.dirname(TEST_TIF_INPUT_FILE))
98
+ object_file = described_class.new(tif_fixture_file)
99
+ expect(object_file.dirname).to eq(File.dirname(tif_fixture_file))
89
100
  end
90
101
  end
91
102
 
92
103
  describe '#filename_without_ext' do
93
104
  it 'returns filename before extension' do
94
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
105
+ object_file = described_class.new(tif_fixture_file)
95
106
  expect(object_file.filename_without_ext).to eq('test')
96
107
  end
97
108
  end
98
109
 
99
110
  describe '#image?' do
111
+ subject { object_file.image? }
112
+
100
113
  context 'with tiff' do
101
- it 'true' do
102
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
103
- expect(object_file.image?).to be(true)
104
- end
114
+ let(:object_file) { described_class.new(tif_fixture_file) }
115
+
116
+ it { is_expected.to be true }
105
117
  end
106
118
 
107
119
  context 'with jp2' do
108
- it 'true' do
109
- object_file = described_class.new(TEST_JP2_INPUT_FILE)
110
- expect(object_file.image?).to be(true)
120
+ let(:object_file) { described_class.new(jp2_fixture_file) }
121
+
122
+ it { is_expected.to be true }
123
+ end
124
+
125
+ context 'with targa file' do
126
+ before do
127
+ allow(object_file).to receive(:exif_mimetype).and_return(nil)
128
+ allow(object_file).to receive(:file_mimetype).and_return('image/x-tga')
111
129
  end
130
+
131
+ let(:object_file) { described_class.new(jp2_fixture_file) }
132
+
133
+ it { is_expected.to be false }
112
134
  end
113
135
 
114
136
  context 'with ruby file' do
115
- it 'false' do
116
- non_image_file = File.join(PATH_TO_GEM, 'spec/assembly/object_file_spec.rb')
117
- object_file = described_class.new(non_image_file)
118
- expect(object_file.image?).to be(false)
119
- end
137
+ let(:object_file) { described_class.new(File.join(root_path, 'spec/assembly/object_file_spec.rb')) }
138
+
139
+ it { is_expected.to be false }
120
140
  end
121
141
 
122
142
  context 'with xml' do
123
- it 'false' do
124
- non_image_file = File.join(PATH_TO_GEM, 'spec/test_data/input/file_with_no_exif.xml')
125
- object_file = described_class.new(non_image_file)
126
- expect(object_file.image?).to be(false)
127
- end
143
+ let(:object_file) { described_class.new(File.join(fixture_input_dir, 'file_with_no_exif.xml')) }
144
+
145
+ it { is_expected.to be false }
128
146
  end
129
147
  end
130
148
 
131
149
  describe '#object_type' do
132
150
  context 'with tiff' do
133
151
  it ':image' do
134
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
152
+ object_file = described_class.new(tif_fixture_file)
135
153
  expect(object_file.object_type).to eq(:image)
136
154
  end
137
155
  end
138
156
 
139
157
  context 'with jp2' do
140
158
  it ':image' do
141
- object_file = described_class.new(TEST_JP2_INPUT_FILE)
159
+ object_file = described_class.new(jp2_fixture_file)
142
160
  expect(object_file.object_type).to eq(:image)
143
161
  end
144
162
  end
145
163
 
146
164
  context 'with ruby file' do
147
165
  it ':text' do
148
- non_image_file = File.join(PATH_TO_GEM, 'spec/assembly/object_file_spec.rb')
166
+ non_image_file = File.join(root_path, 'spec/assembly/object_file_spec.rb')
149
167
  object_file = described_class.new(non_image_file)
150
168
  expect(object_file.object_type).to eq(:text)
151
169
  end
@@ -153,7 +171,7 @@ describe Assembly::ObjectFile do
153
171
 
154
172
  context 'with xml' do
155
173
  it ':application' do
156
- non_image_file = File.join(PATH_TO_GEM, 'spec/test_data/input/file_with_no_exif.xml')
174
+ non_image_file = File.join(fixture_input_dir, 'file_with_no_exif.xml')
157
175
  object_file = described_class.new(non_image_file)
158
176
  expect(object_file.object_type).to eq(:application)
159
177
  end
@@ -163,35 +181,35 @@ describe Assembly::ObjectFile do
163
181
  describe '#valid_image?' do
164
182
  context 'with tiff' do
165
183
  it 'true' do
166
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
184
+ object_file = described_class.new(tif_fixture_file)
167
185
  expect(object_file.valid_image?).to be(true)
168
186
  end
169
187
  end
170
188
 
171
189
  context 'with tiff resolution 1' do
172
190
  it 'true' do
173
- object_file = described_class.new(TEST_RES1_TIF1)
191
+ object_file = described_class.new(resource1_tif_fixture_file)
174
192
  expect(object_file.valid_image?).to be(true)
175
193
  end
176
194
  end
177
195
 
178
196
  context 'with tiff no color' do
179
197
  it 'true' do
180
- object_file = described_class.new(TEST_TIFF_NO_COLOR_FILE)
198
+ object_file = described_class.new(tiff_no_color_fixture_file)
181
199
  expect(object_file.valid_image?).to be(true)
182
200
  end
183
201
  end
184
202
 
185
203
  context 'with jp2' do
186
204
  it 'true' do
187
- object_file = described_class.new(TEST_JP2_INPUT_FILE)
205
+ object_file = described_class.new(jp2_fixture_file)
188
206
  expect(object_file.valid_image?).to be(true)
189
207
  end
190
208
  end
191
209
 
192
210
  context 'with ruby file' do
193
211
  it 'false' do
194
- non_image_file = File.join(PATH_TO_GEM, 'spec/assembly/object_file_spec.rb')
212
+ non_image_file = File.join(root_path, 'spec/assembly/object_file_spec.rb')
195
213
  object_file = described_class.new(non_image_file)
196
214
  expect(object_file.valid_image?).to be(false)
197
215
  end
@@ -199,7 +217,7 @@ describe Assembly::ObjectFile do
199
217
 
200
218
  context 'with xml' do
201
219
  it 'false' do
202
- non_image_file = File.join(PATH_TO_GEM, 'spec/test_data/input/file_with_no_exif.xml')
220
+ non_image_file = File.join(fixture_input_dir, 'file_with_no_exif.xml')
203
221
  object_file = described_class.new(non_image_file)
204
222
  expect(object_file.valid_image?).to be(false)
205
223
  end
@@ -210,14 +228,14 @@ describe Assembly::ObjectFile do
210
228
  # rubocop:disable RSpec/RepeatedExampleGroupBody
211
229
  context 'with .txt file' do
212
230
  it 'plain/text' do
213
- object_file = described_class.new(TEST_RES1_TEXT)
231
+ object_file = described_class.new(resource1_text_fixture_file)
214
232
  expect(object_file.mimetype).to eq('text/plain')
215
233
  end
216
234
  end
217
235
 
218
236
  context 'with .xml file' do
219
237
  it 'plain/text' do
220
- object_file = described_class.new(TEST_RES1_TEXT)
238
+ object_file = described_class.new(resource1_text_fixture_file)
221
239
  expect(object_file.mimetype).to eq('text/plain')
222
240
  end
223
241
  end
@@ -225,21 +243,21 @@ describe Assembly::ObjectFile do
225
243
 
226
244
  context 'with .tif file' do
227
245
  it 'image/tiff' do
228
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
246
+ object_file = described_class.new(tif_fixture_file)
229
247
  expect(object_file.mimetype).to eq('image/tiff')
230
248
  end
231
249
  end
232
250
 
233
251
  context 'with .jp2 file' do
234
252
  it 'image/jp2' do
235
- object_file = described_class.new(TEST_JP2_INPUT_FILE)
253
+ object_file = described_class.new(jp2_fixture_file)
236
254
  expect(object_file.mimetype).to eq('image/jp2')
237
255
  end
238
256
  end
239
257
 
240
258
  context 'with .pdf file' do
241
259
  it 'application/pdf' do
242
- object_file = described_class.new(TEST_RES1_PDF)
260
+ object_file = described_class.new(resource1_pdf_fixture_file)
243
261
  expect(object_file.mimetype).to eq('application/pdf')
244
262
  end
245
263
  end
@@ -247,21 +265,21 @@ describe Assembly::ObjectFile do
247
265
  context 'with .obj (3d) file' do
248
266
  context 'when default preference (unix file system command)' do
249
267
  it 'plain/text' do
250
- object_file = described_class.new(TEST_OBJ_FILE)
268
+ object_file = described_class.new(obj_fixture_file)
251
269
  expect(object_file.mimetype).to eq('text/plain')
252
270
  end
253
271
  end
254
272
 
255
273
  context 'when mimetype extension gem preferred over unix file system command' do
256
274
  it 'application/x-tgif' do
257
- object_file = described_class.new(TEST_OBJ_FILE, mime_type_order: %i[extension file exif])
275
+ object_file = described_class.new(obj_fixture_file, mime_type_order: %i[extension file exif])
258
276
  expect(object_file.mimetype).to eq('application/x-tgif')
259
277
  end
260
278
  end
261
279
 
262
280
  context 'when invalid first preference mimetype generation' do
263
281
  it 'ignores invalid mimetype generation method and respects valid method preference order' do
264
- object_file = described_class.new(TEST_OBJ_FILE, mime_type_order: %i[bogus extension file])
282
+ object_file = described_class.new(obj_fixture_file, mime_type_order: %i[bogus extension file])
265
283
  expect(object_file.mimetype).to eq('application/x-tgif')
266
284
  end
267
285
  end
@@ -269,14 +287,14 @@ describe Assembly::ObjectFile do
269
287
 
270
288
  context 'with .ply 3d file' do
271
289
  it 'text/plain' do
272
- object_file = described_class.new(TEST_PLY_FILE)
290
+ object_file = described_class.new(ply_fixture_file)
273
291
  expect(object_file.mimetype).to eq('text/plain')
274
292
  end
275
293
  end
276
294
 
277
295
  context 'when exif information is damaged' do
278
296
  it 'gives us the mimetype' do
279
- object_file = described_class.new(TEST_FILE_NO_EXIF)
297
+ object_file = described_class.new(no_exif_fixture_file)
280
298
  expect(object_file.filename).to eq('file_with_no_exif.xml')
281
299
  expect(object_file.ext).to eq('.xml')
282
300
  # we could get either of these mimetypes depending on the OS
@@ -286,7 +304,7 @@ describe Assembly::ObjectFile do
286
304
 
287
305
  context 'when .json file' do
288
306
  it 'uses the manual mapping to set the correct mimetype of application/json for a .json file' do
289
- object_file = described_class.new(TEST_JSON_FILE)
307
+ object_file = described_class.new(json_fixture_file)
290
308
  expect(object_file.send(:exif_mimetype)).to be_nil # exif
291
309
  expect(object_file.send(:file_mimetype)).to eq('text/plain') # unix file system command
292
310
  expect(object_file.mimetype).to eq('application/json') # our configured mapping overrides both
@@ -297,14 +315,14 @@ describe Assembly::ObjectFile do
297
315
  describe '#file_mimetype (unix file system command)' do
298
316
  context 'when .json file' do
299
317
  it 'text/plain' do
300
- object_file = described_class.new(TEST_JSON_FILE)
318
+ object_file = described_class.new(json_fixture_file)
301
319
  expect(object_file.send(:file_mimetype)).to eq('text/plain')
302
320
  end
303
321
  end
304
322
 
305
323
  context 'when .tif file' do
306
324
  it 'image/tiff' do
307
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
325
+ object_file = described_class.new(tif_fixture_file)
308
326
  expect(object_file.send(:file_mimetype)).to eq('image/tiff')
309
327
  end
310
328
  end
@@ -313,21 +331,21 @@ describe Assembly::ObjectFile do
313
331
  describe '#jp2able?' do
314
332
  context 'with jp2 file' do
315
333
  it 'false' do
316
- object_file = described_class.new(TEST_JP2_INPUT_FILE)
334
+ object_file = described_class.new(jp2_fixture_file)
317
335
  expect(object_file.jp2able?).to be(false)
318
336
  end
319
337
  end
320
338
 
321
339
  context 'with tiff resolution 1 file' do
322
340
  it 'true' do
323
- object_file = described_class.new(TEST_RES1_TIF1)
341
+ object_file = described_class.new(resource1_tif_fixture_file)
324
342
  expect(object_file.jp2able?).to be(true)
325
343
  end
326
344
  end
327
345
 
328
346
  context 'with tiff no color file' do
329
347
  it 'true' do
330
- object_file = described_class.new(TEST_TIFF_NO_COLOR_FILE)
348
+ object_file = described_class.new(tiff_no_color_fixture_file)
331
349
  expect(object_file.jp2able?).to be(true)
332
350
  end
333
351
  end
@@ -335,7 +353,7 @@ describe Assembly::ObjectFile do
335
353
 
336
354
  describe '#md5' do
337
355
  it 'computes md5 for an image file' do
338
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
356
+ object_file = described_class.new(tif_fixture_file)
339
357
  expect(object_file.md5).to eq('a2400500acf21e43f5440d93be894101')
340
358
  end
341
359
 
@@ -347,7 +365,7 @@ describe Assembly::ObjectFile do
347
365
 
348
366
  describe '#sha1' do
349
367
  it 'computes sha1 for an image file' do
350
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
368
+ object_file = described_class.new(tif_fixture_file)
351
369
  expect(object_file.sha1).to eq('8d11fab63089a24c8b17063d29a4b0eac359fb41')
352
370
  end
353
371
 
@@ -359,7 +377,7 @@ describe Assembly::ObjectFile do
359
377
 
360
378
  describe '#file_exists?' do
361
379
  it 'false when a valid directory is specified instead of a file' do
362
- path = PATH_TO_GEM
380
+ path = root_path
363
381
  object_file = described_class.new(path)
364
382
  expect(File.exist?(path)).to be true
365
383
  expect(File.directory?(path)).to be true
@@ -367,7 +385,7 @@ describe Assembly::ObjectFile do
367
385
  end
368
386
 
369
387
  it 'false when a non-existent file is specified' do
370
- path = File.join(PATH_TO_GEM, 'file_not_there.txt')
388
+ path = File.join(root_path, 'file_not_there.txt')
371
389
  object_file = described_class.new(path)
372
390
  expect(File.exist?(path)).to be false
373
391
  expect(File.directory?(path)).to be false
@@ -377,7 +395,7 @@ describe Assembly::ObjectFile do
377
395
 
378
396
  describe '#filesize' do
379
397
  it 'tells us the size of an input file' do
380
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
398
+ object_file = described_class.new(tif_fixture_file)
381
399
  expect(object_file.filesize).to eq(63_542)
382
400
  end
383
401
 
@@ -390,12 +408,12 @@ describe Assembly::ObjectFile do
390
408
  describe '#exif' do
391
409
  subject(:exif) { object_file.exif }
392
410
 
393
- let(:object_file) { described_class.new(TEST_TIF_INPUT_FILE) }
411
+ let(:object_file) { described_class.new(tif_fixture_file) }
394
412
 
395
- it { is_expected.to be_kind_of MiniExiftool }
413
+ it { is_expected.to be_a MiniExiftool }
396
414
 
397
415
  context 'when exiftool raises an error initializing the file' do
398
- let(:object_file) { described_class.new('spec/test_data/empty.txt') }
416
+ let(:object_file) { described_class.new('spec/fixtures/empty.txt') }
399
417
 
400
418
  it { is_expected.to be_nil }
401
419
  end
@@ -405,14 +423,14 @@ describe Assembly::ObjectFile do
405
423
  # mime-types gem, based on a file extension lookup
406
424
  context 'with .obj file' do
407
425
  it 'application/x-tgif' do
408
- object_file = described_class.new(TEST_OBJ_FILE)
426
+ object_file = described_class.new(obj_fixture_file)
409
427
  expect(object_file.send(:extension_mimetype)).to eq('application/x-tgif')
410
428
  end
411
429
  end
412
430
 
413
431
  context 'with .tif file' do
414
432
  it 'image/tiff' do
415
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
433
+ object_file = described_class.new(tif_fixture_file)
416
434
  expect(object_file.send(:extension_mimetype)).to eq('image/tiff')
417
435
  end
418
436
  end
@@ -421,14 +439,14 @@ describe Assembly::ObjectFile do
421
439
  describe '#exif_mimetype' do
422
440
  context 'with .tif file' do
423
441
  it 'image/tiff' do
424
- object_file = described_class.new(TEST_TIF_INPUT_FILE)
442
+ object_file = described_class.new(tif_fixture_file)
425
443
  expect(object_file.send(:exif_mimetype)).to eq('image/tiff')
426
444
  end
427
445
  end
428
446
 
429
447
  context 'when .json file' do
430
448
  it 'nil' do
431
- object_file = described_class.new(TEST_JSON_FILE)
449
+ object_file = described_class.new(json_fixture_file)
432
450
  expect(object_file.send(:exif_mimetype)).to be_nil
433
451
  end
434
452
  end
data/spec/spec_helper.rb CHANGED
@@ -7,23 +7,15 @@ require File.expand_path("#{File.dirname(__FILE__)}/../config/boot")
7
7
  require 'pry-byebug'
8
8
 
9
9
  RSpec.configure do |config|
10
- config.order = 'random'
11
- end
12
-
13
- PATH_TO_GEM = File.expand_path("#{File.dirname(__FILE__)}/..")
14
- TEST_INPUT_DIR = File.join(PATH_TO_GEM, 'spec', 'test_data', 'input')
15
- TEST_TIF_INPUT_FILE = File.join(TEST_INPUT_DIR, 'test.tif')
16
- TEST_JP2_INPUT_FILE = File.join(TEST_INPUT_DIR, 'test.jp2')
17
-
18
- TEST_TIFF_NO_COLOR_FILE = File.join(TEST_INPUT_DIR, 'test_no_color_profile.tif')
10
+ # Enable flags like --only-failures and --next-failure
11
+ config.example_status_persistence_file_path = ".rspec_status"
19
12
 
20
- TEST_RES1_TIF1 = File.join(TEST_INPUT_DIR, 'res1_image1.tif')
21
- TEST_RES1_TEXT = File.join(TEST_INPUT_DIR, 'res1_textfile.txt')
22
- TEST_RES1_PDF = File.join(TEST_INPUT_DIR, 'res1_transcript.pdf')
13
+ config.expect_with :rspec do |c|
14
+ c.syntax = :expect
15
+ end
23
16
 
24
- TEST_FILE_NO_EXIF = File.join(TEST_INPUT_DIR, 'file_with_no_exif.xml')
17
+ config.default_formatter = 'doc' if config.files_to_run.one?
25
18
 
26
- TEST_JSON_FILE = File.join(TEST_INPUT_DIR, 'test.json')
27
-
28
- TEST_OBJ_FILE = File.join(TEST_INPUT_DIR, 'someobject.obj')
29
- TEST_PLY_FILE = File.join(TEST_INPUT_DIR, 'someobject.ply')
19
+ config.order = 'random'
20
+ Kernel.srand config.seed
21
+ end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assembly-objectfile
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Mangiafico
8
8
  - Renzo Sanchez-Silva
9
9
  - Monty Hindman
10
10
  - Tony Calavano
11
- autorequire:
11
+ autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2022-08-18 00:00:00.000000000 Z
14
+ date: 2023-05-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -166,25 +166,25 @@ files:
166
166
  - lib/assembly/object_file.rb
167
167
  - lib/assembly/object_file/version.rb
168
168
  - spec/assembly/object_file_spec.rb
169
+ - spec/fixtures/empty.txt
170
+ - spec/fixtures/input/.empty
171
+ - spec/fixtures/input/file_with_no_exif.xml
172
+ - spec/fixtures/input/res1_image1.tif
173
+ - spec/fixtures/input/res1_textfile.txt
174
+ - spec/fixtures/input/res1_transcript.pdf
175
+ - spec/fixtures/input/someobject.obj
176
+ - spec/fixtures/input/someobject.ply
177
+ - spec/fixtures/input/test.jp2
178
+ - spec/fixtures/input/test.json
179
+ - spec/fixtures/input/test.tif
180
+ - spec/fixtures/input/test_no_color_profile.tif
169
181
  - spec/spec_helper.rb
170
- - spec/test_data/empty.txt
171
- - spec/test_data/input/.empty
172
- - spec/test_data/input/file_with_no_exif.xml
173
- - spec/test_data/input/res1_image1.tif
174
- - spec/test_data/input/res1_textfile.txt
175
- - spec/test_data/input/res1_transcript.pdf
176
- - spec/test_data/input/someobject.obj
177
- - spec/test_data/input/someobject.ply
178
- - spec/test_data/input/test.jp2
179
- - spec/test_data/input/test.json
180
- - spec/test_data/input/test.tif
181
- - spec/test_data/input/test_no_color_profile.tif
182
182
  homepage: https://github.com/sul-dlss/assembly-objectfile
183
183
  licenses:
184
184
  - ALv2
185
185
  metadata:
186
186
  rubygems_mfa_required: 'true'
187
- post_install_message:
187
+ post_install_message:
188
188
  rdoc_options: []
189
189
  require_paths:
190
190
  - lib
@@ -199,8 +199,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  - !ruby/object:Gem::Version
200
200
  version: '0'
201
201
  requirements: []
202
- rubygems_version: 3.3.7
203
- signing_key:
202
+ rubygems_version: 3.4.12
203
+ signing_key:
204
204
  specification_version: 4
205
205
  summary: Ruby implementation of file services needed to prepare objects to be accessioned
206
206
  into the Stanford Digital Repository
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes