assembly-objectfile 1.8.4 → 1.10.3

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: 55d4581c113766a963826ca6e77b15edcab495dfe1a58d029515ac63f71dab61
4
- data.tar.gz: 6345774179c1af7b1bb179dcb079c79f0c48d15418d15b6c9a8010d2a81d66a8
3
+ metadata.gz: 0060fb5fbd2271cc712b63d2d1ff8752c7ab11346f7ee0a43f41fcc48288d805
4
+ data.tar.gz: 1759dd3e2e5c8ab86333957f30b27468296b53b0f4c7e1607f08e09b4f77da9c
5
5
  SHA512:
6
- metadata.gz: 834d7062c0f3ffa547d5c88e051a5148598cbd6ec0debc9b0318da8c97725e9b136ee5cacbd64b49d1cf5e0bd7481ae4eaa5061e9b247772915b821f2af1c0d3
7
- data.tar.gz: 3c2b9d1496af4400a57b383de90df51b02775e6f15afb6ca869607a4c890dd489cd932f99f473fb346de7fea81121e731ab1e04fb7c58dd4f6ee77bedda37ae3
6
+ metadata.gz: a6fa4a4f685bfd3f1c95284b07f8531b1bcdb6330d54b578ad5fefb7e394dd04431bb666930902204b06b44fedeefb9dca0fa9e69939775d27b40df2d41d434a
7
+ data.tar.gz: ccd72959056a26a186c32247100a86ffc7596ce3ef960800ada4f7c6677da13548b4e54dd5614c015555676d25264e5850d809fab3da7a968312af071654a984
@@ -2,4 +2,11 @@
2
2
 
3
3
 
4
4
 
5
- ## Was the documentation updated?
5
+ ## How was this change tested?
6
+
7
+
8
+
9
+ ## Which documentation and/or configurations were updated?
10
+
11
+
12
+
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
 
@@ -13,3 +16,122 @@ RSpec/MessageSpies:
13
16
 
14
17
  RSpec/NestedGroups:
15
18
  Max: 4 # default: 3
19
+
20
+ Metrics/BlockLength:
21
+ Exclude:
22
+ - 'spec/**/*.rb'
23
+ - '**/*.gemspec'
24
+
25
+ Gemspec/DateAssignment: # (new in 1.10)
26
+ Enabled: true
27
+
28
+ Layout/SpaceAroundMethodCallOperator:
29
+ Enabled: true
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
+
85
+ Lint/RaiseException:
86
+ Enabled: true
87
+
88
+ Lint/StructNewOverride:
89
+ Enabled: true
90
+
91
+ Style/ExponentialNotation:
92
+ Enabled: true
93
+
94
+ Style/HashEachMethods:
95
+ Enabled: true
96
+
97
+ Style/HashTransformKeys:
98
+ Enabled: true
99
+
100
+ Style/HashTransformValues:
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,93 +1,91 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2019-10-17 23:28:35 -0500 using RuboCop version 0.75.1.
3
+ # on 2021-04-26 18:43:37 UTC using RuboCop version 1.11.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
- Lint/AmbiguousBlockAssociation:
11
- Exclude:
12
- - 'spec/content_metadata_spec.rb'
13
-
14
9
  # Offense count: 1
15
10
  Lint/UselessAssignment:
16
11
  Exclude:
17
12
  - 'config/boot.rb'
18
13
 
19
14
  # Offense count: 3
15
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
20
16
  Metrics/AbcSize:
21
- Max: 51
17
+ Max: 55
22
18
 
23
- # Offense count: 11
24
- # Configuration parameters: CountComments, ExcludedMethods.
25
- # ExcludedMethods: refine
19
+ # Offense count: 1
20
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
21
+ # IgnoredMethods: refine
26
22
  Metrics/BlockLength:
27
- Max: 577
23
+ Max: 27
28
24
 
29
- # Offense count: 3
25
+ # Offense count: 2
26
+ # Configuration parameters: IgnoredMethods.
30
27
  Metrics/CyclomaticComplexity:
31
28
  Max: 14
32
29
 
33
- # Offense count: 5
34
- # Configuration parameters: CountComments, ExcludedMethods.
30
+ # Offense count: 4
31
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
35
32
  Metrics/MethodLength:
36
- Max: 30
33
+ Max: 31
37
34
 
38
35
  # Offense count: 1
39
- # Configuration parameters: CountComments.
36
+ # Configuration parameters: CountComments, CountAsOne.
40
37
  Metrics/ModuleLength:
41
- Max: 107
38
+ Max: 120
42
39
 
43
40
  # Offense count: 1
44
- # Configuration parameters: CountKeywordArgs.
41
+ # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
45
42
  Metrics/ParameterLists:
46
- Max: 11
43
+ Max: 12
47
44
 
48
45
  # Offense count: 2
46
+ # Configuration parameters: IgnoredMethods.
49
47
  Metrics/PerceivedComplexity:
50
- Max: 12
48
+ Max: 15
51
49
 
52
50
  # Offense count: 1
53
- # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
51
+ # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms.
54
52
  # 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
55
53
  Naming/FileName:
56
54
  Exclude:
57
55
  - 'lib/assembly-objectfile.rb'
58
56
 
59
57
  # Offense count: 1
60
- # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
58
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
61
59
  # NamePrefix: is_, has_, have_
62
- # NamePrefixBlacklist: is_, has_, have_
63
- # NameWhitelist: is_a?
60
+ # ForbiddenPrefixes: is_, has_, have_
61
+ # AllowedMethods: is_a?
64
62
  # MethodDefinitionMacros: define_method, define_singleton_method
65
63
  Naming/PredicateName:
66
64
  Exclude:
67
65
  - 'spec/**/*'
68
66
  - 'lib/assembly-objectfile/object_fileable.rb'
69
67
 
70
- # Offense count: 8
68
+ # Offense count: 9
71
69
  # Configuration parameters: Max.
72
70
  RSpec/ExampleLength:
73
71
  Exclude:
74
72
  - 'spec/content_metadata_spec.rb'
75
73
 
76
74
  # Offense count: 2
77
- # Configuration parameters: CustomTransform, IgnoreMethods.
75
+ # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
76
+ # Include: **/*_spec*rb*, **/spec/**/*
78
77
  RSpec/FilePath:
79
78
  Exclude:
80
79
  - 'spec/content_metadata_spec.rb'
81
80
  - 'spec/object_file_spec.rb'
82
81
 
83
- # Offense count: 67
82
+ # Offense count: 74
84
83
  # Configuration parameters: AssignmentOnly.
85
84
  RSpec/InstanceVariable:
86
85
  Exclude:
87
86
  - 'spec/object_file_spec.rb'
88
87
 
89
- # Offense count: 38
90
- # Configuration parameters: AggregateFailuresByDefault.
88
+ # Offense count: 40
91
89
  RSpec/MultipleExpectations:
92
90
  Max: 29
93
91
 
@@ -101,20 +99,20 @@ RSpec/RepeatedExample:
101
99
  Exclude:
102
100
  - 'spec/object_file_spec.rb'
103
101
 
102
+ # Offense count: 8
103
+ RSpec/RepeatedExampleGroupDescription:
104
+ Exclude:
105
+ - 'spec/content_metadata_spec.rb'
106
+
104
107
  # Offense count: 2
108
+ # Cop supports --auto-correct.
105
109
  Style/CommentedKeyword:
106
110
  Exclude:
107
111
  - 'lib/assembly-objectfile/content_metadata.rb'
108
112
 
109
- # Offense count: 1
110
- # Configuration parameters: MinBodyLength.
111
- Style/GuardClause:
112
- Exclude:
113
- - 'lib/assembly-objectfile/object_file.rb'
114
-
115
- # Offense count: 346
113
+ # Offense count: 122
116
114
  # Cop supports --auto-correct.
117
115
  # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
118
116
  # URISchemes: http, https
119
- Metrics/LineLength:
120
- Max: 304
117
+ Layout/LineLength:
118
+ Max: 277
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/sul-dlss/assembly-objectfile.svg?branch=master)](https://travis-ci.org/sul-dlss/assembly-objectfile)
1
+ [![Build Status](https://travis-ci.com/sul-dlss/assembly-objectfile.svg?branch=main)](https://travis-ci.com/sul-dlss/assembly-objectfile)
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)
@@ -20,7 +20,10 @@ 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'
26
+ s.add_dependency 'deprecation'
24
27
  s.add_dependency 'dry-struct', '~> 1.0'
25
28
  s.add_dependency 'dry-types', '~> 1.1'
26
29
  s.add_dependency 'mime-types', '> 3'
@@ -32,5 +35,5 @@ Gem::Specification.new do |s|
32
35
  s.add_development_dependency 'rspec', '~> 3.0'
33
36
  s.add_development_dependency 'rubocop'
34
37
  s.add_development_dependency 'rubocop-rspec'
35
- 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
36
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 + '/lib')
9
+ $LOAD_PATH.unshift("#{project_root}/lib")
10
10
 
11
11
  require 'assembly-objectfile'
@@ -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
@@ -15,24 +15,12 @@ module Assembly
15
15
  # if no exif data exists, then the mimetype returned by the unix file command will be used
16
16
  TRUSTED_MIMETYPES = ['text/plain', 'plain/text', 'application/pdf', 'text/html', 'application/xml'].freeze
17
17
 
18
- # default publish/preserve/shelve attributes used in content metadata
19
- # if no mimetype specific attributes are specified for a given file, define some defaults, and override for specific mimetypes below
20
- FILE_ATTRIBUTES = {
21
- 'default' => { preserve: 'yes', shelve: 'no', publish: 'no' },
22
- 'image/tif' => { preserve: 'yes', shelve: 'no', publish: 'no' },
23
- 'image/tiff' => { preserve: 'yes', shelve: 'no', publish: 'no' },
24
- 'image/jp2' => { preserve: 'no', shelve: 'yes', publish: 'yes' },
25
- 'image/jpeg' => { preserve: 'yes', shelve: 'no', publish: 'no' },
26
- 'audio/wav' => { preserve: 'yes', shelve: 'no', publish: 'no' },
27
- 'audio/x-wav' => { preserve: 'yes', shelve: 'no', publish: 'no' },
28
- 'audio/mp3' => { preserve: 'no', shelve: 'yes', publish: 'yes' },
29
- 'audio/mpeg' => { preserve: 'no', shelve: 'yes', publish: 'yes' },
30
- 'application/pdf' => { preserve: 'yes', shelve: 'yes', publish: 'yes' },
31
- 'plain/text' => { preserve: 'yes', shelve: 'yes', publish: 'yes' },
32
- 'text/plain' => { preserve: 'yes', shelve: 'yes', publish: 'yes' },
33
- 'image/png' => { preserve: 'yes', shelve: 'yes', publish: 'no' },
34
- 'application/zip' => { preserve: 'yes', shelve: 'no', publish: 'no' },
35
- 'application/json' => { preserve: 'yes', shelve: 'yes', publish: 'yes' }
18
+ # this is a manual override mapping of file extension to mimetype; if a file with the given extension is found, the mapped
19
+ # mimetype will be returned and no further methods will be used - this is used to force a specific mimetype to be returned for
20
+ # for a given file extension regardless of what exif or the unix file system command returns
21
+ # the mapping format is "extension with period: returned mimetype", e.g. for any .json file, you will always get `application/json`
22
+ OVERRIDE_MIMETYPES = {
23
+ '.json': 'application/json'
36
24
  }.freeze
37
25
  end
38
26
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'nokogiri'
4
+ require 'deprecation'
4
5
  require 'active_support'
5
6
  require 'assembly-objectfile/content_metadata/file'
6
7
  require 'assembly-objectfile/content_metadata/file_set'
@@ -13,6 +14,7 @@ module Assembly
13
14
  # these are used when :bundle=>:dpg only
14
15
 
15
16
  DEPRECATED_STYLES = %i[book_with_pdf book_as_image].freeze
17
+ VALID_STYLES = %i[simple_image simple_book file map document 3d webarchive-seed].freeze
16
18
 
17
19
  # This class generates content metadata for image files
18
20
  class ContentMetadata
@@ -32,6 +34,7 @@ module Assembly
32
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
33
35
  # :map, like simple_image, but with contentMetadata type="map", resource type="image"
34
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"
35
38
  # :bundle = optional - a symbol containing the method of bundling files into resources, allowed values are
36
39
  # :default = all files get their own resources (default)
37
40
  # :filename = files with the same filename but different extensions get bundled together in a single resource
@@ -49,23 +52,25 @@ module Assembly
49
52
  # :flatten_folder_structure = optional - Will remove *all* folder structure when genearting file IDs (e.g. DPG subfolders like '00','05' will be removed) when generating file IDs. This is useful if the folder structure is flattened when staging files (like for DPG).
50
53
  # The default is false. If set to true, will override the "preserve_common_paths" parameter.
51
54
  # :auto_labels = optional - Will add automated resource labels (e.g. "File 1") when labels are not provided by the user. The default is true.
55
+ # See https://consul.stanford.edu/pages/viewpage.action?spaceKey=chimera&title=DOR+content+types%2C+resource+types+and+interpretive+metadata for next two settings
56
+ # :reading_order = optional - only valid for simple_book, can be 'rtl' or 'ltr'. The default is 'ltr'.
52
57
  # Example:
53
58
  # Assembly::ContentMetadata.create_content_metadata(:druid=>'druid:nx288wh8889',:style=>:simple_image,:objects=>object_files,:add_file_attributes=>false)
54
59
  def self.create_content_metadata(druid:, objects:, auto_labels: true,
55
60
  add_exif: false, bundle: :default, style: :simple_image,
56
61
  add_file_attributes: false, file_attributes: {},
57
62
  preserve_common_paths: false, flatten_folder_structure: false,
58
- include_root_xml: nil)
63
+ include_root_xml: nil, reading_order: 'ltr')
59
64
 
60
65
  common_path = find_common_path(objects) unless preserve_common_paths # find common paths to all files provided if needed
61
66
 
62
67
  filesets = FileSetBuilder.build(bundle: bundle, objects: objects, style: style)
63
-
64
68
  config = Config.new(auto_labels: auto_labels,
65
69
  flatten_folder_structure: flatten_folder_structure,
66
70
  add_file_attributes: add_file_attributes,
67
71
  file_attributes: file_attributes,
68
72
  add_exif: add_exif,
73
+ reading_order: reading_order,
69
74
  type: object_level_type(style))
70
75
 
71
76
  builder = NokogiriBuilder.build(druid: druid,
@@ -73,13 +78,11 @@ module Assembly
73
78
  common_path: common_path,
74
79
  config: config)
75
80
 
76
- result = if include_root_xml == false
77
- builder.doc.root.to_xml
78
- else
79
- builder.to_xml
80
- end
81
-
82
- result
81
+ if include_root_xml == false
82
+ builder.doc.root.to_xml
83
+ else
84
+ builder.to_xml
85
+ end
83
86
  end
84
87
 
85
88
  def self.special_dpg_folder?(folder)
@@ -98,21 +101,16 @@ module Assembly
98
101
  private_class_method :find_common_path
99
102
 
100
103
  def self.object_level_type(style)
101
- puts "WARNING - the style #{style} is now deprecated and should not be used." if DEPRECATED_STYLES.include? style
104
+ Deprecation.warn(self, "the style #{style} is now deprecated and should not be used. This will be removed in assembly-objectfile 2.0") if DEPRECATED_STYLES.include? style
105
+ raise "Supplied style (#{style}) not valid" unless (VALID_STYLES + DEPRECATED_STYLES).include? style
102
106
 
103
107
  case style
104
108
  when :simple_image
105
109
  'image'
106
- when :file
107
- 'file'
108
110
  when :simple_book, :book_with_pdf, :book_as_image
109
111
  'book'
110
- when :map
111
- 'map'
112
- when :'3d'
113
- '3d'
114
112
  else
115
- raise "Supplied style (#{style}) not valid"
113
+ style.to_s
116
114
  end
117
115
  end
118
116
  end # class