assembly-objectfile 1.10.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +8 -1
- data/.rubocop.yml +98 -1
- data/.rubocop_todo.yml +62 -17
- data/README.md +1 -1
- data/assembly-objectfile.gemspec +3 -1
- data/config/boot.rb +2 -2
- data/lib/assembly-objectfile.rb +1 -1
- data/lib/assembly-objectfile/content_metadata.rb +7 -8
- data/lib/assembly-objectfile/content_metadata/config.rb +1 -1
- data/lib/assembly-objectfile/content_metadata/file.rb +1 -1
- data/lib/assembly-objectfile/content_metadata/file_set.rb +2 -4
- data/lib/assembly-objectfile/object_file.rb +3 -3
- data/lib/assembly-objectfile/object_fileable.rb +7 -6
- data/lib/assembly-objectfile/version.rb +1 -1
- data/spec/content_metadata_spec.rb +534 -491
- data/spec/spec_helper.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bfe0d362cd776d4099d57530dc6c502e8760eb49953dfa93d755016b98c54d6a
|
|
4
|
+
data.tar.gz: c1f0da284aa258aa89375b6d7b92dd7847b3e87b27712c2802e29157b86b6d9c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dfce4baa7f4d0cd52944195661ba94b6af1010fce66d714eb7c7b54778681fd5041d92d5f2fb82561c20048f76e4c313050afd880d7eb8b0c6eafb0fd6aedb67
|
|
7
|
+
data.tar.gz: c936f71be1c89887f76a9e3c66a37b690730f40a4bcc01605dcd2610d961f85d44eb110b91f40754346ef46482ad481a1aa6a76a2d9e866de42782cb344115b3
|
data/.rubocop.yml
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
|
2
2
|
require: rubocop-rspec
|
|
3
3
|
|
|
4
|
+
AllCops:
|
|
5
|
+
TargetRubyVersion: 2.5
|
|
6
|
+
|
|
4
7
|
RSpec/ContextWording:
|
|
5
8
|
Enabled: false # too dogmatic
|
|
6
9
|
|
|
@@ -16,11 +19,69 @@ RSpec/NestedGroups:
|
|
|
16
19
|
|
|
17
20
|
Metrics/BlockLength:
|
|
18
21
|
Exclude:
|
|
19
|
-
- spec
|
|
22
|
+
- 'spec/**/*.rb'
|
|
23
|
+
- '**/*.gemspec'
|
|
24
|
+
|
|
25
|
+
Gemspec/DateAssignment: # (new in 1.10)
|
|
26
|
+
Enabled: true
|
|
20
27
|
|
|
21
28
|
Layout/SpaceAroundMethodCallOperator:
|
|
22
29
|
Enabled: true
|
|
23
30
|
|
|
31
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
32
|
+
Enabled: true
|
|
33
|
+
|
|
34
|
+
Layout/SpaceBeforeBrackets: # (new in 1.7)
|
|
35
|
+
Enabled: true
|
|
36
|
+
|
|
37
|
+
Lint/AmbiguousAssignment: # (new in 1.7)
|
|
38
|
+
Enabled: true
|
|
39
|
+
|
|
40
|
+
Lint/DeprecatedConstants: # (new in 1.8)
|
|
41
|
+
Enabled: true
|
|
42
|
+
|
|
43
|
+
Lint/DuplicateBranch: # (new in 1.3)
|
|
44
|
+
Enabled: true
|
|
45
|
+
|
|
46
|
+
Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
|
|
47
|
+
Enabled: true
|
|
48
|
+
|
|
49
|
+
Lint/EmptyBlock: # (new in 1.1)
|
|
50
|
+
Enabled: true
|
|
51
|
+
|
|
52
|
+
Lint/EmptyClass: # (new in 1.3)
|
|
53
|
+
Enabled: true
|
|
54
|
+
|
|
55
|
+
Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
|
|
56
|
+
Enabled: true
|
|
57
|
+
|
|
58
|
+
Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
|
|
59
|
+
Enabled: true
|
|
60
|
+
|
|
61
|
+
Lint/NumberedParameterAssignment: # (new in 1.9)
|
|
62
|
+
Enabled: true
|
|
63
|
+
|
|
64
|
+
Lint/OrAssignmentToConstant: # (new in 1.9)
|
|
65
|
+
Enabled: true
|
|
66
|
+
|
|
67
|
+
Lint/RedundantDirGlobSort: # (new in 1.8)
|
|
68
|
+
Enabled: true
|
|
69
|
+
|
|
70
|
+
Lint/SymbolConversion: # (new in 1.9)
|
|
71
|
+
Enabled: true
|
|
72
|
+
|
|
73
|
+
Lint/ToEnumArguments: # (new in 1.1)
|
|
74
|
+
Enabled: true
|
|
75
|
+
|
|
76
|
+
Lint/TripleQuotes: # (new in 1.9)
|
|
77
|
+
Enabled: true
|
|
78
|
+
|
|
79
|
+
Lint/UnexpectedBlockArity: # (new in 1.5)
|
|
80
|
+
Enabled: true
|
|
81
|
+
|
|
82
|
+
Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
|
|
83
|
+
Enabled: true
|
|
84
|
+
|
|
24
85
|
Lint/RaiseException:
|
|
25
86
|
Enabled: true
|
|
26
87
|
|
|
@@ -38,3 +99,39 @@ Style/HashTransformKeys:
|
|
|
38
99
|
|
|
39
100
|
Style/HashTransformValues:
|
|
40
101
|
Enabled: true
|
|
102
|
+
|
|
103
|
+
Style/SlicingWithRange:
|
|
104
|
+
Enabled: true
|
|
105
|
+
|
|
106
|
+
Style/ArgumentsForwarding: # (new in 1.1)
|
|
107
|
+
Enabled: true
|
|
108
|
+
|
|
109
|
+
Style/CollectionCompact: # (new in 1.2)
|
|
110
|
+
Enabled: true
|
|
111
|
+
|
|
112
|
+
Style/DocumentDynamicEvalDefinition: # (new in 1.1)
|
|
113
|
+
Enabled: true
|
|
114
|
+
|
|
115
|
+
Style/EndlessMethod: # (new in 1.8)
|
|
116
|
+
Enabled: true
|
|
117
|
+
|
|
118
|
+
Style/HashConversion: # (new in 1.10)
|
|
119
|
+
Enabled: true
|
|
120
|
+
|
|
121
|
+
Style/HashExcept: # (new in 1.7)
|
|
122
|
+
Enabled: true
|
|
123
|
+
|
|
124
|
+
Style/IfWithBooleanLiteralBranches: # (new in 1.9)
|
|
125
|
+
Enabled: true
|
|
126
|
+
|
|
127
|
+
Style/NegatedIfElseCondition: # (new in 1.2)
|
|
128
|
+
Enabled: true
|
|
129
|
+
|
|
130
|
+
Style/NilLambda: # (new in 1.3)
|
|
131
|
+
Enabled: true
|
|
132
|
+
|
|
133
|
+
Style/RedundantArgument: # (new in 1.4)
|
|
134
|
+
Enabled: true
|
|
135
|
+
|
|
136
|
+
Style/SwapValues: # (new in 1.1)
|
|
137
|
+
Enabled: true
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,54 +1,76 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2021-01-08 23:41:37 UTC using RuboCop version 1.8.0.
|
|
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
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
# Cop supports --auto-correct.
|
|
11
|
+
# Configuration parameters: EnforcedStyleAlignWith, Severity.
|
|
12
|
+
# SupportedStylesAlignWith: start_of_line, begin
|
|
13
|
+
Layout/BeginEndAlignment:
|
|
14
|
+
Exclude:
|
|
15
|
+
- 'lib/assembly-objectfile/object_fileable.rb'
|
|
16
|
+
|
|
17
|
+
# Offense count: 1
|
|
18
|
+
# Cop supports --auto-correct.
|
|
19
|
+
# Configuration parameters: AllowAliasSyntax, AllowedMethods.
|
|
20
|
+
# AllowedMethods: alias_method, public, protected, private
|
|
21
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
22
|
+
Exclude:
|
|
23
|
+
- 'lib/assembly-objectfile/object_fileable.rb'
|
|
24
|
+
|
|
25
|
+
# Offense count: 1
|
|
26
|
+
# Cop supports --auto-correct.
|
|
27
|
+
Layout/RescueEnsureAlignment:
|
|
28
|
+
Exclude:
|
|
29
|
+
- 'lib/assembly-objectfile/object_fileable.rb'
|
|
30
|
+
|
|
9
31
|
# Offense count: 1
|
|
10
32
|
Lint/UselessAssignment:
|
|
11
33
|
Exclude:
|
|
12
34
|
- 'config/boot.rb'
|
|
13
35
|
|
|
14
36
|
# Offense count: 3
|
|
15
|
-
# Configuration parameters: IgnoredMethods.
|
|
37
|
+
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
|
|
16
38
|
Metrics/AbcSize:
|
|
17
|
-
Max:
|
|
39
|
+
Max: 52
|
|
18
40
|
|
|
19
|
-
# Offense count:
|
|
20
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
|
21
|
-
#
|
|
41
|
+
# Offense count: 1
|
|
42
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
|
43
|
+
# IgnoredMethods: refine
|
|
22
44
|
Metrics/BlockLength:
|
|
23
|
-
Max:
|
|
45
|
+
Max: 26
|
|
24
46
|
|
|
25
47
|
# Offense count: 2
|
|
26
48
|
# Configuration parameters: IgnoredMethods.
|
|
27
49
|
Metrics/CyclomaticComplexity:
|
|
28
|
-
Max:
|
|
50
|
+
Max: 13
|
|
29
51
|
|
|
30
52
|
# Offense count: 4
|
|
31
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
|
53
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
|
32
54
|
Metrics/MethodLength:
|
|
33
55
|
Max: 30
|
|
34
56
|
|
|
35
57
|
# Offense count: 1
|
|
36
|
-
# Configuration parameters: CountComments.
|
|
58
|
+
# Configuration parameters: CountComments, CountAsOne.
|
|
37
59
|
Metrics/ModuleLength:
|
|
38
60
|
Max: 117
|
|
39
61
|
|
|
40
62
|
# Offense count: 1
|
|
41
|
-
# Configuration parameters: CountKeywordArgs.
|
|
63
|
+
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
|
|
42
64
|
Metrics/ParameterLists:
|
|
43
65
|
Max: 11
|
|
44
66
|
|
|
45
67
|
# Offense count: 2
|
|
46
68
|
# Configuration parameters: IgnoredMethods.
|
|
47
69
|
Metrics/PerceivedComplexity:
|
|
48
|
-
Max:
|
|
70
|
+
Max: 14
|
|
49
71
|
|
|
50
72
|
# Offense count: 1
|
|
51
|
-
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
|
73
|
+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
|
52
74
|
# 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
75
|
Naming/FileName:
|
|
54
76
|
Exclude:
|
|
@@ -72,7 +94,8 @@ RSpec/ExampleLength:
|
|
|
72
94
|
- 'spec/content_metadata_spec.rb'
|
|
73
95
|
|
|
74
96
|
# Offense count: 2
|
|
75
|
-
# Configuration parameters: CustomTransform, IgnoreMethods.
|
|
97
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
|
|
98
|
+
# Include: **/*_spec*rb*, **/spec/**/*
|
|
76
99
|
RSpec/FilePath:
|
|
77
100
|
Exclude:
|
|
78
101
|
- 'spec/content_metadata_spec.rb'
|
|
@@ -85,7 +108,6 @@ RSpec/InstanceVariable:
|
|
|
85
108
|
- 'spec/object_file_spec.rb'
|
|
86
109
|
|
|
87
110
|
# Offense count: 38
|
|
88
|
-
# Configuration parameters: AggregateFailuresByDefault.
|
|
89
111
|
RSpec/MultipleExpectations:
|
|
90
112
|
Max: 29
|
|
91
113
|
|
|
@@ -105,13 +127,36 @@ RSpec/RepeatedExampleGroupDescription:
|
|
|
105
127
|
- 'spec/content_metadata_spec.rb'
|
|
106
128
|
|
|
107
129
|
# Offense count: 2
|
|
130
|
+
# Cop supports --auto-correct.
|
|
108
131
|
Style/CommentedKeyword:
|
|
109
132
|
Exclude:
|
|
110
133
|
- 'lib/assembly-objectfile/content_metadata.rb'
|
|
111
134
|
|
|
112
|
-
# Offense count:
|
|
135
|
+
# Offense count: 2
|
|
136
|
+
# Cop supports --auto-correct.
|
|
137
|
+
Style/KeywordParametersOrder:
|
|
138
|
+
Exclude:
|
|
139
|
+
- 'lib/assembly-objectfile/content_metadata/file.rb'
|
|
140
|
+
- 'lib/assembly-objectfile/content_metadata/file_set.rb'
|
|
141
|
+
|
|
142
|
+
# Offense count: 1
|
|
143
|
+
# Cop supports --auto-correct.
|
|
144
|
+
Style/RedundantAssignment:
|
|
145
|
+
Exclude:
|
|
146
|
+
- 'lib/assembly-objectfile/content_metadata.rb'
|
|
147
|
+
|
|
148
|
+
# Offense count: 5
|
|
149
|
+
# Cop supports --auto-correct.
|
|
150
|
+
Style/StringConcatenation:
|
|
151
|
+
Exclude:
|
|
152
|
+
- 'config/boot.rb'
|
|
153
|
+
- 'lib/assembly-objectfile.rb'
|
|
154
|
+
- 'lib/assembly-objectfile/object_file.rb'
|
|
155
|
+
- 'spec/spec_helper.rb'
|
|
156
|
+
|
|
157
|
+
# Offense count: 113
|
|
113
158
|
# Cop supports --auto-correct.
|
|
114
159
|
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
|
115
160
|
# URISchemes: http, https
|
|
116
161
|
Layout/LineLength:
|
|
117
|
-
Max:
|
|
162
|
+
Max: 277
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://travis-ci.com/sul-dlss/assembly-objectfile)
|
|
2
2
|
[](https://codeclimate.com/github/sul-dlss/assembly-objectfile/test_coverage)
|
|
3
3
|
[](https://codeclimate.com/github/sul-dlss/assembly-objectfile/maintainability)
|
|
4
4
|
[](https://badge.fury.io/rb/assembly-objectfile)
|
data/assembly-objectfile.gemspec
CHANGED
|
@@ -20,6 +20,8 @@ Gem::Specification.new do |s|
|
|
|
20
20
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
21
21
|
s.require_paths = ['lib']
|
|
22
22
|
|
|
23
|
+
s.required_ruby_version = '~> 2.5'
|
|
24
|
+
|
|
23
25
|
s.add_dependency 'activesupport', '>= 5.2.0'
|
|
24
26
|
s.add_dependency 'deprecation'
|
|
25
27
|
s.add_dependency 'dry-struct', '~> 1.0'
|
|
@@ -33,5 +35,5 @@ Gem::Specification.new do |s|
|
|
|
33
35
|
s.add_development_dependency 'rspec', '~> 3.0'
|
|
34
36
|
s.add_development_dependency 'rubocop'
|
|
35
37
|
s.add_development_dependency 'rubocop-rspec'
|
|
36
|
-
s.add_development_dependency 'simplecov'
|
|
38
|
+
s.add_development_dependency 'simplecov', '~> 0.17.0' # CodeClimate cannot use SimpleCov >= 0.18.0 for generating test coverage
|
|
37
39
|
end
|
data/config/boot.rb
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
require 'rubygems'
|
|
4
4
|
|
|
5
5
|
environment = ENV['ENVIRONMENT'] ||= 'development'
|
|
6
|
-
project_root = File.expand_path(File.dirname(__FILE__)
|
|
6
|
+
project_root = File.expand_path("#{File.dirname(__FILE__)}/..")
|
|
7
7
|
|
|
8
8
|
# Load config for current environment.
|
|
9
|
-
$LOAD_PATH.unshift(project_root
|
|
9
|
+
$LOAD_PATH.unshift("#{project_root}/lib")
|
|
10
10
|
|
|
11
11
|
require 'assembly-objectfile'
|
data/lib/assembly-objectfile.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Assembly
|
|
4
4
|
# the path to the gem, used to access profiles stored with the gem
|
|
5
|
-
PATH_TO_GEM = File.expand_path(File.dirname(__FILE__)
|
|
5
|
+
PATH_TO_GEM = File.expand_path("#{File.dirname(__FILE__)}/..")
|
|
6
6
|
|
|
7
7
|
# if input image is not one of these mime types, it will not be regarded as a valid image for the purpose of generating a JP2 derivative
|
|
8
8
|
VALID_IMAGE_MIMETYPES = ['image/jpeg', 'image/tiff', 'image/tif', 'image/png'].freeze
|
|
@@ -14,7 +14,7 @@ module Assembly
|
|
|
14
14
|
# these are used when :bundle=>:dpg only
|
|
15
15
|
|
|
16
16
|
DEPRECATED_STYLES = %i[book_with_pdf book_as_image].freeze
|
|
17
|
-
VALID_STYLES = %i[simple_image simple_book file map document 3d].freeze
|
|
17
|
+
VALID_STYLES = %i[simple_image simple_book file map document 3d webarchive-seed].freeze
|
|
18
18
|
|
|
19
19
|
# This class generates content metadata for image files
|
|
20
20
|
class ContentMetadata
|
|
@@ -34,6 +34,7 @@ module Assembly
|
|
|
34
34
|
# :book_as_image, as simple_book, but with contentMetadata type="book", resource type="image" (same rule applies for resources with non images) - NOTE: THIS IS DEPRECATED
|
|
35
35
|
# :map, like simple_image, but with contentMetadata type="map", resource type="image"
|
|
36
36
|
# :3d, contentMetadata type="3d", ".obj" and other configured 3d extension files go into resource_type="3d", everything else into resource_type="file"
|
|
37
|
+
# :webarchive-seed, contentMetadata type="webarchive-seed", resource type="image"
|
|
37
38
|
# :bundle = optional - a symbol containing the method of bundling files into resources, allowed values are
|
|
38
39
|
# :default = all files get their own resources (default)
|
|
39
40
|
# :filename = files with the same filename but different extensions get bundled together in a single resource
|
|
@@ -74,13 +75,11 @@ module Assembly
|
|
|
74
75
|
common_path: common_path,
|
|
75
76
|
config: config)
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
result
|
|
78
|
+
if include_root_xml == false
|
|
79
|
+
builder.doc.root.to_xml
|
|
80
|
+
else
|
|
81
|
+
builder.to_xml
|
|
82
|
+
end
|
|
84
83
|
end
|
|
85
84
|
|
|
86
85
|
def self.special_dpg_folder?(folder)
|
|
@@ -12,7 +12,7 @@ module Assembly
|
|
|
12
12
|
|
|
13
13
|
# Represents a configuration for generating the content metadata
|
|
14
14
|
class Config < Dry::Struct
|
|
15
|
-
STYLES = %w[image file book map 3d document].freeze
|
|
15
|
+
STYLES = %w[image file book map 3d document webarchive-seed].freeze
|
|
16
16
|
attribute :auto_labels, Types::Strict::Bool.default(true)
|
|
17
17
|
attribute :flatten_folder_structure, Types::Strict::Bool.default(false)
|
|
18
18
|
attribute :add_file_attributes, Types::Strict::Bool.default(false)
|
|
@@ -9,7 +9,7 @@ module Assembly
|
|
|
9
9
|
# @param [Boolean] dpg (false) is it a dpg bundle?
|
|
10
10
|
# @param [Array<Assembly::ObjectFile>] resource_files
|
|
11
11
|
# @param style
|
|
12
|
-
def initialize(
|
|
12
|
+
def initialize(resource_files:, style:, dpg: false)
|
|
13
13
|
@dpg = dpg
|
|
14
14
|
@resource_files = resource_files
|
|
15
15
|
@style = style
|
|
@@ -46,7 +46,7 @@ module Assembly
|
|
|
46
46
|
resource_has_non_images = !(resource_file_types - [:image]).empty?
|
|
47
47
|
|
|
48
48
|
case style
|
|
49
|
-
when :simple_image
|
|
49
|
+
when :simple_image, :map, :'webarchive-seed'
|
|
50
50
|
'image'
|
|
51
51
|
when :file
|
|
52
52
|
'file'
|
|
@@ -56,8 +56,6 @@ module Assembly
|
|
|
56
56
|
resource_has_non_images && resource_file_types.include?(:image) == false ? 'object' : 'image'
|
|
57
57
|
when :book_with_pdf # in book with PDF type, if we find a resource with *any* non images, switch it's type from book to object
|
|
58
58
|
resource_has_non_images ? 'object' : 'page'
|
|
59
|
-
when :map
|
|
60
|
-
'image'
|
|
61
59
|
when :document
|
|
62
60
|
'document'
|
|
63
61
|
when :'3d'
|
|
@@ -19,10 +19,10 @@ module Assembly
|
|
|
19
19
|
x = strings.last
|
|
20
20
|
n += 1 while strings.all? { |s| s[n] && (s[n] == x[n]) }
|
|
21
21
|
common_prefix = x[0...n]
|
|
22
|
-
if common_prefix[-1, 1]
|
|
23
|
-
common_prefix
|
|
22
|
+
if common_prefix[-1, 1] == '/' # check if last element of the common string is the end of a directory
|
|
23
|
+
common_prefix # if not, split string along directories, and reject last one
|
|
24
24
|
else
|
|
25
|
-
common_prefix # if it was, then return the common prefix directly
|
|
25
|
+
"#{common_prefix.split('/')[0..-2].join('/')}/" # if it was, then return the common prefix directly
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
end
|
|
@@ -7,6 +7,7 @@ module Assembly
|
|
|
7
7
|
# Common behaviors we need for other classes in the gem
|
|
8
8
|
module ObjectFileable
|
|
9
9
|
attr_accessor :file_attributes, :label, :path, :provider_md5, :provider_sha1, :relative_path, :mime_type_order
|
|
10
|
+
|
|
10
11
|
VALID_MIMETYPE_METHODS = %i[exif file extension].freeze
|
|
11
12
|
|
|
12
13
|
# @param [String] path full path to the file to be worked with
|
|
@@ -87,11 +88,11 @@ module Assembly
|
|
|
87
88
|
# puts source_file.exif # hash with exif information
|
|
88
89
|
def exif
|
|
89
90
|
@exif ||= begin
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
check_for_file
|
|
92
|
+
MiniExiftool.new(path, replace_invalid_chars: '?')
|
|
93
|
+
rescue StandardError
|
|
94
|
+
nil
|
|
95
|
+
end
|
|
95
96
|
end
|
|
96
97
|
|
|
97
98
|
# Computes md5 checksum or returns cached value
|
|
@@ -208,7 +209,7 @@ exif&.mimetype && prefer_exif
|
|
|
208
209
|
def valid_image?
|
|
209
210
|
return false unless image?
|
|
210
211
|
|
|
211
|
-
mimetype == 'image/jp2' || jp2able?
|
|
212
|
+
mimetype == 'image/jp2' || jp2able?
|
|
212
213
|
end
|
|
213
214
|
|
|
214
215
|
# @return [Boolean] true if image has a color profile, false if not.
|