moab-versioning 4.2.2 → 4.3.0
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 +5 -5
- data/lib/moab/bagger.rb +3 -3
- data/lib/moab/exceptions.rb +6 -10
- data/lib/moab/file_group.rb +2 -2
- data/lib/moab/file_signature.rb +2 -2
- data/lib/moab/signature_catalog.rb +1 -1
- data/lib/moab/storage_object.rb +3 -3
- data/lib/moab/storage_object_version.rb +3 -3
- data/lib/moab/storage_repository.rb +7 -7
- data/lib/moab/utc_time.rb +2 -2
- data/lib/serializer/serializable.rb +3 -2
- data/lib/stanford/content_inventory.rb +3 -3
- data/lib/stanford/storage_repository.rb +3 -3
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dd9a6b4c49a9ab93e011a23004c0c21b74878ff7dc46c29b022c56b83627c3bb
|
4
|
+
data.tar.gz: 065bb99748c0e06d5f3fafebc9b75552e1585709e170d27b27a5f14cb7b1db85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2efdbe79de69d26b41de7de0052ade6e3c8cf1a8651e6e05d093b889cb0de0ac47061663951bef33082012719b3f5774ff37ced11ef210a8f7a67cfbc7bbb7b2
|
7
|
+
data.tar.gz: cd9518df71844ea61f4b036d08d51e2c86456c28492404265b8bd68d8510db1556ac359abd3ae95736011431ebab6bbe4a804530875e060b278dd54a9e57aff5
|
data/lib/moab/bagger.rb
CHANGED
@@ -259,7 +259,7 @@ module Moab
|
|
259
259
|
rescue
|
260
260
|
shell_execute(tar_cmd.sub('--force-local', ''))
|
261
261
|
end
|
262
|
-
raise "Unable to create tarfile #{tar_pathname}" unless tar_pathname.exist?
|
262
|
+
raise(MoabRuntimeError, "Unable to create tarfile #{tar_pathname}") unless tar_pathname.exist?
|
263
263
|
true
|
264
264
|
end
|
265
265
|
|
@@ -274,11 +274,11 @@ module Moab
|
|
274
274
|
else
|
275
275
|
msg = "Shell command failed: [#{command}] caused by <STDERR = #{stderr}>"
|
276
276
|
msg << " STDOUT = #{stdout}" if stdout && stdout.length.positive?
|
277
|
-
raise(
|
277
|
+
raise(MoabStandardError, msg)
|
278
278
|
end
|
279
279
|
rescue SystemCallError => e
|
280
280
|
msg = "Shell command failed: [#{command}] caused by #{e.inspect}"
|
281
|
-
raise(
|
281
|
+
raise(MoabStandardError, msg)
|
282
282
|
end
|
283
283
|
end
|
284
284
|
end
|
data/lib/moab/exceptions.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
module Moab
|
2
|
-
class
|
3
|
-
end
|
2
|
+
class MoabRuntimeError < RuntimeError; end
|
3
|
+
class MoabStandardError < StandardError; end
|
4
4
|
|
5
|
-
class FileNotFoundException <
|
6
|
-
end
|
7
|
-
|
8
|
-
class
|
9
|
-
end
|
10
|
-
|
11
|
-
class ValidationException < RuntimeError
|
12
|
-
end
|
5
|
+
class FileNotFoundException < MoabRuntimeError; end
|
6
|
+
class InvalidMetadataException < MoabRuntimeError; end
|
7
|
+
class InvalidSuriSyntaxError < MoabRuntimeError; end
|
8
|
+
class ObjectNotFoundException < MoabRuntimeError; end
|
13
9
|
end
|
data/lib/moab/file_group.rb
CHANGED
@@ -160,10 +160,10 @@ module Moab
|
|
160
160
|
# @param pathname [Pathname] The file path to be tested
|
161
161
|
# @return [Boolean] Test whether the given path is contained within the {#base_directory}
|
162
162
|
def is_descendent_of_base?(pathname)
|
163
|
-
raise("base_directory has not been set") if @base_directory.nil?
|
163
|
+
raise(MoabRuntimeError, "base_directory has not been set") if @base_directory.nil?
|
164
164
|
is_descendent = false
|
165
165
|
pathname.expand_path.ascend { |ancestor| is_descendent ||= (ancestor == @base_directory) }
|
166
|
-
raise("#{pathname} is not a descendent of #{@base_directory}") unless is_descendent
|
166
|
+
raise(MoabRuntimeError, "#{pathname} is not a descendent of #{@base_directory}") unless is_descendent
|
167
167
|
is_descendent
|
168
168
|
end
|
169
169
|
|
data/lib/moab/file_signature.rb
CHANGED
@@ -73,7 +73,7 @@ module Moab
|
|
73
73
|
# @param [Array<Symbol>] one or more keys of KNOWN_ALGOS to be computed
|
74
74
|
# @return [Moab::FileSignature] object populated with (requested) checksums
|
75
75
|
def self.from_file(pathname, algos_to_use = active_algos)
|
76
|
-
raise 'Unrecognized algorithm requested' unless algos_to_use.all? { |a| KNOWN_ALGOS.include?(a) }
|
76
|
+
raise(MoabRuntimeError, 'Unrecognized algorithm requested') unless algos_to_use.all? { |a| KNOWN_ALGOS.include?(a) }
|
77
77
|
|
78
78
|
signatures = algos_to_use.map { |k| [k, KNOWN_ALGOS[k].call] }.to_h
|
79
79
|
|
@@ -178,7 +178,7 @@ module Moab
|
|
178
178
|
return sig_from_file if eql?(sig_from_file)
|
179
179
|
# The full signature from file is consistent with current values, or...
|
180
180
|
# One or more of the fixity values is inconsistent, so raise an exception
|
181
|
-
raise "Signature inconsistent between inventory and file for #{pathname}: #{diff(sig_from_file).inspect}"
|
181
|
+
raise(MoabRuntimeError, "Signature inconsistent between inventory and file for #{pathname}: #{diff(sig_from_file).inspect}")
|
182
182
|
end
|
183
183
|
|
184
184
|
# @return [Hash<Symbol,String>] Key is type (e.g. :sha1), value is checksum names (e.g. ['SHA-1', 'SHA1'])
|
@@ -128,7 +128,7 @@ module Moab
|
|
128
128
|
def normalize_group_signatures(group, group_pathname = nil)
|
129
129
|
unless group_pathname.nil?
|
130
130
|
group_pathname = Pathname(group_pathname)
|
131
|
-
raise "Could not locate #{group_pathname}" unless group_pathname.exist?
|
131
|
+
raise(MoabRuntimeError, "Could not locate #{group_pathname}") unless group_pathname.exist?
|
132
132
|
end
|
133
133
|
group.files.each do |file|
|
134
134
|
unless file.signature.complete?
|
data/lib/moab/storage_object.rb
CHANGED
@@ -161,7 +161,7 @@ module Moab
|
|
161
161
|
# @return [Boolean] Tests whether the new version number is one higher than the current version number
|
162
162
|
def validate_new_inventory(version_inventory)
|
163
163
|
if version_inventory.version_id != (current_version_id + 1)
|
164
|
-
raise "version mismatch - current: #{current_version_id} new: #{version_inventory.version_id}"
|
164
|
+
raise(MoabRuntimeError, "version mismatch - current: #{current_version_id} new: #{version_inventory.version_id}")
|
165
165
|
end
|
166
166
|
true
|
167
167
|
end
|
@@ -177,7 +177,7 @@ module Moab
|
|
177
177
|
when 1..current
|
178
178
|
StorageObjectVersion.new(self, version_id)
|
179
179
|
else
|
180
|
-
raise "Version ID #{version_id} does not exist"
|
180
|
+
raise(MoabRuntimeError, "Version ID #{version_id} does not exist")
|
181
181
|
end
|
182
182
|
end
|
183
183
|
|
@@ -187,7 +187,7 @@ module Moab
|
|
187
187
|
# * Version 0 is a special case used to generate empty manifests
|
188
188
|
# * Current version + 1 is used for creation of a new version
|
189
189
|
def storage_object_version(version_id)
|
190
|
-
raise "Version ID not specified" unless version_id
|
190
|
+
raise(MoabRuntimeError, "Version ID not specified") unless version_id
|
191
191
|
StorageObjectVersion.new(self, version_id)
|
192
192
|
end
|
193
193
|
|
@@ -33,7 +33,7 @@ module Moab
|
|
33
33
|
elsif version_id.is_a?(String) && version_id =~ /^v(\d+)$/
|
34
34
|
@version_id = version_id.sub(/^v/, '').to_i
|
35
35
|
else
|
36
|
-
raise "version_id (#{version_id}) is not in a recognized format"
|
36
|
+
raise(MoabRuntimeError, "version_id (#{version_id}) is not in a recognized format")
|
37
37
|
end
|
38
38
|
@version_name = StorageObject.version_dirname(@version_id)
|
39
39
|
@version_pathname = storage_object.object_pathname.join(@version_name)
|
@@ -135,7 +135,7 @@ module Moab
|
|
135
135
|
# @param bag_dir [Pathname,String] The location of the bag to be ingested
|
136
136
|
# @return [void] Create the version subdirectory and move files into it
|
137
137
|
def ingest_bag_data(bag_dir)
|
138
|
-
raise "Version already exists: #{@version_pathname}" if @version_pathname.exist?
|
138
|
+
raise(MoabRuntimeError, "Version already exists: #{@version_pathname}") if @version_pathname.exist?
|
139
139
|
@version_pathname.join('manifests').mkpath
|
140
140
|
bag_dir = Pathname(bag_dir)
|
141
141
|
ingest_dir(bag_dir.join('data'), @version_pathname.join('data'))
|
@@ -149,7 +149,7 @@ module Moab
|
|
149
149
|
# @param use_links [Boolean] If true, use hard links; if false, make copies
|
150
150
|
# @return [void] recursively link or copy the source directory contents to the target directory
|
151
151
|
def ingest_dir(source_dir, target_dir, use_links = true)
|
152
|
-
raise "cannot copy - target already exists: #{target_dir.expand_path}" if target_dir.exist?
|
152
|
+
raise(MoabRuntimeError, "cannot copy - target already exists: #{target_dir.expand_path}") if target_dir.exist?
|
153
153
|
target_dir.mkpath
|
154
154
|
source_dir.children.each do |child|
|
155
155
|
if child.directory?
|
@@ -18,10 +18,10 @@ module Moab
|
|
18
18
|
# @return [Array<Pathname>] The list of filesystem root paths in which objects are stored
|
19
19
|
def storage_roots
|
20
20
|
unless defined?(@storage_roots)
|
21
|
-
raise "Moab::Config.storage_roots not found in config file" if Moab::Config.storage_roots.nil?
|
21
|
+
raise(MoabRuntimeError, "Moab::Config.storage_roots not found in config file") if Moab::Config.storage_roots.nil?
|
22
22
|
@storage_roots = [Moab::Config.storage_roots].flatten.collect { |filesystem| Pathname(filesystem) }
|
23
|
-
raise "Moab::Config.storage_roots empty" if @storage_roots.empty?
|
24
|
-
@storage_roots.each { |root| raise "Storage root #{root} not found on system" unless root.exist? }
|
23
|
+
raise(MoabRuntimeError, "Moab::Config.storage_roots empty") if @storage_roots.empty?
|
24
|
+
@storage_roots.each { |root| raise(MoabRuntimeError, "Storage root #{root} not found on system") unless root.exist? }
|
25
25
|
end
|
26
26
|
@storage_roots
|
27
27
|
end
|
@@ -29,7 +29,7 @@ module Moab
|
|
29
29
|
# @return [String] The trunk segment of the object storage path
|
30
30
|
def storage_trunk
|
31
31
|
unless defined?(@storage_trunk)
|
32
|
-
raise "Moab::Config.storage_trunk not found in config file" if Moab::Config.storage_trunk.nil?
|
32
|
+
raise(MoabRuntimeError, "Moab::Config.storage_trunk not found in config file") if Moab::Config.storage_trunk.nil?
|
33
33
|
@storage_trunk = Moab::Config.storage_trunk
|
34
34
|
end
|
35
35
|
@storage_trunk
|
@@ -70,7 +70,7 @@ module Moab
|
|
70
70
|
branch = storage_branch(object_id)
|
71
71
|
storage_roots.each do |root|
|
72
72
|
root_trunk = root.join(storage_trunk)
|
73
|
-
raise "Storage area not found at #{root_trunk}" unless root_trunk.exist?
|
73
|
+
raise(MoabRuntimeError, "Storage area not found at #{root_trunk}") unless root_trunk.exist?
|
74
74
|
root_trunk_branch = root_trunk.join(branch)
|
75
75
|
return root if root_trunk_branch.exist?
|
76
76
|
end
|
@@ -79,7 +79,7 @@ module Moab
|
|
79
79
|
branch = deposit_branch(object_id)
|
80
80
|
storage_roots.each do |root|
|
81
81
|
root_trunk = root.join(deposit_trunk)
|
82
|
-
raise "Deposit area not found at #{root_trunk}" unless root_trunk.exist?
|
82
|
+
raise(MoabRuntimeError, "Deposit area not found at #{root_trunk}") unless root_trunk.exist?
|
83
83
|
root_trunk_branch = root_trunk.join(branch)
|
84
84
|
return root if root_trunk_branch.exist?
|
85
85
|
end
|
@@ -117,7 +117,7 @@ module Moab
|
|
117
117
|
def storage_object(object_id, create = false)
|
118
118
|
storage_object = find_storage_object(object_id)
|
119
119
|
unless storage_object.object_pathname.exist?
|
120
|
-
raise
|
120
|
+
raise ObjectNotFoundException, "No storage object found for #{object_id}" unless create
|
121
121
|
storage_object.object_pathname.mkpath
|
122
122
|
end
|
123
123
|
storage_object
|
data/lib/moab/utc_time.rb
CHANGED
@@ -14,7 +14,7 @@ module Moab
|
|
14
14
|
when Time
|
15
15
|
datetime
|
16
16
|
else
|
17
|
-
raise "unknown time format #{datetime.inspect}"
|
17
|
+
raise(MoabRuntimeError, "unknown time format #{datetime.inspect}")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -29,7 +29,7 @@ module Moab
|
|
29
29
|
when Time
|
30
30
|
datetime.utc.iso8601
|
31
31
|
else
|
32
|
-
raise "unknown time format #{datetime.inspect}"
|
32
|
+
raise(MoabRuntimeError, "unknown time format #{datetime.inspect}")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -19,7 +19,8 @@ module Serializer
|
|
19
19
|
# The symbols should correspond to attributes declared using HappyMapper syntax
|
20
20
|
def initialize(opts = {})
|
21
21
|
opts.each do |key, value|
|
22
|
-
|
22
|
+
errmsg = "#{key} is not a variable name in #{self.class.name}"
|
23
|
+
raise(Moab::MoabRuntimeError, errmsg) unless variable_names.include?(key.to_s) || key == :test
|
23
24
|
instance_variable_set("@#{key}", value)
|
24
25
|
end
|
25
26
|
end
|
@@ -115,7 +116,7 @@ module Serializer
|
|
115
116
|
# @param other [Serializable] The other object being compared
|
116
117
|
# @return [Hash] Generate a hash containing the differences between two objects of the same type
|
117
118
|
def diff(other)
|
118
|
-
raise "Cannot compare different classes" if self.class != other.class
|
119
|
+
raise(Moab::MoabRuntimeError, "Cannot compare different classes") if self.class != other.class
|
119
120
|
left = other.to_hash
|
120
121
|
right = to_hash
|
121
122
|
if key.nil? || other.key.nil?
|
@@ -45,7 +45,7 @@ module Stanford
|
|
45
45
|
when 'all'
|
46
46
|
ng_doc.xpath("//file")
|
47
47
|
else
|
48
|
-
raise "Unknown disposition subset (#{subset})"
|
48
|
+
raise(Moab::MoabRuntimeError, "Unknown disposition subset (#{subset})")
|
49
49
|
end
|
50
50
|
content_group = Moab::FileGroup.new(:group_id => 'content', :data_source => "contentMetadata-#{subset}")
|
51
51
|
nodeset.each do |file_node|
|
@@ -198,7 +198,7 @@ module Stanford
|
|
198
198
|
if file_size.nil? || file_size.empty?
|
199
199
|
file_node['size'] = signature.size.to_s
|
200
200
|
elsif file_size != signature.size.to_s
|
201
|
-
raise "Inconsistent size for #{file_node['id']}: #{file_size} != #{signature.size}"
|
201
|
+
raise(Moab::MoabRuntimeError, "Inconsistent size for #{file_node['id']}: #{file_size} != #{signature.size}")
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
@@ -228,7 +228,7 @@ module Stanford
|
|
228
228
|
if cm_checksum.nil? || cm_checksum.empty?
|
229
229
|
checksum_node.content = sig_checksum
|
230
230
|
elsif cm_checksum != sig_checksum
|
231
|
-
raise "Inconsistent #{type} for #{file_node['id']}: #{cm_checksum} != #{sig_checksum}"
|
231
|
+
raise(Moab::MoabRuntimeError, "Inconsistent #{type} for #{file_node['id']}: #{cm_checksum} != #{sig_checksum}")
|
232
232
|
end
|
233
233
|
end
|
234
234
|
end
|
@@ -31,10 +31,10 @@ module Stanford
|
|
31
31
|
def druid_tree(object_id)
|
32
32
|
# Note: this seems an odd place to do druid validation, but leaving it here for now
|
33
33
|
syntax_msg = "Identifier has invalid suri syntax: #{object_id}"
|
34
|
-
raise syntax_msg + " nil or empty" if object_id.to_s.empty?
|
34
|
+
raise(Moab::InvalidSuriSyntaxError, syntax_msg + " nil or empty") if object_id.to_s.empty?
|
35
35
|
identifier = object_id.split(':')[-1]
|
36
|
-
raise syntax_msg if identifier.to_s.empty?
|
37
|
-
raise syntax_msg unless DruidTools::Druid.valid?(identifier, true)
|
36
|
+
raise(Moab::InvalidSuriSyntaxError, syntax_msg) if identifier.to_s.empty?
|
37
|
+
raise(Moab::InvalidSuriSyntaxError, syntax_msg) unless DruidTools::Druid.valid?(identifier, true)
|
38
38
|
DruidTools::Druid.new(identifier, true).tree.join(File::SEPARATOR)
|
39
39
|
end
|
40
40
|
end
|
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.
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Weber
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2019-11-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: confstruct
|
@@ -244,8 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
244
|
- !ruby/object:Gem::Version
|
245
245
|
version: '0'
|
246
246
|
requirements: []
|
247
|
-
|
248
|
-
rubygems_version: 2.6.13
|
247
|
+
rubygems_version: 3.0.3
|
249
248
|
signing_key:
|
250
249
|
specification_version: 4
|
251
250
|
summary: Ruby implementation of digital object versioning toolkit used by the SULAIR
|