moab-versioning 6.1.0 → 6.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ac9a723ffc977aa08ff80ac3222a5edac9007f34516b269e53323119a129646
4
- data.tar.gz: df5e62f7a0c6b1a328676063f08da78977465505bcafa933273f4964dab7f239
3
+ metadata.gz: 7ee90f0940591133476bcd8eb26fd6d210dac5927c1ade040b94056a0a271521
4
+ data.tar.gz: f105d5e796fb41f0ab8c38afc70c983b30ac5840868285731af13ca0e844934a
5
5
  SHA512:
6
- metadata.gz: 188bdd57026ac1bcdc431ce8266927414dcb4b3539ddc8b0f733240adb888bbd564f3469d6346c8948af5fcf072fb3ebde5a0cc894d65539acddfe104522e43b
7
- data.tar.gz: c00a2aa7923f9138b34afd7d2a212dc0c9a9cd4b70a953217771fe46c4cbb2f6013d9ba4632e121a95c6238c1242fedfeba2ba8a4883775afab2558e86ad3fdd
6
+ metadata.gz: 18e970e6f03a4ef17112ba603579f8dc4eae8e4a53dc952cd6ef55f5ab66670d21a58b6df94c3827a1e0660b4786802ffc0a7f7db094f6fc13196f5b64624df0
7
+ data.tar.gz: 6ee40f28548c85fa09d5a702ce2e50fb869eb81e40901830b3738ba30af7d7cb1759ca8cef58e082704f84fd106479f2eb1fd176c327e8ff0efcd3bb8e7ad6f6
data/lib/moab/bagger.rb CHANGED
@@ -67,14 +67,7 @@ module Moab
67
67
  # @return [NilClass] Delete the bagit files
68
68
  def delete_bag
69
69
  # make sure this looks like a bag before deleting
70
- if bag_pathname.join('bagit.txt').exist?
71
- if bag_pathname.join('data').exist?
72
- bag_pathname.rmtree
73
- else
74
- bag_pathname.children.each(&:delete)
75
- bag_pathname.rmdir
76
- end
77
- end
70
+ bag_pathname.rmtree if bag_pathname.join('bagit.txt').exist?
78
71
  nil
79
72
  end
80
73
 
@@ -234,12 +227,12 @@ module Moab
234
227
  manifest_file[type] = manifest_pathname[type].open('w')
235
228
  end
236
229
  bag_pathname.children.each do |file|
237
- unless file.directory? || file.basename.to_s[0, 11] == 'tagmanifest'
238
- signature = FileSignature.new.signature_from_file(file)
239
- fixity = signature.fixity
240
- DEFAULT_CHECKSUM_TYPES.each do |type|
241
- manifest_file[type].puts("#{fixity[type]} #{file.basename}") if fixity[type]
242
- end
230
+ next unless include_in_tagfile_manifests?(file)
231
+
232
+ signature = FileSignature.new.signature_from_file(file)
233
+ fixity = signature.fixity
234
+ DEFAULT_CHECKSUM_TYPES.each do |type|
235
+ manifest_file[type].puts("#{fixity[type]} #{file.basename}") if fixity[type]
243
236
  end
244
237
  end
245
238
  ensure
@@ -252,6 +245,13 @@ module Moab
252
245
  end
253
246
  end
254
247
 
248
+ def include_in_tagfile_manifests?(file)
249
+ basename = file.basename.to_s
250
+ return false if file.directory? || basename.start_with?('tagmanifest') || basename.match?(/\A\.nfs\w+\z/)
251
+
252
+ true
253
+ end
254
+
255
255
  # @return [Boolean] Create a tar file containing the bag
256
256
  def create_tarfile(tar_pathname = nil)
257
257
  bag_name = bag_pathname.basename
data/lib/moab/config.rb CHANGED
@@ -8,8 +8,8 @@ module Moab
8
8
  @checksum_algos = [:md5, :sha1, :sha256]
9
9
  end
10
10
 
11
- def configure(&block)
12
- instance_eval(&block)
11
+ def configure(...)
12
+ instance_eval(...)
13
13
  end
14
14
 
15
15
  def storage_roots(new_value = nil)
@@ -38,7 +38,7 @@ module Moab
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(&: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(&: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(&:to_s)
58
58
 
59
59
  def block_count
60
60
  files.inject(0) { |sum, manifestation| sum + manifestation.block_count }
@@ -64,7 +64,7 @@ module Moab
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(&: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(&: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(&: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(&: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(&: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(&: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(&: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(&:to_s)
122
122
  def deleted
123
123
  subset_hash[:deleted].count
124
124
  end
@@ -256,7 +256,7 @@ module Moab
256
256
  basis_only_paths = basis_paths - other_paths
257
257
  other_only_paths = other_paths - basis_paths
258
258
  maxsize = [basis_only_paths.size, other_only_paths.size].max
259
- (0..maxsize - 1).each do |n|
259
+ (0..maxsize - 1).each do |n| # rubocop:disable Lint/AmbiguousRange
260
260
  fid = FileInstanceDifference.new
261
261
  fid.basis_path = basis_only_paths[n]
262
262
  fid.other_path = other_only_paths[n]
@@ -364,7 +364,7 @@ module Moab
364
364
  end
365
365
  # Are any of the filenames the same in set of oldnames and set of newnames?
366
366
  intersection = oldnames & newnames
367
- intersection.count > 0
367
+ intersection.any?
368
368
  end
369
369
 
370
370
  # @param [Array<Array<String>>] filepairs The set of oldname, newname pairs for all files being renamed
@@ -30,7 +30,7 @@ module Moab
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(&:to_s)
34
34
 
35
35
  def count
36
36
  files.size
@@ -38,11 +38,11 @@ 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(&: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(&: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)
@@ -50,7 +50,7 @@ module Moab
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(&:to_s)
54
54
 
55
55
  # @return [String] The unique identifier concatenating digital object id with version id
56
56
  def composite_key
@@ -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(&: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(&: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(&:to_s)
91
91
 
92
92
  def block_count
93
93
  groups.inject(0) { |sum, group| sum + group.block_count }
@@ -161,7 +161,7 @@ module Moab
161
161
  # @return [String] Returns either the version ID (if inventory is a version manifest) or the name of the directory
162
162
  # that was harvested to create the inventory
163
163
  def data_source
164
- data_source = (groups.collect { |g| g.data_source.to_s }).join('|')
164
+ data_source = groups.collect { |g| g.data_source.to_s }.join('|')
165
165
  if data_source.start_with?('contentMetadata')
166
166
  version_id ? "v#{version_id}-#{data_source}" : "new-#{data_source}"
167
167
  else
@@ -34,7 +34,7 @@ module Moab
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(&:to_s)
38
38
 
39
39
  def difference_count
40
40
  @group_differences.inject(0) { |sum, group| sum + group.difference_count }
@@ -46,19 +46,19 @@ module Moab
46
46
 
47
47
  # @attribute
48
48
  # @return [String] The size of the file in bytes (can be empty)
49
- attribute :size, Integer, on_save: proc { |n| n.to_s }
49
+ attribute :size, Integer, on_save: proc(&:to_s)
50
50
 
51
51
  # @attribute
52
52
  # @return [String] The MD5 checksum value of the file (can be empty)
53
- attribute :md5, String, on_save: proc { |n| n.to_s }
53
+ attribute :md5, String, on_save: proc(&:to_s)
54
54
 
55
55
  # @attribute
56
56
  # @return [String] The SHA1 checksum value of the file (can be empty)
57
- attribute :sha1, String, on_save: proc { |n| n.to_s }
57
+ attribute :sha1, String, on_save: proc(&:to_s)
58
58
 
59
59
  # @attribute
60
60
  # @return [String] The SHA256 checksum value of the file (can be empty)
61
- attribute :sha256, String, on_save: proc { |n| n.to_s }
61
+ attribute :sha256, String, on_save: proc(&:to_s)
62
62
 
63
63
  KNOWN_ALGOS = {
64
64
  md5: proc { Digest::MD5.new },
@@ -43,7 +43,7 @@ module Moab
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(&:to_s)
47
47
 
48
48
  # @return [String] The unique identifier concatenating digital object id with version id
49
49
  def composite_key
@@ -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(&: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(&: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(&:to_s)
84
84
 
85
85
  def block_count
86
86
  block_size = 1024
@@ -25,7 +25,7 @@ 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(&:to_s)
29
29
 
30
30
  # @attribute
31
31
  # @return [String] The name of the file group
@@ -75,7 +75,7 @@ module Moab
75
75
 
76
76
  def check_correctly_named_version_dirs
77
77
  errors = []
78
- errors << result_hash(MISSING_DIR, 'no versions exist') unless version_directories.count > 0
78
+ errors << result_hash(MISSING_DIR, 'no versions exist') unless version_directories.any?
79
79
  version_directories.each do |version_dir|
80
80
  errors << result_hash(VERSION_DIR_BAD_FORMAT, version_dir) unless VERSION_DIR_PATTERN.match?(version_dir)
81
81
  end
@@ -31,7 +31,7 @@ module Moab
31
31
  # @return [VerificationResult] The result of comparing the expected and found values
32
32
  def self.verify_value(entity, expected, found)
33
33
  details = { 'expected' => expected, 'found' => found }
34
- new(entity, (expected == found), details)
34
+ new(entity, (expected == found), details) # rubocop:disable Style/RedundantParentheses
35
35
  end
36
36
 
37
37
  # @deprecated Just use the constructor
@@ -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(&:to_s)
28
28
 
29
29
  # @attribute
30
30
  # @return [String] "an external version label that increments the most significant digit for major revisions,
@@ -19,6 +19,10 @@ module Stanford
19
19
  @@repository
20
20
  end
21
21
 
22
+ # NOTE: `ShelvingService.content_diff` in dor-services-app implements similar logic, but in a way that
23
+ # uses XML retrieved via preservation-client instead of reading the XML from disk. This allows DSA to
24
+ # perform the potentially time expensive diff without requiring access to preservation disk mounts.
25
+ # See https://github.com/sul-dlss/dor-services-app/pull/4492 and https://github.com/sul-dlss/dor-services-app/issues/4359
22
26
  # @param new_content_metadata [String] The content metadata to be compared to the base
23
27
  # @param object_id [String] The digital object identifier of the object whose version inventory is the basis of the
24
28
  # comparison
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: 6.1.0
4
+ version: 6.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
@@ -9,10 +9,9 @@ authors:
9
9
  - Tony Zanella
10
10
  - Mike Giarlo
11
11
  - John Martin
12
- autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2023-02-03 00:00:00.000000000 Z
14
+ date: 2025-09-24 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: druid-tools
@@ -84,20 +83,6 @@ dependencies:
84
83
  - - ">="
85
84
  - !ruby/object:Gem::Version
86
85
  version: '0'
87
- - !ruby/object:Gem::Dependency
88
- name: pry-byebug
89
- requirement: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- type: :development
95
- prerelease: false
96
- version_requirements: !ruby/object:Gem::Requirement
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: '0'
101
86
  - !ruby/object:Gem::Dependency
102
87
  name: rake
103
88
  requirement: !ruby/object:Gem::Requirement
@@ -144,16 +129,16 @@ dependencies:
144
129
  name: rubocop-rspec
145
130
  requirement: !ruby/object:Gem::Requirement
146
131
  requirements:
147
- - - "~>"
132
+ - - ">="
148
133
  - !ruby/object:Gem::Version
149
- version: '2.1'
134
+ version: '0'
150
135
  type: :development
151
136
  prerelease: false
152
137
  version_requirements: !ruby/object:Gem::Requirement
153
138
  requirements:
154
- - - "~>"
139
+ - - ">="
155
140
  - !ruby/object:Gem::Version
156
- version: '2.1'
141
+ version: '0'
157
142
  - !ruby/object:Gem::Dependency
158
143
  name: simplecov
159
144
  requirement: !ruby/object:Gem::Requirement
@@ -215,7 +200,6 @@ licenses:
215
200
  - Apache-2.0
216
201
  metadata:
217
202
  rubygems_mfa_required: 'true'
218
- post_install_message:
219
203
  rdoc_options: []
220
204
  require_paths:
221
205
  - lib
@@ -230,8 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
214
  - !ruby/object:Gem::Version
231
215
  version: '0'
232
216
  requirements: []
233
- rubygems_version: 3.3.7
234
- signing_key:
217
+ rubygems_version: 3.6.2
235
218
  specification_version: 4
236
219
  summary: Ruby implementation of digital object versioning toolkit used by Stanford
237
220
  University Libraries