moab-versioning 4.4.1 → 4.4.2

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: e07f40b9d0310571b007d21bd9a0f08572b02d4f1396c79cdf2e6b96d616ae13
4
- data.tar.gz: 56d0ea7fa3f43bf1c38e283b46028858163d47fa4432614e4a8ced40e7105de2
3
+ metadata.gz: 4b576c73187205ae4548c6460bac2b68cedab5dc7c3b94a66a5d8ec13729c6ae
4
+ data.tar.gz: e714a158d2e1388dec94482c1fa858a2ee29a6eca6e0f9004658446801088476
5
5
  SHA512:
6
- metadata.gz: 1a809dc2e8f57cc405843bd49116368a9ae7c1db3fda35b053ea4267b148e7f4fea792c601bbb3c52370e4df1cd3d9d51c02af6023e6fa1d9ce885671ad4284a
7
- data.tar.gz: 13c2954fe8e666bb8366a4c9b871fa6114e069ba90f6d6e2536f3fc9a7ce6bf576842045b735d2913599301d43940365c5cbd20978bec27ab91ff689d9e00943
6
+ metadata.gz: 251925f9e4c45f20f6ae4270fc73adfe9f4645689bda08ebd42c2b707909177ab575e0427c83e321c2ebc039c735f9bc141b29037f28cb65249c25bd9e76d520
7
+ data.tar.gz: '053391d53a3a3a46bbfedce8e7a04ea0f28a7f5c43689c2bde3c1901f9303eae7356d507904ec1892d9da61f2d4c9c6e58ed3fec894985e19b9ab85dd5fa65fd'
@@ -191,7 +191,7 @@ module Moab
191
191
  home_dir_pathnames = deposit_bag_pathname.children.reject { |file| file.basename.to_s.start_with?(TAGMANIFEST) }
192
192
  hash_with_full_pathnames = generate_checksums_hash(home_dir_pathnames, types_to_generate)
193
193
  # return hash keys as basenames only
194
- hash_with_full_pathnames.map { |k, v| [Pathname.new(k).basename.to_s, v] }.to_h
194
+ hash_with_full_pathnames.transform_keys { |k| Pathname.new(k).basename.to_s }
195
195
  end
196
196
 
197
197
  # generate hash of checksums by file name for bag data dir files
@@ -199,7 +199,7 @@ module Moab
199
199
  data_pathnames = deposit_bag_pathname.join(DATA_DIR_BASENAME).find
200
200
  hash_with_full_pathnames = generate_checksums_hash(data_pathnames, types_to_generate)
201
201
  # return hash keys beginning with 'data/'
202
- hash_with_full_pathnames.map { |k, v| [Pathname.new(k).relative_path_from(deposit_bag_pathname).to_s, v] }.to_h
202
+ hash_with_full_pathnames.transform_keys { |k| Pathname.new(k).relative_path_from(deposit_bag_pathname).to_s }
203
203
  end
204
204
 
205
205
  def generate_checksums_hash(pathnames, types_to_generate)
@@ -2,10 +2,14 @@
2
2
 
3
3
  module Moab
4
4
  class MoabRuntimeError < RuntimeError; end
5
+
5
6
  class MoabStandardError < StandardError; end
6
7
 
7
8
  class FileNotFoundException < MoabRuntimeError; end
9
+
8
10
  class InvalidMetadataException < MoabRuntimeError; end
11
+
9
12
  class InvalidSuriSyntaxError < MoabRuntimeError; end
13
+
10
14
  class ObjectNotFoundException < MoabRuntimeError; end
11
15
  end
@@ -30,15 +30,15 @@ module Moab
30
30
 
31
31
  # @attribute
32
32
  # @return [String] The name of the file group
33
- attribute :group_id, String, :tag => 'groupId', :key => true
33
+ attribute :group_id, String, tag: 'groupId', key: true
34
34
 
35
35
  # @attribute
36
36
  # @return [String] The directory location or other source of this groups file data
37
- attribute :data_source, String, :tag => 'dataSource'
37
+ attribute :data_source, String, tag: 'dataSource'
38
38
 
39
39
  # @attribute
40
40
  # @return [Integer] The total number of data files (dynamically calculated)
41
- attribute :file_count, Integer, :tag => 'fileCount', :on_save => proc { |i| i.to_s }
41
+ attribute :file_count, Integer, tag: 'fileCount', on_save: proc { |i| i.to_s }
42
42
 
43
43
  def file_count
44
44
  files.inject(0) { |sum, manifestation| sum + manifestation.file_count }
@@ -46,7 +46,7 @@ module Moab
46
46
 
47
47
  # @attribute
48
48
  # @return [Integer] The total size (in bytes) of all data files (dynamically calculated)
49
- attribute :byte_count, Integer, :tag => 'byteCount', :on_save => proc { |i| i.to_s }
49
+ attribute :byte_count, Integer, tag: 'byteCount', on_save: proc { |i| i.to_s }
50
50
 
51
51
  def byte_count
52
52
  files.inject(0) { |sum, manifestation| sum + manifestation.byte_count }
@@ -54,7 +54,7 @@ module Moab
54
54
 
55
55
  # @attribute
56
56
  # @return [Integer] The total disk usage (in 1 kB blocks) of all data files (estimating du -k result) (dynamically calculated)
57
- attribute :block_count, Integer, :tag => 'blockCount', :on_save => proc { |i| i.to_s }
57
+ attribute :block_count, Integer, tag: 'blockCount', on_save: proc { |i| i.to_s }
58
58
 
59
59
  def block_count
60
60
  files.inject(0) { |sum, manifestation| sum + manifestation.block_count }
@@ -67,7 +67,7 @@ module Moab
67
67
 
68
68
  # @attribute
69
69
  # @return [Array<FileManifestation>] The set of files comprising the group
70
- has_many :files, FileManifestation, :tag => 'file'
70
+ has_many :files, FileManifestation, tag: 'file'
71
71
 
72
72
  def files
73
73
  signature_hash.values
@@ -53,18 +53,18 @@ module Moab
53
53
 
54
54
  # (see Serializable#initialize)
55
55
  def initialize(opts = {})
56
- @subset_hash = Hash.new { |hash, key| hash[key] = FileGroupDifferenceSubset.new(:change => key.to_s) }
56
+ @subset_hash = Hash.new { |hash, key| hash[key] = FileGroupDifferenceSubset.new(change: key.to_s) }
57
57
  super(opts)
58
58
  end
59
59
 
60
60
  # @attribute
61
61
  # @return [String] The name of the file group
62
- attribute :group_id, String, :tag => 'groupId', :key => true
62
+ attribute :group_id, String, tag: 'groupId', key: true
63
63
 
64
64
  # @attribute
65
65
  # @return [Integer] the total number of differences found between the two inventories that were
66
66
  # compared (dynamically calculated)
67
- attribute :difference_count, Integer, :tag => 'differenceCount', :on_save => proc { |i| i.to_s }
67
+ attribute :difference_count, Integer, tag: 'differenceCount', on_save: proc { |i| i.to_s }
68
68
 
69
69
  def difference_count
70
70
  count = 0
@@ -76,49 +76,49 @@ module Moab
76
76
 
77
77
  # @attribute
78
78
  # @return [Integer] How many files were unchanged
79
- attribute :identical, Integer, :on_save => proc { |n| n.to_s }
79
+ attribute :identical, Integer, on_save: proc { |n| n.to_s }
80
80
  def identical
81
81
  subset_hash[:identical].count
82
82
  end
83
83
 
84
84
  # @attribute
85
85
  # @return [Integer] How many duplicate copies of files were added
86
- attribute :copyadded, Integer, :on_save => proc { |n| n.to_s }
86
+ attribute :copyadded, Integer, on_save: proc { |n| n.to_s }
87
87
  def copyadded
88
88
  subset_hash[:copyadded].count
89
89
  end
90
90
 
91
91
  # @attribute
92
92
  # @return [Integer] How many duplicate copies of files were deleted
93
- attribute :copydeleted, Integer, :on_save => proc { |n| n.to_s }
93
+ attribute :copydeleted, Integer, on_save: proc { |n| n.to_s }
94
94
  def copydeleted
95
95
  subset_hash[:copydeleted].count
96
96
  end
97
97
 
98
98
  # @attribute
99
99
  # @return [Integer] How many files were renamed
100
- attribute :renamed, Integer, :on_save => proc { |n| n.to_s }
100
+ attribute :renamed, Integer, on_save: proc { |n| n.to_s }
101
101
  def renamed
102
102
  subset_hash[:renamed].count
103
103
  end
104
104
 
105
105
  # @attribute
106
106
  # @return [Integer] How many files were modified
107
- attribute :modified, Integer, :on_save => proc { |n| n.to_s }
107
+ attribute :modified, Integer, on_save: proc { |n| n.to_s }
108
108
  def modified
109
109
  subset_hash[:modified].count
110
110
  end
111
111
 
112
112
  # @attribute
113
113
  # @return [Integer] How many files were added
114
- attribute :added, Integer, :on_save => proc { |n| n.to_s }
114
+ attribute :added, Integer, on_save: proc { |n| n.to_s }
115
115
  def added
116
116
  subset_hash[:added].count
117
117
  end
118
118
 
119
119
  # @attribute
120
120
  # @return [Integer] How many files were deleted
121
- attribute :deleted, Integer, :on_save => proc { |n| n.to_s }
121
+ attribute :deleted, Integer, on_save: proc { |n| n.to_s }
122
122
  def deleted
123
123
  subset_hash[:deleted].count
124
124
  end
@@ -126,7 +126,7 @@ module Moab
126
126
  # @attribute
127
127
  # @return [Array<FileGroupDifferenceSubset>] A set of Arrays (one for each change type),
128
128
  # each of which contains an collection of file-level differences having that change type.
129
- has_many :subsets, FileGroupDifferenceSubset, :tag => 'subset'
129
+ has_many :subsets, FileGroupDifferenceSubset, tag: 'subset'
130
130
 
131
131
  def subsets
132
132
  subset_hash.values
@@ -147,14 +147,14 @@ module Moab
147
147
  # @return [FileGroupDifference] Clone just this element for inclusion in a versionMetadata structure
148
148
  def summary
149
149
  FileGroupDifference.new(
150
- :group_id => group_id,
151
- :identical => identical,
152
- :copyadded => copyadded,
153
- :copydeleted => copydeleted,
154
- :renamed => renamed,
155
- :modified => modified,
156
- :added => added,
157
- :deleted => deleted
150
+ group_id: group_id,
151
+ identical: identical,
152
+ copyadded: copyadded,
153
+ copydeleted: copydeleted,
154
+ renamed: renamed,
155
+ modified: modified,
156
+ added: added,
157
+ deleted: deleted
158
158
  )
159
159
  end
160
160
 
@@ -231,7 +231,7 @@ module Moab
231
231
  other_paths = other_signature_hash[signature].paths
232
232
  matching_paths = basis_paths & other_paths
233
233
  matching_paths.each do |path|
234
- fid = FileInstanceDifference.new(:change => 'identical')
234
+ fid = FileInstanceDifference.new(change: 'identical')
235
235
  fid.basis_path = path
236
236
  fid.other_path = "same"
237
237
  fid.signatures << signature
@@ -284,7 +284,7 @@ module Moab
284
284
  # Container for reporting the set of file-level differences of type 'modified'
285
285
  def tabulate_modified_files(basis_path_hash, other_path_hash)
286
286
  matching_keys(basis_path_hash, other_path_hash).each do |path|
287
- fid = FileInstanceDifference.new(:change => 'modified')
287
+ fid = FileInstanceDifference.new(change: 'modified')
288
288
  fid.basis_path = path
289
289
  fid.other_path = "same"
290
290
  fid.signatures << basis_path_hash[path]
@@ -303,7 +303,7 @@ module Moab
303
303
  # Container for reporting the set of file-level differences of type 'added'
304
304
  def tabulate_added_files(basis_path_hash, other_path_hash)
305
305
  other_only_keys(basis_path_hash, other_path_hash).each do |path|
306
- fid = FileInstanceDifference.new(:change => 'added')
306
+ fid = FileInstanceDifference.new(change: 'added')
307
307
  fid.basis_path = ""
308
308
  fid.other_path = path
309
309
  fid.signatures << other_path_hash[path]
@@ -321,7 +321,7 @@ module Moab
321
321
  # Container for reporting the set of file-level differences of type 'deleted'
322
322
  def tabulate_deleted_files(basis_path_hash, other_path_hash)
323
323
  basis_only_keys(basis_path_hash, other_path_hash).each do |path|
324
- fid = FileInstanceDifference.new(:change => 'deleted')
324
+ fid = FileInstanceDifference.new(change: 'deleted')
325
325
  fid.basis_path = path
326
326
  fid.other_path = ""
327
327
  fid.signatures << basis_path_hash[path]
@@ -26,11 +26,11 @@ module Moab
26
26
 
27
27
  # @attribute
28
28
  # @return [String] The type of change (identical|renamed|modified|deleted|added)
29
- attribute :change, String, :key => true
29
+ attribute :change, String, key: true
30
30
 
31
31
  # @attribute
32
32
  # @return [Integer] How many files were changed
33
- attribute :count, Integer, :on_save => proc { |n| n.to_s }
33
+ attribute :count, Integer, on_save: proc { |n| n.to_s }
34
34
 
35
35
  def count
36
36
  files.size
@@ -38,6 +38,6 @@ module Moab
38
38
 
39
39
  # @attribute
40
40
  # @return [Array<FileInstanceDifference>] The set of file instances having this type of change
41
- has_many :files, FileInstanceDifference, :tag => 'file'
41
+ has_many :files, FileInstanceDifference, tag: 'file'
42
42
  end
43
43
  end
@@ -25,7 +25,7 @@ module Moab
25
25
 
26
26
  # @attribute
27
27
  # @return [String] The id is the filename path, relative to the file group's base directory
28
- attribute :path, String, :key => true
28
+ attribute :path, String, key: true
29
29
 
30
30
  # @attribute
31
31
  # @return [String] gsub(/\n/,' ')
@@ -38,14 +38,14 @@ module Moab
38
38
 
39
39
  # @attribute
40
40
  # @return [String] The file's path in the basis inventory (usually for an old version)
41
- attribute :basis_path, String, :tag => 'basisPath', :on_save => proc { |s| s.to_s }
41
+ attribute :basis_path, String, tag: 'basisPath', on_save: proc { |s| s.to_s }
42
42
 
43
43
  # @attribute
44
44
  # @return [String] The file's path in the other inventory (usually for an new version) compared against the basis
45
- attribute :other_path, String, :tag => 'otherPath', :on_save => proc { |s| s.to_s }
45
+ attribute :other_path, String, tag: 'otherPath', on_save: proc { |s| s.to_s }
46
46
 
47
47
  # @attribute
48
48
  # @return [Array<FileSignature>] The fixity data of the file manifestation(s) (plural if change was a content modification)
49
- has_many :signatures, FileSignature, :tag => 'fileSignature'
49
+ has_many :signatures, FileSignature, tag: 'fileSignature'
50
50
  end
51
51
  end
@@ -46,20 +46,20 @@ module Moab
46
46
 
47
47
  # @attribute
48
48
  # @return [String] The digital object identifier (druid)
49
- attribute :digital_object_id, String, :tag => 'objectId'
49
+ attribute :digital_object_id, String, tag: 'objectId'
50
50
 
51
51
  # @attribute
52
52
  # @return [Integer] The ordinal version number
53
- attribute :version_id, Integer, :tag => 'versionId', :key => true, :on_save => proc { |n| n.to_s }
53
+ attribute :version_id, Integer, tag: 'versionId', key: true, on_save: proc { |n| n.to_s }
54
54
 
55
55
  # @return [String] The unique identifier concatenating digital object id with version id
56
56
  def composite_key
57
- digital_object_id + '-' + StorageObject.version_dirname(version_id)
57
+ "#{digital_object_id}-#{StorageObject.version_dirname(version_id)}"
58
58
  end
59
59
 
60
60
  # @attribute
61
61
  # @return [String] The datetime at which the inventory was created
62
- attribute :inventory_datetime, String, :tag => 'inventoryDatetime'
62
+ attribute :inventory_datetime, String, tag: 'inventoryDatetime'
63
63
 
64
64
  def inventory_datetime=(datetime)
65
65
  @inventory_datetime = Moab::UtcTime.input(datetime)
@@ -71,7 +71,7 @@ module Moab
71
71
 
72
72
  # @attribute
73
73
  # @return [Integer] The total number of data files in the inventory (dynamically calculated)
74
- attribute :file_count, Integer, :tag => 'fileCount', :on_save => proc { |t| t.to_s }
74
+ attribute :file_count, Integer, tag: 'fileCount', on_save: proc { |t| t.to_s }
75
75
 
76
76
  def file_count
77
77
  groups.inject(0) { |sum, group| sum + group.file_count }
@@ -79,7 +79,7 @@ module Moab
79
79
 
80
80
  # @attribute
81
81
  # @return [Integer] The total size (in bytes) in all files of all files in the inventory (dynamically calculated)
82
- attribute :byte_count, Integer, :tag => 'byteCount', :on_save => proc { |t| t.to_s }
82
+ attribute :byte_count, Integer, tag: 'byteCount', on_save: proc { |t| t.to_s }
83
83
 
84
84
  def byte_count
85
85
  groups.inject(0) { |sum, group| sum + group.byte_count }
@@ -87,7 +87,7 @@ module Moab
87
87
 
88
88
  # @attribute
89
89
  # @return [Integer] The total disk usage (in 1 kB blocks) of all data files (estimating du -k result) (dynamically calculated)
90
- attribute :block_count, Integer, :tag => 'blockCount', :on_save => proc { |t| t.to_s }
90
+ attribute :block_count, Integer, tag: 'blockCount', on_save: proc { |t| t.to_s }
91
91
 
92
92
  def block_count
93
93
  groups.inject(0) { |sum, group| sum + group.block_count }
@@ -95,7 +95,7 @@ module Moab
95
95
 
96
96
  # @attribute
97
97
  # @return [Array<FileGroup>] The set of data groups comprising the version
98
- has_many :groups, FileGroup, :tag => 'fileGroup'
98
+ has_many :groups, FileGroup, tag: 'fileGroup'
99
99
 
100
100
  # @return [Array<FileGroup] The set of data groups that contain files
101
101
  def non_empty_groups
@@ -194,7 +194,7 @@ module Moab
194
194
  signatures_from_bag = signatures_from_bagit_manifests(bag_pathname)
195
195
  bag_data_subdirs = bag_pathname.join('data').children
196
196
  bag_data_subdirs.each do |subdir|
197
- groups << FileGroup.new(:group_id => subdir.basename.to_s).group_from_bagit_subdir(subdir, signatures_from_bag)
197
+ groups << FileGroup.new(group_id: subdir.basename.to_s).group_from_bagit_subdir(subdir, signatures_from_bag)
198
198
  end
199
199
  self
200
200
  end
@@ -30,11 +30,11 @@ module Moab
30
30
 
31
31
  # @attribute
32
32
  # @return [String] The digital object ID (druid)
33
- attribute :digital_object_id, String, :tag => 'objectId'
33
+ attribute :digital_object_id, String, tag: 'objectId'
34
34
 
35
35
  # @attribute
36
36
  # @return [Integer] the number of differences found between the two inventories that were compared (dynamically calculated)
37
- attribute :difference_count, Integer, :tag => 'differenceCount', :on_save => proc { |i| i.to_s }
37
+ attribute :difference_count, Integer, tag: 'differenceCount', on_save: proc { |i| i.to_s }
38
38
 
39
39
  def difference_count
40
40
  @group_differences.inject(0) { |sum, group| sum + group.difference_count }
@@ -50,7 +50,7 @@ module Moab
50
50
 
51
51
  # @attribute
52
52
  # @return [String] The datetime at which the report was run
53
- attribute :report_datetime, String, :tag => 'reportDatetime'
53
+ attribute :report_datetime, String, tag: 'reportDatetime'
54
54
 
55
55
  def report_datetime=(datetime)
56
56
  @report_datetime = Moab::UtcTime.input(datetime)
@@ -62,7 +62,7 @@ module Moab
62
62
 
63
63
  # @attribute
64
64
  # @return [Array<FileGroupDifference>] The set of data groups comprising the version
65
- has_many :group_differences, FileGroupDifference, :tag => 'fileGroupDifference'
65
+ has_many :group_differences, FileGroupDifference, tag: 'fileGroupDifference'
66
66
 
67
67
  # @return [Array<String>] The data fields to include in summary reports
68
68
  def summary_fields
@@ -89,8 +89,8 @@ module Moab
89
89
  group_ids = basis_inventory.group_ids | other_inventory.group_ids
90
90
  group_ids.each do |group_id|
91
91
  # get a pair of groups to compare, creating a empty group if not present in the inventory
92
- basis_group = basis_inventory.group(group_id) || FileGroup.new(:group_id => group_id)
93
- other_group = other_inventory.group(group_id) || FileGroup.new(:group_id => group_id)
92
+ basis_group = basis_inventory.group(group_id) || FileGroup.new(group_id: group_id)
93
+ other_group = other_inventory.group(group_id) || FileGroup.new(group_id: group_id)
94
94
  @group_differences << FileGroupDifference.new.compare_file_groups(basis_group, other_group)
95
95
  end
96
96
  self
@@ -30,7 +30,7 @@ module Moab
30
30
 
31
31
  # @attribute
32
32
  # @return [FileSignature] The fixity data of the file instance
33
- element :signature, FileSignature, :tag => 'fileSignature'
33
+ element :signature, FileSignature, tag: 'fileSignature'
34
34
 
35
35
  def signature
36
36
  @signature.is_a?(Array) ? @signature[0] : @signature
@@ -42,7 +42,7 @@ module Moab
42
42
 
43
43
  # @attribute
44
44
  # @return [Array<FileInstance>] The location(s) of the file manifestation's file instances
45
- has_many :instances, FileInstance, :tag => 'fileInstance'
45
+ has_many :instances, FileInstance, tag: 'fileInstance'
46
46
 
47
47
  # @api internal
48
48
  # @return [Array<String>] Create an array from all the file paths of the child {FileInstance} objects
@@ -46,19 +46,19 @@ module Moab
46
46
 
47
47
  # @attribute
48
48
  # @return [Integer] The size of the file in bytes
49
- attribute :size, Integer, :on_save => proc { |n| n.to_s }
49
+ attribute :size, Integer, on_save: proc { |n| n.to_s }
50
50
 
51
51
  # @attribute
52
52
  # @return [String] The MD5 checksum value of the file
53
- attribute :md5, String, :on_save => proc { |n| n.nil? ? "" : n.to_s }
53
+ attribute :md5, String, on_save: proc { |n| n.nil? ? "" : n.to_s }
54
54
 
55
55
  # @attribute
56
56
  # @return [String] The SHA1 checksum value of the file
57
- attribute :sha1, String, :on_save => proc { |n| n.nil? ? "" : n.to_s }
57
+ attribute :sha1, String, on_save: proc { |n| n.nil? ? "" : n.to_s }
58
58
 
59
59
  # @attribute
60
60
  # @return [String] The SHA256 checksum value of the file
61
- attribute :sha256, String, :on_save => proc { |n| n.nil? ? "" : n.to_s }
61
+ attribute :sha256, String, on_save: proc { |n| n.nil? ? "" : n.to_s }
62
62
 
63
63
  KNOWN_ALGOS = {
64
64
  md5: proc { Digest::MD5.new },
@@ -85,7 +85,7 @@ module Moab
85
85
  end
86
86
  end
87
87
 
88
- new(signatures.map { |k, digest| [k, digest.hexdigest] }.to_h.merge(size: pathname.size))
88
+ new(signatures.transform_values(&:hexdigest).merge(size: pathname.size))
89
89
  end
90
90
 
91
91
  # @param type [Symbol,String] The type of checksum
@@ -39,20 +39,20 @@ module Moab
39
39
 
40
40
  # @attribute
41
41
  # @return [String] The object ID (druid)
42
- attribute :digital_object_id, String, :tag => 'objectId'
42
+ attribute :digital_object_id, String, tag: 'objectId'
43
43
 
44
44
  # @attribute
45
45
  # @return [Integer] The ordinal version number
46
- attribute :version_id, Integer, :tag => 'versionId', :key => true, :on_save => proc { |n| n.to_s }
46
+ attribute :version_id, Integer, tag: 'versionId', key: true, on_save: proc { |n| n.to_s }
47
47
 
48
48
  # @return [String] The unique identifier concatenating digital object id with version id
49
49
  def composite_key
50
- @digital_object_id + '-' + StorageObject.version_dirname(@version_id)
50
+ "#{@digital_object_id}-#{StorageObject.version_dirname(@version_id)}"
51
51
  end
52
52
 
53
53
  # @attribute
54
54
  # @return [String] The datetime at which the catalog was updated
55
- attribute :catalog_datetime, Time, :tag => 'catalogDatetime'
55
+ attribute :catalog_datetime, Time, tag: 'catalogDatetime'
56
56
 
57
57
  def catalog_datetime=(datetime)
58
58
  @catalog_datetime = Moab::UtcTime.input(datetime)
@@ -64,7 +64,7 @@ module Moab
64
64
 
65
65
  # @attribute
66
66
  # @return [Integer] The total number of data files (dynamically calculated)
67
- attribute :file_count, Integer, :tag => 'fileCount', :on_save => proc { |t| t.to_s }
67
+ attribute :file_count, Integer, tag: 'fileCount', on_save: proc { |t| t.to_s }
68
68
 
69
69
  def file_count
70
70
  entries.size
@@ -72,7 +72,7 @@ module Moab
72
72
 
73
73
  # @attribute
74
74
  # @return [Integer] The total size (in bytes) of all data files (dynamically calculated)
75
- attribute :byte_count, Integer, :tag => 'byteCount', :on_save => proc { |t| t.to_s }
75
+ attribute :byte_count, Integer, tag: 'byteCount', on_save: proc { |t| t.to_s }
76
76
 
77
77
  def byte_count
78
78
  entries.inject(0) { |sum, entry| sum + entry.signature.size.to_i }
@@ -80,7 +80,7 @@ module Moab
80
80
 
81
81
  # @attribute
82
82
  # @return [Integer] The total disk usage (in 1 kB blocks) of all data files (estimating du -k result) (dynamically calculated)
83
- attribute :block_count, Integer, :tag => 'blockCount', :on_save => proc { |t| t.to_s }
83
+ attribute :block_count, Integer, tag: 'blockCount', on_save: proc { |t| t.to_s }
84
84
 
85
85
  def block_count
86
86
  block_size = 1024
@@ -94,7 +94,7 @@ module Moab
94
94
 
95
95
  # @attribute
96
96
  # @return [Array<SignatureCatalogEntry>] The set of data groups comprising the version
97
- has_many :entries, SignatureCatalogEntry, :tag => 'entry'
97
+ has_many :entries, SignatureCatalogEntry, tag: 'entry'
98
98
 
99
99
  def entries=(entry_array)
100
100
  entry_array.each do |entry|
@@ -178,10 +178,10 @@ module Moab
178
178
  # containing only those files that were added in this version
179
179
  # @example {include:file:spec/features/catalog/version_additions_spec.rb}
180
180
  def version_additions(version_inventory)
181
- version_additions = FileInventory.new(:type => 'additions')
181
+ version_additions = FileInventory.new(type: 'additions')
182
182
  version_additions.copy_ids(version_inventory)
183
183
  version_inventory.groups.each do |group|
184
- group_addtions = FileGroup.new(:group_id => group.group_id)
184
+ group_addtions = FileGroup.new(group_id: group.group_id)
185
185
  group.files.each do |file|
186
186
  group_addtions.add_file_instance(file.signature, file.instances[0]) unless @signature_hash.key?(file.signature)
187
187
  end
@@ -25,19 +25,19 @@ module Moab
25
25
 
26
26
  # @attribute
27
27
  # @return [Integer] The ordinal version number
28
- attribute :version_id, Integer, :tag => 'originalVersion', :key => true, :on_save => proc { |n| n.to_s }
28
+ attribute :version_id, Integer, tag: 'originalVersion', key: true, on_save: proc { |n| n.to_s }
29
29
 
30
30
  # @attribute
31
31
  # @return [String] The name of the file group
32
- attribute :group_id, String, :tag => 'groupId', :key => true
32
+ attribute :group_id, String, tag: 'groupId', key: true
33
33
 
34
34
  # @attribute
35
35
  # @return [String] The id is the filename path, relative to the file group's base directory
36
- attribute :path, String, :key => true, :tag => 'storagePath'
36
+ attribute :path, String, key: true, tag: 'storagePath'
37
37
 
38
38
  # @attribute
39
39
  # @return [FileSignature] The fixity data of the file instance
40
- element :signature, FileSignature, :tag => 'fileSignature'
40
+ element :signature, FileSignature, tag: 'fileSignature'
41
41
 
42
42
  def signature
43
43
  # HappyMapper's parser tries to put an array of signatures in the signature field
@@ -84,10 +84,10 @@ module Moab
84
84
  # @return [FileInventory] The file inventory of the specified type for this version
85
85
  def versionize_bag(bag_dir, current_version, new_version)
86
86
  new_inventory = FileInventory.new(
87
- :type => 'version',
88
- :digital_object_id => @digital_object_id,
89
- :version_id => new_version.version_id,
90
- :inventory_datetime => Time.now
87
+ type: 'version',
88
+ digital_object_id: @digital_object_id,
89
+ version_id: new_version.version_id,
90
+ inventory_datetime: Time.now
91
91
  )
92
92
  new_inventory.inventory_from_bagit_bag(bag_dir)
93
93
  new_inventory.write_xml_file(bag_dir)
@@ -133,7 +133,7 @@ module Moab
133
133
 
134
134
  @object_pathname.children.each do |dirname|
135
135
  vnum = dirname.basename.to_s
136
- list << vnum[1..-1].to_i if vnum =~ /^v(\d+)$/
136
+ list << vnum[1..].to_i if vnum =~ /^v(\d+)$/
137
137
  end
138
138
  list.sort
139
139
  end
@@ -85,13 +85,13 @@ module Moab
85
85
  end
86
86
 
87
87
  def version_dir_format?(dirname)
88
- dirname =~ /^[v]\d{4}$/
88
+ dirname =~ /^v\d{4}$/
89
89
  end
90
90
 
91
91
  # call only if the version directories are "correctly named" vdddd
92
92
  def check_sequential_version_dirs
93
93
  version_directories.each_with_index do |dir_name, index|
94
- next if dir_name[1..-1].to_i == index + 1 # version numbering starts at 1, array indexing at 0
94
+ next if dir_name[1..].to_i == index + 1 # version numbering starts at 1, array indexing at 0
95
95
 
96
96
  return [result_hash(VERSIONS_NOT_IN_ORDER, version_directories)]
97
97
  end
@@ -45,7 +45,7 @@ module Moab
45
45
 
46
46
  # @return [String] The unique identifier concatenating digital object id with version id
47
47
  def composite_key
48
- @storage_object.digital_object_id + '-' + StorageObject.version_dirname(@version_id)
48
+ "#{@storage_object.digital_object_id}-#{StorageObject.version_dirname(@version_id)}"
49
49
  end
50
50
 
51
51
  # @return [Boolean] true if the object version directory exists
@@ -115,12 +115,12 @@ module Moab
115
115
 
116
116
  @inventory_cache[type] = FileInventory.read_xml_file(@version_pathname.join('manifests'), type)
117
117
  else
118
- groups = %w[content metadata].collect { |id| FileGroup.new(:group_id => id) }
118
+ groups = %w[content metadata].collect { |id| FileGroup.new(group_id: id) }
119
119
  FileInventory.new(
120
- :type => 'version',
121
- :digital_object_id => @storage_object.digital_object_id,
122
- :version_id => @version_id,
123
- :groups => groups
120
+ type: 'version',
121
+ digital_object_id: @storage_object.digital_object_id,
122
+ version_id: @version_id,
123
+ groups: groups
124
124
  )
125
125
  end
126
126
  end
@@ -131,7 +131,7 @@ module Moab
131
131
  if version_id > 0
132
132
  SignatureCatalog.read_xml_file(@version_pathname.join('manifests'))
133
133
  else
134
- SignatureCatalog.new(:digital_object_id => @storage_object.digital_object_id)
134
+ SignatureCatalog.new(digital_object_id: @storage_object.digital_object_id)
135
135
  end
136
136
  end
137
137
 
@@ -202,12 +202,12 @@ module Moab
202
202
  # @return [void] examine the version's directory and create/serialize a {FileInventory} containing the manifest files
203
203
  def generate_manifest_inventory
204
204
  manifest_inventory = FileInventory.new(
205
- :type => 'manifests',
206
- :digital_object_id => @storage_object.digital_object_id,
207
- :version_id => @version_id
205
+ type: 'manifests',
206
+ digital_object_id: @storage_object.digital_object_id,
207
+ version_id: @version_id
208
208
  )
209
209
  pathname = @version_pathname.join('manifests')
210
- manifest_inventory.groups << FileGroup.new(:group_id => 'manifests').group_from_directory(pathname, false)
210
+ manifest_inventory.groups << FileGroup.new(group_id: 'manifests').group_from_directory(pathname, false)
211
211
  manifest_inventory.write_xml_file(pathname)
212
212
  end
213
213
 
@@ -312,7 +312,7 @@ module Moab
312
312
  version_additions = file_inventory('additions')
313
313
  result.subentities << VerificationResult.verify_value('composite_key', composite_key, version_additions.composite_key)
314
314
  data_directory = @version_pathname.join('data')
315
- directory_inventory = FileInventory.new(:type => 'directory').inventory_from_directory(data_directory)
315
+ directory_inventory = FileInventory.new(type: 'directory').inventory_from_directory(data_directory)
316
316
  diff = FileInventoryDifference.new
317
317
  diff.compare(version_additions, directory_inventory)
318
318
  compare_result = VerificationResult.new('file_differences')
@@ -160,7 +160,7 @@ module Moab
160
160
  # @param druid [String] The object identifier
161
161
  # @return [void] transfer the object to the preservation repository
162
162
  def store_new_object_version(druid, bag_pathname)
163
- storage_object(druid, create = true).ingest_bag(bag_pathname)
163
+ storage_object(druid, true).ingest_bag(bag_pathname)
164
164
  end
165
165
 
166
166
  private
@@ -110,7 +110,7 @@ module Moab
110
110
  # @return [Pathname] Pathname object containing the full path for the specified file
111
111
  def self.retrieve_file(file_category, file_id, object_id, version_id = nil)
112
112
  storage_object_version = @@repository.storage_object(object_id).find_object_version(version_id)
113
- file_pathname = storage_object_version.find_filepath(file_category, file_id)
113
+ storage_object_version.find_filepath(file_category, file_id)
114
114
  end
115
115
 
116
116
  # @param [String] file_category The category of file ('content', 'metdata', or 'manifest')
@@ -120,7 +120,7 @@ module Moab
120
120
  # @return [Pathname] Pathname object containing the full path for the specified file
121
121
  def self.retrieve_file_using_signature(file_category, file_signature, object_id, version_id = nil)
122
122
  storage_object_version = @@repository.storage_object(object_id).find_object_version(version_id)
123
- file_pathname = storage_object_version.find_filepath_using_signature(file_category, file_signature)
123
+ storage_object_version.find_filepath_using_signature(file_category, file_signature)
124
124
  end
125
125
 
126
126
  # @param [String] file_category The category of file ('content', 'metdata', or 'manifest')
@@ -130,7 +130,7 @@ module Moab
130
130
  # @return [FileSignature] The signature of the file
131
131
  def self.retrieve_file_signature(file_category, file_id, object_id, version_id = nil)
132
132
  storage_object_version = @@repository.storage_object(object_id).find_object_version(version_id)
133
- file_pathname = storage_object_version.find_signature(file_category, file_id)
133
+ storage_object_version.find_signature(file_category, file_id)
134
134
  end
135
135
 
136
136
  # @param [String] object_id The digital object identifier of the object
@@ -25,10 +25,10 @@ module Moab
25
25
 
26
26
  # @attribute
27
27
  # @return [String] The digital object identifier
28
- attribute :digital_object_id, String, :tag => 'objectId'
28
+ attribute :digital_object_id, String, tag: 'objectId'
29
29
 
30
30
  # @attribute
31
31
  # @return [Array<VersionMetadataEntry>] An array of version metadata entries, one per version
32
- has_many :versions, VersionMetadataEntry, :tag => 'version'
32
+ has_many :versions, VersionMetadataEntry, tag: 'version'
33
33
  end
34
34
  end
@@ -24,7 +24,7 @@ module Moab
24
24
 
25
25
  # @attribute
26
26
  # @return [Integer] The object version number (A sequential integer)
27
- 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 }
28
28
 
29
29
  # @attribute
30
30
  # @return [String] "an external version label that increments the most significant digit for major revisions,
@@ -46,14 +46,14 @@ module Moab
46
46
 
47
47
  # @attribute
48
48
  # @return [FileGroupDifference] Summary of content file differences since previous version
49
- element :content_changes, FileGroupDifference, :tag => 'fileGroupDifference'
49
+ element :content_changes, FileGroupDifference, tag: 'fileGroupDifference'
50
50
 
51
51
  # @attribute
52
52
  # @return [FileGroupDifference] Summary of metadata file differences since previous version
53
- element :metadata_changes, FileGroupDifference, :tag => 'fileGroupDifference'
53
+ element :metadata_changes, FileGroupDifference, tag: 'fileGroupDifference'
54
54
 
55
55
  # @attribute
56
56
  # @return [Array<VersionMetadataEvent>] Array of events with timestamps that track lifecycle stages
57
- has_many :events, VersionMetadataEvent, :tag => 'event'
57
+ has_many :events, VersionMetadataEvent, tag: 'event'
58
58
  end
59
59
  end
@@ -22,7 +22,7 @@ module Serializer
22
22
  filename
23
23
  else
24
24
  cname = name.split(/::/).last
25
- cname[0, 1].downcase + cname[1..-1] + '.xml'
25
+ "#{cname[0, 1].downcase}#{cname[1..]}.xml"
26
26
  end
27
27
  end
28
28
 
@@ -59,7 +59,7 @@ module Serializer
59
59
  def self.write_xml_file(xml_object, parent_dir, filename = nil)
60
60
  parent_dir.mkpath
61
61
  xml_pathname(parent_dir, filename).open('w') do |f|
62
- xmlBuilder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8')
62
+ xmlBuilder = Nokogiri::XML::Builder.new(encoding: 'UTF-8')
63
63
  xmlBuilder = xml_object.to_xml(xmlBuilder)
64
64
  f << xmlBuilder.to_xml
65
65
  end
@@ -113,7 +113,7 @@ module Serializer
113
113
 
114
114
  # @return [Hash] Calls to_hash(summary=true)
115
115
  def summary
116
- to_hash(summary = true)
116
+ to_hash(true)
117
117
  end
118
118
 
119
119
  # @api internal
@@ -23,7 +23,7 @@ module Stanford
23
23
  # Many of these objects have contentMetadata with no child elements, such as this:
24
24
  # <contentMetadata objectId="bd608mj3166" type="file"/>
25
25
  # but there are also objects that have no datasteam of this name at all
26
- 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)
27
27
  content_group = group_from_cm(content_metadata, subset)
28
28
  cm_inventory.groups << content_group
29
29
  cm_inventory
@@ -49,7 +49,7 @@ module Stanford
49
49
  else
50
50
  raise(Moab::MoabRuntimeError, "Unknown disposition subset (#{subset})")
51
51
  end
52
- 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}")
53
53
  nodeset.each do |file_node|
54
54
  signature = generate_signature(file_node)
55
55
  instance = generate_instance(file_node)
@@ -85,10 +85,10 @@ module Stanford
85
85
  instance = Moab::FileInstance.new
86
86
  instance.path = node.attributes['id'].content
87
87
  instance.datetime = begin
88
- node.attributes['datetime'].content
89
- rescue
90
- nil
91
- end
88
+ node.attributes['datetime'].content
89
+ rescue
90
+ nil
91
+ end
92
92
  instance
93
93
  end
94
94
 
@@ -98,23 +98,23 @@ module Stanford
98
98
  # @example {include:file:spec/features/stanford/content_metadata_write_spec.rb}
99
99
  def generate_content_metadata(file_group, object_id, version_id)
100
100
  cm = Nokogiri::XML::Builder.new do |xml|
101
- xml.contentMetadata(:type => "sample", :objectId => object_id) do
102
- 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
103
103
  file_group.files.each do |file_manifestation|
104
104
  signature = file_manifestation.signature
105
105
  file_manifestation.instances.each do |instance|
106
106
  xml.file(
107
- :id => instance.path,
108
- :size => signature.size,
109
- :datetime => instance.datetime,
110
- :shelve => 'yes',
111
- :publish => 'yes',
112
- :preserve => 'yes'
107
+ id: instance.path,
108
+ size: signature.size,
109
+ datetime: instance.datetime,
110
+ shelve: 'yes',
111
+ publish: 'yes',
112
+ preserve: 'yes'
113
113
  ) do
114
114
  fixity = signature.fixity
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]
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]
118
118
  end
119
119
  end
120
120
  end
@@ -128,7 +128,7 @@ module Stanford
128
128
  # @return [Boolean] True if contentMetadata has essential file attributes, else raise exception
129
129
  def validate_content_metadata(content_metadata)
130
130
  result = validate_content_metadata_details(content_metadata)
131
- raise Moab::InvalidMetadataException, result[0] + " ..." unless result.empty?
131
+ raise Moab::InvalidMetadataException, "#{result[0]} ..." unless result.empty?
132
132
 
133
133
  true
134
134
  end
@@ -191,7 +191,7 @@ module Stanford
191
191
  remediate_file_size(file_node, signature)
192
192
  remediate_checksum_nodes(file_node, signature)
193
193
  end
194
- ng_doc.to_xml(:indent => 2)
194
+ ng_doc.to_xml(indent: 2)
195
195
  end
196
196
 
197
197
  # @param [Nokogiri::XML::Element] file_node the File stanza being remediated
@@ -31,11 +31,12 @@ module Stanford
31
31
  # @return [FileInventory] Inventory of the files under the specified directory
32
32
  def inventory_from_directory(directory, version_id = nil)
33
33
  version_id ||= @version_id
34
- version_inventory = Moab::FileInventory.new(type: 'version', digital_object_id: @digital_object_id, version_id: version_id)
34
+ version_inventory = Moab::FileInventory.new(type: 'version', digital_object_id: @digital_object_id,
35
+ version_id: version_id)
35
36
  content_metadata = IO.read(File.join(directory, 'contentMetadata.xml'))
36
37
  content_group = Stanford::ContentInventory.new.group_from_cm(content_metadata, 'preserve')
37
38
  version_inventory.groups << content_group
38
- metadata_group = Moab::FileGroup.new(:group_id => 'metadata').group_from_directory(directory)
39
+ metadata_group = Moab::FileGroup.new(group_id: 'metadata').group_from_directory(directory)
39
40
  version_inventory.groups << metadata_group
40
41
  version_inventory
41
42
  end
@@ -31,9 +31,9 @@ module Stanford
31
31
  # @param object_id [String] The identifier of the digital object whose path is requested
32
32
  # @return [String] the druid tree directory path based on the given object identifier.
33
33
  def druid_tree(object_id)
34
- # 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
35
35
  syntax_msg = "Identifier has invalid suri syntax: #{object_id}"
36
- 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
37
 
38
38
  identifier = object_id.split(':')[-1]
39
39
  raise(Moab::InvalidSuriSyntaxError, syntax_msg) if identifier.to_s.empty?
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moab-versioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.1
4
+ version: 4.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Weber
8
8
  - Richard Anderson
9
9
  - Lynn McRae
10
10
  - Hannah Frost
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-04-22 00:00:00.000000000 Z
14
+ date: 2021-06-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: druid-tools
@@ -145,28 +145,28 @@ dependencies:
145
145
  requirements:
146
146
  - - "~>"
147
147
  - !ruby/object:Gem::Version
148
- version: 0.79.0
148
+ version: '1.7'
149
149
  type: :development
150
150
  prerelease: false
151
151
  version_requirements: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - "~>"
154
154
  - !ruby/object:Gem::Version
155
- version: 0.79.0
155
+ version: '1.7'
156
156
  - !ruby/object:Gem::Dependency
157
157
  name: rubocop-rspec
158
158
  requirement: !ruby/object:Gem::Requirement
159
159
  requirements:
160
160
  - - "~>"
161
161
  - !ruby/object:Gem::Version
162
- version: 1.37.1
162
+ version: '2.1'
163
163
  type: :development
164
164
  prerelease: false
165
165
  version_requirements: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - "~>"
168
168
  - !ruby/object:Gem::Version
169
- version: 1.37.1
169
+ version: '2.1'
170
170
  description: Contains classes to process digital object version content and metadata
171
171
  email:
172
172
  - darren.weber@stanford.edu
@@ -215,23 +215,23 @@ homepage: https://github.com/sul-dlss/moab-versioning
215
215
  licenses:
216
216
  - Apache-2.0
217
217
  metadata: {}
218
- post_install_message:
218
+ post_install_message:
219
219
  rdoc_options: []
220
220
  require_paths:
221
221
  - lib
222
222
  required_ruby_version: !ruby/object:Gem::Requirement
223
223
  requirements:
224
- - - "~>"
224
+ - - ">="
225
225
  - !ruby/object:Gem::Version
226
- version: '2.3'
226
+ version: '2.6'
227
227
  required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  requirements:
229
229
  - - ">="
230
230
  - !ruby/object:Gem::Version
231
231
  version: '0'
232
232
  requirements: []
233
- rubygems_version: 3.0.3
234
- signing_key:
233
+ rubygems_version: 3.1.4
234
+ signing_key:
235
235
  specification_version: 4
236
236
  summary: Ruby implementation of digital object versioning toolkit used by the SULAIR
237
237
  Digital Library