moab-versioning 5.0.0.beta1 → 5.2.0

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: 1d109f89af3228b70fe8e8b8cf394830b9397f4815a8c2324bb7e09e849432d6
4
- data.tar.gz: 9695c1dfb048663ff1b56084597b8ece2973966704a07d610dd7e537da8be61b
3
+ metadata.gz: c20a012b9d9c481ddfeed15296e61aaf6648bed0cd1d0065a8b0662301e94a1b
4
+ data.tar.gz: 8d5a96d608b7334f117b5ee9faa3cbe16f82f543bd3af0d23d11371df2181d76
5
5
  SHA512:
6
- metadata.gz: 85be7b541e0056fd50296092448b01c4d83195529c00bd4aaa244cce6596336b0ae7b41ba855f54b618666bf265a9986844eaf6a0f7a78eb811b6ccdaf1329ae
7
- data.tar.gz: 72dc3ada7f22d891e883ce08fe55c7c783689f73b8868e6c29bb5040c2bcc45197c044a3b5823a94f3e8ade7de6b16ccc291902ee142ab0e68036824623c6695
6
+ metadata.gz: 296fd7985772e8296f879e955066f7e3c71b00a6a83d9893aa124de5d900a427ca61d57b221f4227ae54210f3518111a5d99ae60db62ed9dbb25818871f8e87d
7
+ data.tar.gz: 701adc9ee529e10fd608ed890f8f8a3f978cb3ec023f58d8a75bd11a0caa6e27f4631ec4f73c9280cf8de914da855d100be3cd077f029ec91fab4b07749c627c
@@ -100,10 +100,10 @@ module Moab
100
100
  # @param (see #compare)
101
101
  # @return [String] Returns either the common digitial object ID, or a concatenation of both inventory's IDs
102
102
  def common_object_id(basis_inventory, other_inventory)
103
- if basis_inventory.digital_object_id != other_inventory.digital_object_id
104
- "#{basis_inventory.digital_object_id}|#{other_inventory.digital_object_id}"
105
- else
103
+ if basis_inventory.digital_object_id == other_inventory.digital_object_id
106
104
  basis_inventory.digital_object_id.to_s
105
+ else
106
+ "#{basis_inventory.digital_object_id}|#{other_inventory.digital_object_id}"
107
107
  end
108
108
  end
109
109
 
@@ -77,7 +77,7 @@ module Moab
77
77
  def self.from_file(pathname, algos_to_use = active_algos)
78
78
  raise(MoabRuntimeError, 'Unrecognized algorithm requested') unless algos_to_use.all? { |a| KNOWN_ALGOS.include?(a) }
79
79
 
80
- signatures = algos_to_use.map { |k| [k, KNOWN_ALGOS[k].call] }.to_h
80
+ signatures = algos_to_use.to_h { |k| [k, KNOWN_ALGOS[k].call] }
81
81
 
82
82
  pathname.open("r") do |stream|
83
83
  while (buffer = stream.read(8192))
@@ -84,7 +84,7 @@ module Moab
84
84
 
85
85
  def block_count
86
86
  block_size = 1024
87
- entries.inject(0) { |sum, entry| sum + (entry.signature.size.to_i + block_size - 1) / block_size }
87
+ entries.inject(0) { |sum, entry| sum + ((entry.signature.size.to_i + block_size - 1) / block_size) }
88
88
  end
89
89
 
90
90
  # @return [Array<String>] The data fields to include in summary reports
@@ -57,9 +57,10 @@ module Moab
57
57
 
58
58
  # @api external
59
59
  # @param bag_dir [Pathname,String] The location of the bag to be ingested
60
+ # @param use_links [Boolean] If true, use hard links; if false, make copies
60
61
  # @return [void] Ingest a new object version contained in a bag into this objects storage area
61
62
  # @example {include:file:spec/features/storage/ingest_spec.rb}
62
- def ingest_bag(bag_dir = deposit_bag_pathname)
63
+ def ingest_bag(bag_dir = deposit_bag_pathname, use_links: true)
63
64
  bag_dir = Pathname(bag_dir)
64
65
  current_version = StorageObjectVersion.new(self, current_version_id)
65
66
  current_inventory = current_version.file_inventory('version')
@@ -70,7 +71,7 @@ module Moab
70
71
  new_inventory = versionize_bag(bag_dir, current_version, new_version)
71
72
  end
72
73
  validate_new_inventory(new_inventory)
73
- new_version.ingest_bag_data(bag_dir)
74
+ new_version.ingest_bag_data(bag_dir, use_links: use_links)
74
75
  new_version.update_catalog(current_version.signature_catalog, new_inventory)
75
76
  new_version.generate_differences_report(current_inventory, new_inventory)
76
77
  new_version.generate_manifest_inventory
@@ -128,24 +128,25 @@ module Moab
128
128
  # @api external
129
129
  # @return [SignatureCatalog] The signature catalog of the digital object as of this version
130
130
  def signature_catalog
131
- if version_id > 0
132
- SignatureCatalog.read_xml_file(@version_pathname.join('manifests'))
133
- else
134
- SignatureCatalog.new(digital_object_id: @storage_object.digital_object_id)
135
- end
131
+ @signature_catalog ||= if version_id > 0
132
+ SignatureCatalog.read_xml_file(@version_pathname.join('manifests'))
133
+ else
134
+ SignatureCatalog.new(digital_object_id: @storage_object.digital_object_id)
135
+ end
136
136
  end
137
137
 
138
138
  # @api internal
139
139
  # @param bag_dir [Pathname,String] The location of the bag to be ingested
140
+ # @param use_links [Boolean] If true, use hard links; if false, make copies
140
141
  # @return [void] Create the version subdirectory and move files into it
141
- def ingest_bag_data(bag_dir)
142
+ def ingest_bag_data(bag_dir, use_links: true)
142
143
  raise(MoabRuntimeError, "Version already exists: #{@version_pathname}") if @version_pathname.exist?
143
144
 
144
145
  @version_pathname.join('manifests').mkpath
145
146
  bag_dir = Pathname(bag_dir)
146
- ingest_dir(bag_dir.join('data'), @version_pathname.join('data'))
147
- ingest_file(bag_dir.join(FileInventory.xml_filename('version')), @version_pathname.join('manifests'))
148
- ingest_file(bag_dir.join(FileInventory.xml_filename('additions')), @version_pathname.join('manifests'))
147
+ ingest_dir(bag_dir.join('data'), @version_pathname.join('data'), use_links)
148
+ ingest_file(bag_dir.join(FileInventory.xml_filename('version')), @version_pathname.join('manifests'), use_links)
149
+ ingest_file(bag_dir.join(FileInventory.xml_filename('additions')), @version_pathname.join('manifests'), use_links)
149
150
  end
150
151
 
151
152
  # @api internal
@@ -286,10 +287,10 @@ module Moab
286
287
  file.instances.each do |instance|
287
288
  relative_path = File.join(group.group_id, instance.path)
288
289
  catalog_entry = signature_catalog.signature_hash[file.signature]
289
- if !catalog_entry.nil?
290
- found += 1
291
- else
290
+ if catalog_entry.nil?
292
291
  missing << relative_path.to_s
292
+ else
293
+ found += 1
293
294
  end
294
295
  end
295
296
  end
data/lib/moab/utc_time.rb CHANGED
@@ -7,9 +7,7 @@ module Moab
7
7
  # @return [void] Convert input datetime to a Time object, or nil if input is empty.
8
8
  def self.input(datetime)
9
9
  case datetime
10
- when nil
11
- nil
12
- when ""
10
+ when nil, ""
13
11
  nil
14
12
  when String
15
13
  Time.parse(datetime)
@@ -66,7 +66,7 @@ module Moab
66
66
  # @param level [Integer] Used to increment the depth of recursion
67
67
  # @return [Hash] The verification result of subentities serialized to a hash
68
68
  def subentities_to_hash(verbose, level)
69
- subentities.map { |s| [s.entity, s.to_hash(verbose, level + 1)] }.to_h
69
+ subentities.to_h { |s| [s.entity, s.to_hash(verbose, level + 1)] }
70
70
  end
71
71
  end
72
72
  end
@@ -157,7 +157,7 @@ module Serializer
157
157
  diff[k] = if left[k].is_a?(Hash) && right[k].is_a?(Hash)
158
158
  deep_diff(ltag, left[k], rtag, right[k])
159
159
  else
160
- Hash.[](ltag, left[k], rtag, right[k])
160
+ { ltag => left[k], rtag => right[k] }
161
161
  end
162
162
  end
163
163
  end
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: 5.0.0.beta1
4
+ version: 5.2.0
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: 2021-10-19 00:00:00.000000000 Z
14
+ date: 2022-08-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: druid-tools
@@ -69,20 +69,6 @@ dependencies:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
- - !ruby/object:Gem::Dependency
73
- name: coveralls
74
- requirement: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: '0'
79
- type: :development
80
- prerelease: false
81
- version_requirements: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
72
  - !ruby/object:Gem::Dependency
87
73
  name: equivalent-xml
88
74
  requirement: !ruby/object:Gem::Requirement
@@ -167,6 +153,20 @@ dependencies:
167
153
  - - "~>"
168
154
  - !ruby/object:Gem::Version
169
155
  version: '2.1'
156
+ - !ruby/object:Gem::Dependency
157
+ name: simplecov
158
+ requirement: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ type: :development
164
+ prerelease: false
165
+ version_requirements: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
170
  description: Contains classes to process digital object version content and metadata
171
171
  email:
172
172
  - darren.weber@stanford.edu
@@ -208,8 +208,9 @@ files:
208
208
  homepage: https://github.com/sul-dlss/moab-versioning
209
209
  licenses:
210
210
  - Apache-2.0
211
- metadata: {}
212
- post_install_message:
211
+ metadata:
212
+ rubygems_mfa_required: 'true'
213
+ post_install_message:
213
214
  rdoc_options: []
214
215
  require_paths:
215
216
  - lib
@@ -217,15 +218,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
218
  requirements:
218
219
  - - ">="
219
220
  - !ruby/object:Gem::Version
220
- version: '2.6'
221
+ version: '2.7'
221
222
  required_rubygems_version: !ruby/object:Gem::Requirement
222
223
  requirements:
223
- - - ">"
224
+ - - ">="
224
225
  - !ruby/object:Gem::Version
225
- version: 1.3.1
226
+ version: '0'
226
227
  requirements: []
227
- rubygems_version: 3.1.4
228
- signing_key:
228
+ rubygems_version: 3.3.7
229
+ signing_key:
229
230
  specification_version: 4
230
231
  summary: Ruby implementation of digital object versioning toolkit used by the SULAIR
231
232
  Digital Library