assembly-objectfile 2.1.3 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.gitignore +1 -2
- data/.rubocop.yml +34 -41
- data/Gemfile.lock +41 -35
- data/lib/assembly/object_file/version.rb +1 -1
- data/lib/assembly/object_file.rb +5 -7
- data/spec/assembly/object_file_spec.rb +62 -51
- data/spec/spec_helper.rb +9 -17
- metadata +18 -18
- /data/spec/{test_data → fixtures}/empty.txt +0 -0
- /data/spec/{test_data → fixtures}/input/.empty +0 -0
- /data/spec/{test_data → fixtures}/input/file_with_no_exif.xml +0 -0
- /data/spec/{test_data → fixtures}/input/res1_image1.tif +0 -0
- /data/spec/{test_data → fixtures}/input/res1_textfile.txt +0 -0
- /data/spec/{test_data → fixtures}/input/res1_transcript.pdf +0 -0
- /data/spec/{test_data → fixtures}/input/someobject.obj +0 -0
- /data/spec/{test_data → fixtures}/input/someobject.ply +0 -0
- /data/spec/{test_data → fixtures}/input/test.jp2 +0 -0
- /data/spec/{test_data → fixtures}/input/test.json +0 -0
- /data/spec/{test_data → fixtures}/input/test.tif +0 -0
- /data/spec/{test_data → fixtures}/input/test_no_color_profile.tif +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 808727d8b4ab8ff12dd01249accf0d2a88e6821349d23950c2b8aaa2a1913391
|
4
|
+
data.tar.gz: 406feb2ba9a205ec1bb3bd9aafa8a95b87ebb6f815cbb025f6e437467ab5e2dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de4086ae3355a75b2bdcdf95e077215b9076b607792648404004176e09c7d724dc3c3b441a89a69149f86717461651eb89c9e0d1e83582897214ba9bce600144
|
7
|
+
data.tar.gz: 125078c8caf3b6f2d4fb9d17a6bd41ae622894586648cfc43a67530744cfa474505b1ddc32f3ecf51079bbcdb88978c504522a05bf3d185221da523befc9d1d0
|
data/.circleci/config.yml
CHANGED
data/.gitignore
CHANGED
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
|
-
|
41
|
+
Enabled: false
|
30
42
|
|
31
43
|
RSpec/MultipleExpectations:
|
32
|
-
Max:
|
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.
|
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
|
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,22 +17,22 @@ GEM
|
|
17
17
|
ast (2.4.2)
|
18
18
|
byebug (11.1.3)
|
19
19
|
coderay (1.1.3)
|
20
|
-
concurrent-ruby (1.
|
20
|
+
concurrent-ruby (1.2.2)
|
21
21
|
diff-lcs (1.5.0)
|
22
22
|
docile (1.4.0)
|
23
|
-
i18n (1.
|
23
|
+
i18n (1.13.0)
|
24
24
|
concurrent-ruby (~> 1.0)
|
25
|
-
json (2.6.
|
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.
|
29
|
+
mime-types-data (3.2023.0218.1)
|
30
30
|
mini_exiftool (2.10.2)
|
31
|
-
minitest (5.
|
32
|
-
parallel (1.
|
33
|
-
parser (3.
|
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.14.
|
35
|
+
pry (0.14.2)
|
36
36
|
coderay (~> 1.1)
|
37
37
|
method_source (~> 1.0)
|
38
38
|
pry-byebug (3.10.1)
|
@@ -40,45 +40,51 @@ GEM
|
|
40
40
|
pry (>= 0.13, < 0.15)
|
41
41
|
rainbow (3.1.1)
|
42
42
|
rake (13.0.6)
|
43
|
-
regexp_parser (2.
|
43
|
+
regexp_parser (2.8.0)
|
44
44
|
rexml (3.2.5)
|
45
|
-
rspec (3.
|
46
|
-
rspec-core (~> 3.
|
47
|
-
rspec-expectations (~> 3.
|
48
|
-
rspec-mocks (~> 3.
|
49
|
-
rspec-core (3.
|
50
|
-
rspec-support (~> 3.
|
51
|
-
rspec-expectations (3.
|
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.
|
54
|
-
rspec-mocks (3.
|
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.
|
57
|
-
rspec-support (3.
|
58
|
-
rubocop (1.
|
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.
|
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.
|
65
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
66
66
|
ruby-progressbar (~> 1.7)
|
67
|
-
unicode-display_width (>=
|
68
|
-
rubocop-ast (1.
|
69
|
-
parser (>= 3.
|
70
|
-
rubocop-
|
71
|
-
rubocop (~> 1.
|
72
|
-
|
73
|
-
|
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.
|
85
|
+
tzinfo (2.0.6)
|
80
86
|
concurrent-ruby (~> 1.0)
|
81
|
-
unicode-display_width (2.2
|
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.
|
103
|
+
2.4.13
|
data/lib/assembly/object_file.rb
CHANGED
@@ -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.
|
15
|
-
# # => '/Users/peter/
|
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, :
|
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
|
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
|
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
|
@@ -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,29 +80,29 @@ describe Assembly::ObjectFile do
|
|
69
80
|
|
70
81
|
describe '#filename' do
|
71
82
|
it 'returns File.basename' do
|
72
|
-
object_file = described_class.new(
|
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(
|
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(
|
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(
|
88
|
-
expect(object_file.dirname).to eq(File.dirname(
|
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(
|
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
|
@@ -100,13 +111,13 @@ describe Assembly::ObjectFile do
|
|
100
111
|
subject { object_file.image? }
|
101
112
|
|
102
113
|
context 'with tiff' do
|
103
|
-
let(:object_file) { described_class.new(
|
114
|
+
let(:object_file) { described_class.new(tif_fixture_file) }
|
104
115
|
|
105
116
|
it { is_expected.to be true }
|
106
117
|
end
|
107
118
|
|
108
119
|
context 'with jp2' do
|
109
|
-
let(:object_file) { described_class.new(
|
120
|
+
let(:object_file) { described_class.new(jp2_fixture_file) }
|
110
121
|
|
111
122
|
it { is_expected.to be true }
|
112
123
|
end
|
@@ -117,19 +128,19 @@ describe Assembly::ObjectFile do
|
|
117
128
|
allow(object_file).to receive(:file_mimetype).and_return('image/x-tga')
|
118
129
|
end
|
119
130
|
|
120
|
-
let(:object_file) { described_class.new(
|
131
|
+
let(:object_file) { described_class.new(jp2_fixture_file) }
|
121
132
|
|
122
133
|
it { is_expected.to be false }
|
123
134
|
end
|
124
135
|
|
125
136
|
context 'with ruby file' do
|
126
|
-
let(:object_file) { described_class.new(File.join(
|
137
|
+
let(:object_file) { described_class.new(File.join(root_path, 'spec/assembly/object_file_spec.rb')) }
|
127
138
|
|
128
139
|
it { is_expected.to be false }
|
129
140
|
end
|
130
141
|
|
131
142
|
context 'with xml' do
|
132
|
-
let(:object_file) { described_class.new(File.join(
|
143
|
+
let(:object_file) { described_class.new(File.join(fixture_input_dir, 'file_with_no_exif.xml')) }
|
133
144
|
|
134
145
|
it { is_expected.to be false }
|
135
146
|
end
|
@@ -138,21 +149,21 @@ describe Assembly::ObjectFile do
|
|
138
149
|
describe '#object_type' do
|
139
150
|
context 'with tiff' do
|
140
151
|
it ':image' do
|
141
|
-
object_file = described_class.new(
|
152
|
+
object_file = described_class.new(tif_fixture_file)
|
142
153
|
expect(object_file.object_type).to eq(:image)
|
143
154
|
end
|
144
155
|
end
|
145
156
|
|
146
157
|
context 'with jp2' do
|
147
158
|
it ':image' do
|
148
|
-
object_file = described_class.new(
|
159
|
+
object_file = described_class.new(jp2_fixture_file)
|
149
160
|
expect(object_file.object_type).to eq(:image)
|
150
161
|
end
|
151
162
|
end
|
152
163
|
|
153
164
|
context 'with ruby file' do
|
154
165
|
it ':text' do
|
155
|
-
non_image_file = File.join(
|
166
|
+
non_image_file = File.join(root_path, 'spec/assembly/object_file_spec.rb')
|
156
167
|
object_file = described_class.new(non_image_file)
|
157
168
|
expect(object_file.object_type).to eq(:text)
|
158
169
|
end
|
@@ -160,7 +171,7 @@ describe Assembly::ObjectFile do
|
|
160
171
|
|
161
172
|
context 'with xml' do
|
162
173
|
it ':application' do
|
163
|
-
non_image_file = File.join(
|
174
|
+
non_image_file = File.join(fixture_input_dir, 'file_with_no_exif.xml')
|
164
175
|
object_file = described_class.new(non_image_file)
|
165
176
|
expect(object_file.object_type).to eq(:application)
|
166
177
|
end
|
@@ -170,35 +181,35 @@ describe Assembly::ObjectFile do
|
|
170
181
|
describe '#valid_image?' do
|
171
182
|
context 'with tiff' do
|
172
183
|
it 'true' do
|
173
|
-
object_file = described_class.new(
|
184
|
+
object_file = described_class.new(tif_fixture_file)
|
174
185
|
expect(object_file.valid_image?).to be(true)
|
175
186
|
end
|
176
187
|
end
|
177
188
|
|
178
189
|
context 'with tiff resolution 1' do
|
179
190
|
it 'true' do
|
180
|
-
object_file = described_class.new(
|
191
|
+
object_file = described_class.new(resource1_tif_fixture_file)
|
181
192
|
expect(object_file.valid_image?).to be(true)
|
182
193
|
end
|
183
194
|
end
|
184
195
|
|
185
196
|
context 'with tiff no color' do
|
186
197
|
it 'true' do
|
187
|
-
object_file = described_class.new(
|
198
|
+
object_file = described_class.new(tiff_no_color_fixture_file)
|
188
199
|
expect(object_file.valid_image?).to be(true)
|
189
200
|
end
|
190
201
|
end
|
191
202
|
|
192
203
|
context 'with jp2' do
|
193
204
|
it 'true' do
|
194
|
-
object_file = described_class.new(
|
205
|
+
object_file = described_class.new(jp2_fixture_file)
|
195
206
|
expect(object_file.valid_image?).to be(true)
|
196
207
|
end
|
197
208
|
end
|
198
209
|
|
199
210
|
context 'with ruby file' do
|
200
211
|
it 'false' do
|
201
|
-
non_image_file = File.join(
|
212
|
+
non_image_file = File.join(root_path, 'spec/assembly/object_file_spec.rb')
|
202
213
|
object_file = described_class.new(non_image_file)
|
203
214
|
expect(object_file.valid_image?).to be(false)
|
204
215
|
end
|
@@ -206,7 +217,7 @@ describe Assembly::ObjectFile do
|
|
206
217
|
|
207
218
|
context 'with xml' do
|
208
219
|
it 'false' do
|
209
|
-
non_image_file = File.join(
|
220
|
+
non_image_file = File.join(fixture_input_dir, 'file_with_no_exif.xml')
|
210
221
|
object_file = described_class.new(non_image_file)
|
211
222
|
expect(object_file.valid_image?).to be(false)
|
212
223
|
end
|
@@ -217,14 +228,14 @@ describe Assembly::ObjectFile do
|
|
217
228
|
# rubocop:disable RSpec/RepeatedExampleGroupBody
|
218
229
|
context 'with .txt file' do
|
219
230
|
it 'plain/text' do
|
220
|
-
object_file = described_class.new(
|
231
|
+
object_file = described_class.new(resource1_text_fixture_file)
|
221
232
|
expect(object_file.mimetype).to eq('text/plain')
|
222
233
|
end
|
223
234
|
end
|
224
235
|
|
225
236
|
context 'with .xml file' do
|
226
237
|
it 'plain/text' do
|
227
|
-
object_file = described_class.new(
|
238
|
+
object_file = described_class.new(resource1_text_fixture_file)
|
228
239
|
expect(object_file.mimetype).to eq('text/plain')
|
229
240
|
end
|
230
241
|
end
|
@@ -232,21 +243,21 @@ describe Assembly::ObjectFile do
|
|
232
243
|
|
233
244
|
context 'with .tif file' do
|
234
245
|
it 'image/tiff' do
|
235
|
-
object_file = described_class.new(
|
246
|
+
object_file = described_class.new(tif_fixture_file)
|
236
247
|
expect(object_file.mimetype).to eq('image/tiff')
|
237
248
|
end
|
238
249
|
end
|
239
250
|
|
240
251
|
context 'with .jp2 file' do
|
241
252
|
it 'image/jp2' do
|
242
|
-
object_file = described_class.new(
|
253
|
+
object_file = described_class.new(jp2_fixture_file)
|
243
254
|
expect(object_file.mimetype).to eq('image/jp2')
|
244
255
|
end
|
245
256
|
end
|
246
257
|
|
247
258
|
context 'with .pdf file' do
|
248
259
|
it 'application/pdf' do
|
249
|
-
object_file = described_class.new(
|
260
|
+
object_file = described_class.new(resource1_pdf_fixture_file)
|
250
261
|
expect(object_file.mimetype).to eq('application/pdf')
|
251
262
|
end
|
252
263
|
end
|
@@ -254,21 +265,21 @@ describe Assembly::ObjectFile do
|
|
254
265
|
context 'with .obj (3d) file' do
|
255
266
|
context 'when default preference (unix file system command)' do
|
256
267
|
it 'plain/text' do
|
257
|
-
object_file = described_class.new(
|
268
|
+
object_file = described_class.new(obj_fixture_file)
|
258
269
|
expect(object_file.mimetype).to eq('text/plain')
|
259
270
|
end
|
260
271
|
end
|
261
272
|
|
262
273
|
context 'when mimetype extension gem preferred over unix file system command' do
|
263
274
|
it 'application/x-tgif' do
|
264
|
-
object_file = described_class.new(
|
275
|
+
object_file = described_class.new(obj_fixture_file, mime_type_order: %i[extension file exif])
|
265
276
|
expect(object_file.mimetype).to eq('application/x-tgif')
|
266
277
|
end
|
267
278
|
end
|
268
279
|
|
269
280
|
context 'when invalid first preference mimetype generation' do
|
270
281
|
it 'ignores invalid mimetype generation method and respects valid method preference order' do
|
271
|
-
object_file = described_class.new(
|
282
|
+
object_file = described_class.new(obj_fixture_file, mime_type_order: %i[bogus extension file])
|
272
283
|
expect(object_file.mimetype).to eq('application/x-tgif')
|
273
284
|
end
|
274
285
|
end
|
@@ -276,14 +287,14 @@ describe Assembly::ObjectFile do
|
|
276
287
|
|
277
288
|
context 'with .ply 3d file' do
|
278
289
|
it 'text/plain' do
|
279
|
-
object_file = described_class.new(
|
290
|
+
object_file = described_class.new(ply_fixture_file)
|
280
291
|
expect(object_file.mimetype).to eq('text/plain')
|
281
292
|
end
|
282
293
|
end
|
283
294
|
|
284
295
|
context 'when exif information is damaged' do
|
285
296
|
it 'gives us the mimetype' do
|
286
|
-
object_file = described_class.new(
|
297
|
+
object_file = described_class.new(no_exif_fixture_file)
|
287
298
|
expect(object_file.filename).to eq('file_with_no_exif.xml')
|
288
299
|
expect(object_file.ext).to eq('.xml')
|
289
300
|
# we could get either of these mimetypes depending on the OS
|
@@ -293,7 +304,7 @@ describe Assembly::ObjectFile do
|
|
293
304
|
|
294
305
|
context 'when .json file' do
|
295
306
|
it 'uses the manual mapping to set the correct mimetype of application/json for a .json file' do
|
296
|
-
object_file = described_class.new(
|
307
|
+
object_file = described_class.new(json_fixture_file)
|
297
308
|
expect(object_file.send(:exif_mimetype)).to be_nil # exif
|
298
309
|
expect(object_file.send(:file_mimetype)).to eq('text/plain') # unix file system command
|
299
310
|
expect(object_file.mimetype).to eq('application/json') # our configured mapping overrides both
|
@@ -304,14 +315,14 @@ describe Assembly::ObjectFile do
|
|
304
315
|
describe '#file_mimetype (unix file system command)' do
|
305
316
|
context 'when .json file' do
|
306
317
|
it 'text/plain' do
|
307
|
-
object_file = described_class.new(
|
318
|
+
object_file = described_class.new(json_fixture_file)
|
308
319
|
expect(object_file.send(:file_mimetype)).to eq('text/plain')
|
309
320
|
end
|
310
321
|
end
|
311
322
|
|
312
323
|
context 'when .tif file' do
|
313
324
|
it 'image/tiff' do
|
314
|
-
object_file = described_class.new(
|
325
|
+
object_file = described_class.new(tif_fixture_file)
|
315
326
|
expect(object_file.send(:file_mimetype)).to eq('image/tiff')
|
316
327
|
end
|
317
328
|
end
|
@@ -320,21 +331,21 @@ describe Assembly::ObjectFile do
|
|
320
331
|
describe '#jp2able?' do
|
321
332
|
context 'with jp2 file' do
|
322
333
|
it 'false' do
|
323
|
-
object_file = described_class.new(
|
334
|
+
object_file = described_class.new(jp2_fixture_file)
|
324
335
|
expect(object_file.jp2able?).to be(false)
|
325
336
|
end
|
326
337
|
end
|
327
338
|
|
328
339
|
context 'with tiff resolution 1 file' do
|
329
340
|
it 'true' do
|
330
|
-
object_file = described_class.new(
|
341
|
+
object_file = described_class.new(resource1_tif_fixture_file)
|
331
342
|
expect(object_file.jp2able?).to be(true)
|
332
343
|
end
|
333
344
|
end
|
334
345
|
|
335
346
|
context 'with tiff no color file' do
|
336
347
|
it 'true' do
|
337
|
-
object_file = described_class.new(
|
348
|
+
object_file = described_class.new(tiff_no_color_fixture_file)
|
338
349
|
expect(object_file.jp2able?).to be(true)
|
339
350
|
end
|
340
351
|
end
|
@@ -342,7 +353,7 @@ describe Assembly::ObjectFile do
|
|
342
353
|
|
343
354
|
describe '#md5' do
|
344
355
|
it 'computes md5 for an image file' do
|
345
|
-
object_file = described_class.new(
|
356
|
+
object_file = described_class.new(tif_fixture_file)
|
346
357
|
expect(object_file.md5).to eq('a2400500acf21e43f5440d93be894101')
|
347
358
|
end
|
348
359
|
|
@@ -354,7 +365,7 @@ describe Assembly::ObjectFile do
|
|
354
365
|
|
355
366
|
describe '#sha1' do
|
356
367
|
it 'computes sha1 for an image file' do
|
357
|
-
object_file = described_class.new(
|
368
|
+
object_file = described_class.new(tif_fixture_file)
|
358
369
|
expect(object_file.sha1).to eq('8d11fab63089a24c8b17063d29a4b0eac359fb41')
|
359
370
|
end
|
360
371
|
|
@@ -366,7 +377,7 @@ describe Assembly::ObjectFile do
|
|
366
377
|
|
367
378
|
describe '#file_exists?' do
|
368
379
|
it 'false when a valid directory is specified instead of a file' do
|
369
|
-
path =
|
380
|
+
path = root_path
|
370
381
|
object_file = described_class.new(path)
|
371
382
|
expect(File.exist?(path)).to be true
|
372
383
|
expect(File.directory?(path)).to be true
|
@@ -374,7 +385,7 @@ describe Assembly::ObjectFile do
|
|
374
385
|
end
|
375
386
|
|
376
387
|
it 'false when a non-existent file is specified' do
|
377
|
-
path = File.join(
|
388
|
+
path = File.join(root_path, 'file_not_there.txt')
|
378
389
|
object_file = described_class.new(path)
|
379
390
|
expect(File.exist?(path)).to be false
|
380
391
|
expect(File.directory?(path)).to be false
|
@@ -384,7 +395,7 @@ describe Assembly::ObjectFile do
|
|
384
395
|
|
385
396
|
describe '#filesize' do
|
386
397
|
it 'tells us the size of an input file' do
|
387
|
-
object_file = described_class.new(
|
398
|
+
object_file = described_class.new(tif_fixture_file)
|
388
399
|
expect(object_file.filesize).to eq(63_542)
|
389
400
|
end
|
390
401
|
|
@@ -397,12 +408,12 @@ describe Assembly::ObjectFile do
|
|
397
408
|
describe '#exif' do
|
398
409
|
subject(:exif) { object_file.exif }
|
399
410
|
|
400
|
-
let(:object_file) { described_class.new(
|
411
|
+
let(:object_file) { described_class.new(tif_fixture_file) }
|
401
412
|
|
402
|
-
it { is_expected.to
|
413
|
+
it { is_expected.to be_a MiniExiftool }
|
403
414
|
|
404
415
|
context 'when exiftool raises an error initializing the file' do
|
405
|
-
let(:object_file) { described_class.new('spec/
|
416
|
+
let(:object_file) { described_class.new('spec/fixtures/empty.txt') }
|
406
417
|
|
407
418
|
it { is_expected.to be_nil }
|
408
419
|
end
|
@@ -412,14 +423,14 @@ describe Assembly::ObjectFile do
|
|
412
423
|
# mime-types gem, based on a file extension lookup
|
413
424
|
context 'with .obj file' do
|
414
425
|
it 'application/x-tgif' do
|
415
|
-
object_file = described_class.new(
|
426
|
+
object_file = described_class.new(obj_fixture_file)
|
416
427
|
expect(object_file.send(:extension_mimetype)).to eq('application/x-tgif')
|
417
428
|
end
|
418
429
|
end
|
419
430
|
|
420
431
|
context 'with .tif file' do
|
421
432
|
it 'image/tiff' do
|
422
|
-
object_file = described_class.new(
|
433
|
+
object_file = described_class.new(tif_fixture_file)
|
423
434
|
expect(object_file.send(:extension_mimetype)).to eq('image/tiff')
|
424
435
|
end
|
425
436
|
end
|
@@ -428,14 +439,14 @@ describe Assembly::ObjectFile do
|
|
428
439
|
describe '#exif_mimetype' do
|
429
440
|
context 'with .tif file' do
|
430
441
|
it 'image/tiff' do
|
431
|
-
object_file = described_class.new(
|
442
|
+
object_file = described_class.new(tif_fixture_file)
|
432
443
|
expect(object_file.send(:exif_mimetype)).to eq('image/tiff')
|
433
444
|
end
|
434
445
|
end
|
435
446
|
|
436
447
|
context 'when .json file' do
|
437
448
|
it 'nil' do
|
438
|
-
object_file = described_class.new(
|
449
|
+
object_file = described_class.new(json_fixture_file)
|
439
450
|
expect(object_file.send(:exif_mimetype)).to be_nil
|
440
451
|
end
|
441
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
|
-
|
11
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
13
|
+
config.expect_with :rspec do |c|
|
14
|
+
c.syntax = :expect
|
15
|
+
end
|
23
16
|
|
24
|
-
|
17
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
25
18
|
|
26
|
-
|
27
|
-
|
28
|
-
|
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.
|
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:
|
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.
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|