moab-versioning 4.3.0 → 5.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/moab/bagger.rb +7 -2
  3. data/lib/moab/config.rb +40 -7
  4. data/lib/moab/exceptions.rb +6 -0
  5. data/lib/moab/file_group.rb +12 -9
  6. data/lib/moab/file_group_difference.rb +26 -23
  7. data/lib/moab/file_group_difference_subset.rb +5 -3
  8. data/lib/moab/file_instance.rb +4 -1
  9. data/lib/moab/file_instance_difference.rb +5 -3
  10. data/lib/moab/file_inventory.rb +13 -9
  11. data/lib/moab/file_inventory_difference.rb +8 -6
  12. data/lib/moab/file_manifestation.rb +5 -2
  13. data/lib/moab/file_signature.rb +12 -7
  14. data/lib/moab/signature_catalog.rb +13 -13
  15. data/lib/moab/signature_catalog_entry.rb +6 -4
  16. data/lib/moab/stanford.rb +2 -10
  17. data/lib/moab/storage_object.rb +11 -5
  18. data/lib/moab/storage_object_validator.rb +24 -10
  19. data/lib/moab/storage_object_version.rb +19 -12
  20. data/lib/moab/storage_repository.rb +49 -7
  21. data/lib/moab/storage_services.rb +12 -9
  22. data/lib/moab/utc_time.rb +2 -0
  23. data/lib/moab/verification_result.rb +4 -3
  24. data/lib/moab/version_metadata_entry.rb +6 -4
  25. data/lib/moab.rb +2 -9
  26. data/lib/serializer/manifest.rb +4 -2
  27. data/lib/serializer/serializable.rb +6 -1
  28. data/lib/serializer.rb +2 -0
  29. data/lib/stanford/content_inventory.rb +23 -19
  30. data/lib/stanford/storage_object_validator.rb +2 -0
  31. data/lib/stanford/storage_repository.rb +6 -2
  32. data/lib/stanford/storage_services.rb +2 -0
  33. metadata +22 -42
  34. data/lib/moab/deposit_bag_validator.rb +0 -323
  35. data/lib/moab/version_metadata.rb +0 -32
  36. data/lib/moab/version_metadata_event.rb +0 -40
  37. data/lib/stanford/active_fedora_object.rb +0 -28
  38. data/lib/stanford/dor_metadata.rb +0 -41
  39. data/lib/stanford/moab_storage_directory.rb +0 -36
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Moab
2
4
  # The descriptive attributes of a digital object version.
3
5
  #
@@ -22,7 +24,7 @@ module Moab
22
24
 
23
25
  # @attribute
24
26
  # @return [Integer] The object version number (A sequential integer)
25
- attribute :version_id, Integer, :tag => 'versionId', :key => true, :on_save => proc { |n| n.to_s }
27
+ attribute :version_id, Integer, tag: 'versionId', key: true, on_save: proc { |n| n.to_s }
26
28
 
27
29
  # @attribute
28
30
  # @return [String] "an external version label that increments the most significant digit for major revisions,
@@ -44,14 +46,14 @@ module Moab
44
46
 
45
47
  # @attribute
46
48
  # @return [FileGroupDifference] Summary of content file differences since previous version
47
- element :content_changes, FileGroupDifference, :tag => 'fileGroupDifference'
49
+ element :content_changes, FileGroupDifference, tag: 'fileGroupDifference'
48
50
 
49
51
  # @attribute
50
52
  # @return [FileGroupDifference] Summary of metadata file differences since previous version
51
- element :metadata_changes, FileGroupDifference, :tag => 'fileGroupDifference'
53
+ element :metadata_changes, FileGroupDifference, tag: 'fileGroupDifference'
52
54
 
53
55
  # @attribute
54
56
  # @return [Array<VersionMetadataEvent>] Array of events with timestamps that track lifecycle stages
55
- has_many :events, VersionMetadataEvent, :tag => 'event'
57
+ has_many :events, VersionMetadataEvent, tag: 'event'
56
58
  end
57
59
  end
data/lib/moab.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Moab is a module that provides a distintive namespace for the collection of classes it contains.
2
4
  #
3
5
  # ====Data Model
@@ -18,10 +20,6 @@
18
20
  # * {FileInstanceDifference} [1..*] = contains difference information at the file level
19
21
  # * {FileSignature} [1..2] = contains the file signature(s) of two file instances being compared
20
22
  #
21
- # * <b>{VersionMetadata} = descriptive information about a digital object's versions</b>
22
- # * {VersionMetadataEntry} [1..*] = attributes of a digital object version
23
- # * {VersionMetadataEvent} [1..*] = object version lifecycle events with timestamps
24
- #
25
23
  # * <b>{StorageObject} = represents a digital object's repository storage location and ingest/dissemination methods</b>
26
24
  # * {StorageObjectVersion} [1..*] = represents a version subdirectory within an object's home directory
27
25
  # * {Bagger} [1] = utility for creating bagit packages for ingest or dissemination
@@ -33,7 +31,6 @@ module Moab
33
31
  end
34
32
 
35
33
  require 'serializer'
36
- require 'confstruct/configuration'
37
34
  require 'moab/config'
38
35
  require 'moab/utc_time'
39
36
  require 'moab/file_signature'
@@ -47,9 +44,6 @@ require 'moab/file_instance_difference'
47
44
  require 'moab/file_group_difference_subset'
48
45
  require 'moab/file_group_difference'
49
46
  require 'moab/file_inventory_difference'
50
- require 'moab/version_metadata_event'
51
- require 'moab/version_metadata_entry'
52
- require 'moab/version_metadata'
53
47
  require 'moab/bagger'
54
48
  require 'moab/storage_object'
55
49
  require 'moab/storage_object_version'
@@ -58,4 +52,3 @@ require 'moab/storage_services'
58
52
  require 'moab/exceptions'
59
53
  require 'moab/verification_result'
60
54
  require 'moab/storage_object_validator'
61
- require 'moab/deposit_bag_validator'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Serializer
2
4
  # Subclass of {Serializable} that adds methods for marshalling/unmarshalling data
3
5
  # to a persistent XML file format.
@@ -20,7 +22,7 @@ module Serializer
20
22
  filename
21
23
  else
22
24
  cname = name.split(/::/).last
23
- cname[0, 1].downcase + cname[1..-1] + '.xml'
25
+ "#{cname[0, 1].downcase}#{cname[1..]}.xml"
24
26
  end
25
27
  end
26
28
 
@@ -57,7 +59,7 @@ module Serializer
57
59
  def self.write_xml_file(xml_object, parent_dir, filename = nil)
58
60
  parent_dir.mkpath
59
61
  xml_pathname(parent_dir, filename).open('w') do |f|
60
- xmlBuilder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8')
62
+ xmlBuilder = Nokogiri::XML::Builder.new(encoding: 'UTF-8')
61
63
  xmlBuilder = xml_object.to_xml(xmlBuilder)
62
64
  f << xmlBuilder.to_xml
63
65
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Serializer
2
4
  # Some utility methods to faciliate serialization of data fields to Hash, JSON, or YAML shared by all subclasses.
3
5
  # This class assumes that HappyMapper is used for declaration of fields to be serialized.
@@ -21,6 +23,7 @@ module Serializer
21
23
  opts.each do |key, value|
22
24
  errmsg = "#{key} is not a variable name in #{self.class.name}"
23
25
  raise(Moab::MoabRuntimeError, errmsg) unless variable_names.include?(key.to_s) || key == :test
26
+
24
27
  instance_variable_set("@#{key}", value)
25
28
  end
26
29
  end
@@ -68,6 +71,7 @@ module Serializer
68
71
  # @return [String] For the current object instance, return the string to use as a hash key
69
72
  def key
70
73
  return send(key_name) if key_name
74
+
71
75
  nil
72
76
  end
73
77
 
@@ -109,7 +113,7 @@ module Serializer
109
113
 
110
114
  # @return [Hash] Calls to_hash(summary=true)
111
115
  def summary
112
- to_hash(summary = true)
116
+ to_hash(true)
113
117
  end
114
118
 
115
119
  # @api internal
@@ -117,6 +121,7 @@ module Serializer
117
121
  # @return [Hash] Generate a hash containing the differences between two objects of the same type
118
122
  def diff(other)
119
123
  raise(Moab::MoabRuntimeError, "Cannot compare different classes") if self.class != other.class
124
+
120
125
  left = other.to_hash
121
126
  right = to_hash
122
127
  if key.nil? || other.key.nil?
data/lib/serializer.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Serializer is a module containing classes whose methods faciliate serialization
2
4
  # of data fields to various formats. To obtain those benefits, a dependent class
3
5
  # should inherit from {Serializable} or {Manifest}
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Stanford
2
4
  # Stanford-specific utility methods for transforming contentMetadata to versionInventory and doing comparisons
3
5
  #
@@ -21,7 +23,7 @@ module Stanford
21
23
  # Many of these objects have contentMetadata with no child elements, such as this:
22
24
  # <contentMetadata objectId="bd608mj3166" type="file"/>
23
25
  # but there are also objects that have no datasteam of this name at all
24
- cm_inventory = Moab::FileInventory.new(:type => "version", :digital_object_id => object_id, :version_id => version_id)
26
+ cm_inventory = Moab::FileInventory.new(type: "version", digital_object_id: object_id, version_id: version_id)
25
27
  content_group = group_from_cm(content_metadata, subset)
26
28
  cm_inventory.groups << content_group
27
29
  cm_inventory
@@ -47,7 +49,7 @@ module Stanford
47
49
  else
48
50
  raise(Moab::MoabRuntimeError, "Unknown disposition subset (#{subset})")
49
51
  end
50
- content_group = Moab::FileGroup.new(:group_id => 'content', :data_source => "contentMetadata-#{subset}")
52
+ content_group = Moab::FileGroup.new(group_id: 'content', data_source: "contentMetadata-#{subset}")
51
53
  nodeset.each do |file_node|
52
54
  signature = generate_signature(file_node)
53
55
  instance = generate_instance(file_node)
@@ -83,10 +85,10 @@ module Stanford
83
85
  instance = Moab::FileInstance.new
84
86
  instance.path = node.attributes['id'].content
85
87
  instance.datetime = begin
86
- node.attributes['datetime'].content
87
- rescue
88
- nil
89
- end
88
+ node.attributes['datetime'].content
89
+ rescue
90
+ nil
91
+ end
90
92
  instance
91
93
  end
92
94
 
@@ -96,23 +98,23 @@ module Stanford
96
98
  # @example {include:file:spec/features/stanford/content_metadata_write_spec.rb}
97
99
  def generate_content_metadata(file_group, object_id, version_id)
98
100
  cm = Nokogiri::XML::Builder.new do |xml|
99
- xml.contentMetadata(:type => "sample", :objectId => object_id) do
100
- xml.resource(:type => "version", :sequence => "1", :id => "version-#{version_id}") do
101
+ xml.contentMetadata(type: "sample", objectId: object_id) do
102
+ xml.resource(type: "version", sequence: "1", id: "version-#{version_id}") do
101
103
  file_group.files.each do |file_manifestation|
102
104
  signature = file_manifestation.signature
103
105
  file_manifestation.instances.each do |instance|
104
106
  xml.file(
105
- :id => instance.path,
106
- :size => signature.size,
107
- :datetime => instance.datetime,
108
- :shelve => 'yes',
109
- :publish => 'yes',
110
- :preserve => 'yes'
107
+ id: instance.path,
108
+ size: signature.size,
109
+ datetime: instance.datetime,
110
+ shelve: 'yes',
111
+ publish: 'yes',
112
+ preserve: 'yes'
111
113
  ) do
112
114
  fixity = signature.fixity
113
- xml.checksum(:type => "MD5") { xml.text signature.md5 } if fixity[:md5]
114
- xml.checksum(:type => "SHA-1") { xml.text signature.sha1 } if fixity[:sha1]
115
- xml.checksum(:type => "SHA-256") { xml.text signature.sha256 } if fixity[:sha256]
115
+ xml.checksum(type: "MD5") { xml.text signature.md5 } if fixity[:md5]
116
+ xml.checksum(type: "SHA-1") { xml.text signature.sha1 } if fixity[:sha1]
117
+ xml.checksum(type: "SHA-256") { xml.text signature.sha256 } if fixity[:sha256]
116
118
  end
117
119
  end
118
120
  end
@@ -126,7 +128,8 @@ module Stanford
126
128
  # @return [Boolean] True if contentMetadata has essential file attributes, else raise exception
127
129
  def validate_content_metadata(content_metadata)
128
130
  result = validate_content_metadata_details(content_metadata)
129
- raise Moab::InvalidMetadataException, result[0] + " ..." unless result.empty?
131
+ raise Moab::InvalidMetadataException, "#{result[0]} ..." unless result.empty?
132
+
130
133
  true
131
134
  end
132
135
 
@@ -176,6 +179,7 @@ module Stanford
176
179
  def remediate_content_metadata(content_metadata, content_group)
177
180
  return nil if content_metadata.nil?
178
181
  return content_metadata if content_group.nil? || content_group.files.empty?
182
+
179
183
  signature_for_path = content_group.path_hash
180
184
  @type_for_name = Moab::FileSignature.checksum_type_for_name
181
185
  @names_for_type = Moab::FileSignature.checksum_names_for_type
@@ -187,7 +191,7 @@ module Stanford
187
191
  remediate_file_size(file_node, signature)
188
192
  remediate_checksum_nodes(file_node, signature)
189
193
  end
190
- ng_doc.to_xml(:indent => 2)
194
+ ng_doc.to_xml(indent: 2)
191
195
  end
192
196
 
193
197
  # @param [Nokogiri::XML::Element] file_node the File stanza being remediated
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Stanford
2
4
  # druids are Stanford specific entities
3
5
  class StorageObjectValidator < Moab::StorageObjectValidator
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'druid-tools'
2
4
 
3
5
  module Stanford
@@ -29,12 +31,14 @@ module Stanford
29
31
  # @param object_id [String] The identifier of the digital object whose path is requested
30
32
  # @return [String] the druid tree directory path based on the given object identifier.
31
33
  def druid_tree(object_id)
32
- # Note: this seems an odd place to do druid validation, but leaving it here for now
34
+ # NOTE: this seems an odd place to do druid validation, but leaving it here for now
33
35
  syntax_msg = "Identifier has invalid suri syntax: #{object_id}"
34
- raise(Moab::InvalidSuriSyntaxError, syntax_msg + " nil or empty") if object_id.to_s.empty?
36
+ raise(Moab::InvalidSuriSyntaxError, "#{syntax_msg} nil or empty") if object_id.to_s.empty?
37
+
35
38
  identifier = object_id.split(':')[-1]
36
39
  raise(Moab::InvalidSuriSyntaxError, syntax_msg) if identifier.to_s.empty?
37
40
  raise(Moab::InvalidSuriSyntaxError, syntax_msg) unless DruidTools::Druid.valid?(identifier, true)
41
+
38
42
  DruidTools::Druid.new(identifier, true).tree.join(File::SEPARATOR)
39
43
  end
40
44
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Stanford
2
4
  # An interface class to support access to SDR storage via a RESTful server
3
5
  class StorageServices < Moab::StorageServices
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moab-versioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 5.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Weber
@@ -11,24 +11,24 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-11-15 00:00:00.000000000 Z
14
+ date: 2021-10-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: confstruct
17
+ name: druid-tools
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: '0'
22
+ version: 1.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '0'
29
+ version: 1.0.0
30
30
  - !ruby/object:Gem::Dependency
31
- name: nokogiri
31
+ name: json
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - ">="
@@ -42,7 +42,7 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  - !ruby/object:Gem::Dependency
45
- name: nokogiri-happymapper
45
+ name: nokogiri
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - ">="
@@ -56,7 +56,7 @@ dependencies:
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  - !ruby/object:Gem::Dependency
59
- name: json
59
+ name: nokogiri-happymapper
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - ">="
@@ -70,21 +70,7 @@ dependencies:
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  - !ruby/object:Gem::Dependency
73
- name: druid-tools
74
- requirement: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: 1.0.0
79
- type: :runtime
80
- prerelease: false
81
- version_requirements: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: 1.0.0
86
- - !ruby/object:Gem::Dependency
87
- name: equivalent-xml
73
+ name: coveralls
88
74
  requirement: !ruby/object:Gem::Requirement
89
75
  requirements:
90
76
  - - ">="
@@ -98,7 +84,7 @@ dependencies:
98
84
  - !ruby/object:Gem::Version
99
85
  version: '0'
100
86
  - !ruby/object:Gem::Dependency
101
- name: rake
87
+ name: equivalent-xml
102
88
  requirement: !ruby/object:Gem::Requirement
103
89
  requirements:
104
90
  - - ">="
@@ -112,7 +98,7 @@ dependencies:
112
98
  - !ruby/object:Gem::Version
113
99
  version: '0'
114
100
  - !ruby/object:Gem::Dependency
115
- name: rspec
101
+ name: pry-byebug
116
102
  requirement: !ruby/object:Gem::Requirement
117
103
  requirements:
118
104
  - - ">="
@@ -126,7 +112,7 @@ dependencies:
126
112
  - !ruby/object:Gem::Version
127
113
  version: '0'
128
114
  - !ruby/object:Gem::Dependency
129
- name: coveralls
115
+ name: rake
130
116
  requirement: !ruby/object:Gem::Requirement
131
117
  requirements:
132
118
  - - ">="
@@ -140,7 +126,7 @@ dependencies:
140
126
  - !ruby/object:Gem::Version
141
127
  version: '0'
142
128
  - !ruby/object:Gem::Dependency
143
- name: pry-byebug
129
+ name: rspec
144
130
  requirement: !ruby/object:Gem::Requirement
145
131
  requirements:
146
132
  - - ">="
@@ -159,28 +145,28 @@ dependencies:
159
145
  requirements:
160
146
  - - "~>"
161
147
  - !ruby/object:Gem::Version
162
- version: 0.50.0
148
+ version: '1.7'
163
149
  type: :development
164
150
  prerelease: false
165
151
  version_requirements: !ruby/object:Gem::Requirement
166
152
  requirements:
167
153
  - - "~>"
168
154
  - !ruby/object:Gem::Version
169
- version: 0.50.0
155
+ version: '1.7'
170
156
  - !ruby/object:Gem::Dependency
171
157
  name: rubocop-rspec
172
158
  requirement: !ruby/object:Gem::Requirement
173
159
  requirements:
174
160
  - - "~>"
175
161
  - !ruby/object:Gem::Version
176
- version: 1.18.0
162
+ version: '2.1'
177
163
  type: :development
178
164
  prerelease: false
179
165
  version_requirements: !ruby/object:Gem::Requirement
180
166
  requirements:
181
167
  - - "~>"
182
168
  - !ruby/object:Gem::Version
183
- version: 1.18.0
169
+ version: '2.1'
184
170
  description: Contains classes to process digital object version content and metadata
185
171
  email:
186
172
  - darren.weber@stanford.edu
@@ -191,7 +177,6 @@ files:
191
177
  - lib/moab.rb
192
178
  - lib/moab/bagger.rb
193
179
  - lib/moab/config.rb
194
- - lib/moab/deposit_bag_validator.rb
195
180
  - lib/moab/exceptions.rb
196
181
  - lib/moab/file_group.rb
197
182
  - lib/moab/file_group_difference.rb
@@ -212,16 +197,11 @@ files:
212
197
  - lib/moab/storage_services.rb
213
198
  - lib/moab/utc_time.rb
214
199
  - lib/moab/verification_result.rb
215
- - lib/moab/version_metadata.rb
216
200
  - lib/moab/version_metadata_entry.rb
217
- - lib/moab/version_metadata_event.rb
218
201
  - lib/serializer.rb
219
202
  - lib/serializer/manifest.rb
220
203
  - lib/serializer/serializable.rb
221
- - lib/stanford/active_fedora_object.rb
222
204
  - lib/stanford/content_inventory.rb
223
- - lib/stanford/dor_metadata.rb
224
- - lib/stanford/moab_storage_directory.rb
225
205
  - lib/stanford/storage_object_validator.rb
226
206
  - lib/stanford/storage_repository.rb
227
207
  - lib/stanford/storage_services.rb
@@ -235,16 +215,16 @@ require_paths:
235
215
  - lib
236
216
  required_ruby_version: !ruby/object:Gem::Requirement
237
217
  requirements:
238
- - - "~>"
218
+ - - ">="
239
219
  - !ruby/object:Gem::Version
240
- version: '2.1'
220
+ version: '2.6'
241
221
  required_rubygems_version: !ruby/object:Gem::Requirement
242
222
  requirements:
243
- - - ">="
223
+ - - ">"
244
224
  - !ruby/object:Gem::Version
245
- version: '0'
225
+ version: 1.3.1
246
226
  requirements: []
247
- rubygems_version: 3.0.3
227
+ rubygems_version: 3.1.4
248
228
  signing_key:
249
229
  specification_version: 4
250
230
  summary: Ruby implementation of digital object versioning toolkit used by the SULAIR