libis-tools 1.0.15 → 1.0.17

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: f007ed770338a6d5f537e3388cc72409e4e35deab2c337f8f4a80a76db200371
4
- data.tar.gz: c57cd7d2cb65c0cf6cc03a2e7973ee2d24e279f5e975da5580b4569f50c833b3
3
+ metadata.gz: '01219a5f1fbace5f69a992675d9e67a049c1924cf7b9d9f24db18be8fdf4dc60'
4
+ data.tar.gz: 0b1ded7e545eeec542e739bfbf20a2c680a6a3a05561d95087f172932312a53a
5
5
  SHA512:
6
- metadata.gz: a4a87f3ffdb3319e748fa9d60f47971f250fb2ff841ea63f0c7795afbacbee452943958b366b1462f866a406f07a39b5556258778b7913db236e8889a2f2a7ea
7
- data.tar.gz: 1058f448308c579de12b41183d185846278ec9c798cf97cece7f5a324039fcd7886f12960a8023e833eadac073f33245d0fbb3e022d00267f5eaa7f633f34c5d
6
+ metadata.gz: e6e997f4405fef929aef639c6807b8b3de168777c487efb7f91ffc31eb1f588d03cf9d4210485314b44ccd074a5f7aa5ad02a1fe5e0c245a6a8524955a643e36
7
+ data.tar.gz: cc69c4dadac622c704539fb1c3357eed4c6fe6784b1870a6a4b46edc927c635c528812e9817f7769b6497ad9eba06d8faa86fce56f166d0ba3ce6cdc92a4dab8
@@ -88,4 +88,16 @@ module Roo
88
88
  end
89
89
 
90
90
  end
91
+
92
+ class CSV
93
+ def each_row(options, &block)
94
+ if uri?(filename)
95
+ each_row_using_tempdir(options, &block)
96
+ elsif is_stream?(filename_or_stream)
97
+ ::CSV.new(filename_or_stream, **options).each(&block)
98
+ else
99
+ ::CSV.foreach(filename, **options, &block)
100
+ end
101
+ end
102
+ end
91
103
  end
@@ -31,7 +31,9 @@ module Libis
31
31
  # Specialized DNX section.
32
32
  class WebHarvesting < DnxSection; end
33
33
  # Specialized DNX section.
34
- class Collection < DnxSection; end
34
+ class Collection < DnxSection
35
+ def tag; 'Collection'; end
36
+ end
35
37
  # Specialized DNX section.
36
38
  class PreservationLevel < DnxSection; end
37
39
  # Specialized DNX section.
@@ -44,188 +44,6 @@ module Libis
44
44
 
45
45
  end
46
46
 
47
- # Container class for creating a representation in the METS.
48
- class Representation
49
- include MetsObject
50
-
51
- # The currently allowed attributes on this class. The attributes will typically be used in {DnxSection}s.
52
- attr_accessor :label, :preservation_type, :usage_type, :representation_code, :entity_type, :access_right_id,
53
- :user_a, :user_b, :user_c,
54
- :group_id, :priority, :order,
55
- :digital_original, :content, :context, :hardware, :carrier, :original_name,
56
- :preservation_levels, :env_dependencies, :hardware_ids, :software_ids,
57
- :hardware_infos, :software_infos, :relationship_infos, :environments,
58
- :dc_record, :source_metadata
59
-
60
- # The id that will be used in the XML file to reference this representation.
61
- def xml_id
62
- "rep#{@id}"
63
- end
64
-
65
- # This method creates the appropriate {DnxSection}s based on what attributes are filled in.
66
- def amd
67
- dnx = {}
68
- tech_data = []
69
- # General characteristics
70
- data = {
71
- preservationType: preservation_type,
72
- usageType: usage_type,
73
- DigitalOriginal: digital_original,
74
- label: label,
75
- representationEntityType: entity_type,
76
- contentType: content,
77
- contextType: context,
78
- hardwareUsed: hardware,
79
- physicalCarrierMedia: carrier,
80
- deliveryPriority: priority,
81
- orderingSequence: order,
82
- RepresentationCode: representation_code,
83
- RepresentationOriginalName: original_name,
84
- UserDefinedA: user_a,
85
- UserDefinedB: user_b,
86
- UserDefinedC: user_c,
87
- }.cleanup
88
- tech_data << GeneralRepCharacteristics.new(data) unless data.empty?
89
- # Object characteristics
90
- data = {
91
- groupID: group_id
92
- }.cleanup
93
- tech_data << ObjectCharacteristics.new(data) unless data.empty?
94
- # Preservation level
95
- if preservation_levels
96
- data_list = []
97
- preservation_levels.each do |preservation_level|
98
- data = {
99
- preservationLevelValue: preservation_level[:value],
100
- preservationLevelRole: preservation_level[:role],
101
- preservationLevelRationale: preservation_level[:rationale],
102
- preservationLevelDateAssigned: preservation_level[:date],
103
- }.cleanup
104
- data_list << OpenStruct.new(data) unless data.empty?
105
- end
106
- tech_data << PreservationLevel.new(array: data_list) unless data_list.empty?
107
- end
108
- # Dependencies
109
- if env_dependencies
110
- data_list = []
111
- env_dependencies.each do |dependency|
112
- data = {
113
- dependencyName: dependency[:name],
114
- dependencyIdentifierType1: dependency[:type1],
115
- dependencyIdentifierValue1: dependency[:value1],
116
- dependencyIdentifierType2: dependency[:type2],
117
- dependencyIdentifierValue2: dependency[:value2],
118
- dependencyIdentifierType3: dependency[:type3],
119
- dependencyIdentifierValue3: dependency[:value3],
120
- }.cleanup
121
- data_list << OpenStruct.new(data) unless data.empty?
122
- end
123
- tech_data << EnvironmentDependencies.new(array: data_list) unless data_list.empty?
124
- end
125
- # Hardware registry id
126
- if hardware_ids
127
- data_list = []
128
- hardware_ids.each do |id|
129
- data = {
130
- registryId: id
131
- }.cleanup
132
- data_list << OpenStruct.new(data) unless data.empty?
133
- end
134
- tech_data << EnvHardwareRegistry.new(array: data_list) unless data_list.empty?
135
- end
136
- # Software registry id
137
- if software_ids
138
- data_list = []
139
- software_ids.each do |id|
140
- data = {
141
- registryId: id
142
- }.cleanup
143
- data_list << OpenStruct.new(data) unless data.empty?
144
- end
145
- tech_data << EnvSoftwareRegistry.new(array: data_list) unless data_list.empty?
146
- end
147
- # Hardware
148
- if hardware_infos
149
- data_list = []
150
- hardware_infos.each do |hardware|
151
- data = {
152
- hardwareName: hardware[:name],
153
- hardwareType: hardware[:type],
154
- hardwareOtherInformation: hardware[:info],
155
- }.cleanup
156
- data_list << OpenStruct.new(data) unless data.empty?
157
- end
158
- tech_data << EnvironmentHardware.new(array: data_list) unless data_list.empty?
159
- end
160
- # Software
161
- if software_infos
162
- data_list = []
163
- software_infos.each do |software|
164
- data = {
165
- softwareName: software[:name],
166
- softwareVersion: software[:version],
167
- softwareType: software[:type],
168
- softwareOtherInformation: software[:info],
169
- softwareDependancy: software[:dependency],
170
- }.cleanup
171
- data_list << OpenStruct.new(data) unless data.empty?
172
- end
173
- tech_data << EnvironmentSoftware.new(array: data_list) unless data_list.empty?
174
- end
175
- # Relationship
176
- if relationship_infos
177
- data_list = []
178
- relationship_infos.each do |relationship|
179
- data = {
180
- relationshipType: relationship[:type],
181
- relationshipSubType: relationship[:subtype],
182
- relatedObjectIdentifierType1: relationship[:type1],
183
- relatedObjectIdentifierValue1: relationship[:id1],
184
- relatedObjectSequence1: relationship[:seq1],
185
- relatedObjectIdentifierType2: relationship[:type2],
186
- relatedObjectIdentifierValue2: relationship[:id2],
187
- relatedObjectSequence2: relationship[:seq2],
188
- relatedObjectIdentifierType3: relationship[:type3],
189
- relatedObjectIdentifierValue3: relationship[:id3],
190
- relatedObjectSequence3: relationship[:seq3],
191
- }.cleanup
192
- data_list << OpenStruct.new(data) unless data.empty?
193
- end
194
- tech_data << RelationShip.new(array: data_list) unless data_list.empty?
195
- end
196
- # Environment
197
- if environments
198
- data_list = []
199
- environments.each do |environment|
200
- data = {
201
- environmentCharacteristic: environment[:characteristic],
202
- environmentPurpose: environment[:purpose],
203
- environmentNote: environment[:note],
204
- }.cleanup
205
- data_list << OpenStruct.new(data) unless data.empty?
206
- end
207
- tech_data << Environment.new(array: data_list) unless data_list.empty?
208
- end
209
- # Finally assemble technical section
210
- dnx[:tech] = tech_data unless tech_data.empty?
211
- # Rights section
212
- rights_data = []
213
- data = {
214
- policyId: access_right_id
215
- }.cleanup
216
- rights_data << AccessRightsPolicy.new(data) unless data.empty?
217
- dnx[:rights] = rights_data unless rights_data.empty?
218
- # Source metadata
219
- if source_metadata
220
- source_metadata.each_with_index do |metadata, i|
221
- dnx["source-#{metadata[:type].to_s.upcase}-#{i}"] = metadata[:data]
222
- end
223
- end
224
- dnx
225
- end
226
-
227
- end
228
-
229
47
  # Container class for creating a file in the METS.
230
48
  class File
231
49
  include MetsObject
@@ -289,9 +107,9 @@ module Libis
289
107
  compositionLevel: composition_level,
290
108
  # fileLocationType: 'FILE',
291
109
  fileLocation: location,
292
- fileOriginalName: original || target_names,
110
+ fileOriginalName: original || target_name,
293
111
  fileOriginalPath: target_path,
294
- # fileOriginalID: URI.encode(location),
112
+ # fileOriginalID: CGI.escape(location),
295
113
  # fileExtension: ::File.extname(orig_name),
296
114
  fileMIMEType: mimetype,
297
115
  fileSizeBytes: size,
@@ -524,6 +342,187 @@ module Libis
524
342
 
525
343
  end
526
344
 
345
+ # Container class for creating a representation in the METS.
346
+ class Representation < Div
347
+
348
+ # The currently allowed attributes on this class. The attributes will typically be used in {DnxSection}s.
349
+ attr_accessor :preservation_type, :usage_type, :representation_code, :entity_type, :access_right_id,
350
+ :user_a, :user_b, :user_c,
351
+ :group_id, :priority, :order,
352
+ :digital_original, :content, :context, :hardware, :carrier, :original_name,
353
+ :preservation_levels, :env_dependencies, :hardware_ids, :software_ids,
354
+ :hardware_infos, :software_infos, :relationship_infos, :environments,
355
+ :dc_record, :source_metadata
356
+
357
+ # The id that will be used in the XML file to reference this representation.
358
+ def xml_id
359
+ "rep#{@id}"
360
+ end
361
+
362
+ # This method creates the appropriate {DnxSection}s based on what attributes are filled in.
363
+ def amd
364
+ dnx = {}
365
+ tech_data = []
366
+ # General characteristics
367
+ data = {
368
+ preservationType: preservation_type,
369
+ usageType: usage_type,
370
+ DigitalOriginal: digital_original,
371
+ label: label,
372
+ representationEntityType: entity_type,
373
+ contentType: content,
374
+ contextType: context,
375
+ hardwareUsed: hardware,
376
+ physicalCarrierMedia: carrier,
377
+ deliveryPriority: priority,
378
+ orderingSequence: order,
379
+ RepresentationCode: representation_code,
380
+ RepresentationOriginalName: original_name,
381
+ UserDefinedA: user_a,
382
+ UserDefinedB: user_b,
383
+ UserDefinedC: user_c,
384
+ }.cleanup
385
+ tech_data << GeneralRepCharacteristics.new(data) unless data.empty?
386
+ # Object characteristics
387
+ data = {
388
+ groupID: group_id
389
+ }.cleanup
390
+ tech_data << ObjectCharacteristics.new(data) unless data.empty?
391
+ # Preservation level
392
+ if preservation_levels
393
+ data_list = []
394
+ preservation_levels.each do |preservation_level|
395
+ data = {
396
+ preservationLevelValue: preservation_level[:value],
397
+ preservationLevelRole: preservation_level[:role],
398
+ preservationLevelRationale: preservation_level[:rationale],
399
+ preservationLevelDateAssigned: preservation_level[:date],
400
+ }.cleanup
401
+ data_list << OpenStruct.new(data) unless data.empty?
402
+ end
403
+ tech_data << PreservationLevel.new(array: data_list) unless data_list.empty?
404
+ end
405
+ # Dependencies
406
+ if env_dependencies
407
+ data_list = []
408
+ env_dependencies.each do |dependency|
409
+ data = {
410
+ dependencyName: dependency[:name],
411
+ dependencyIdentifierType1: dependency[:type1],
412
+ dependencyIdentifierValue1: dependency[:value1],
413
+ dependencyIdentifierType2: dependency[:type2],
414
+ dependencyIdentifierValue2: dependency[:value2],
415
+ dependencyIdentifierType3: dependency[:type3],
416
+ dependencyIdentifierValue3: dependency[:value3],
417
+ }.cleanup
418
+ data_list << OpenStruct.new(data) unless data.empty?
419
+ end
420
+ tech_data << EnvironmentDependencies.new(array: data_list) unless data_list.empty?
421
+ end
422
+ # Hardware registry id
423
+ if hardware_ids
424
+ data_list = []
425
+ hardware_ids.each do |id|
426
+ data = {
427
+ registryId: id
428
+ }.cleanup
429
+ data_list << OpenStruct.new(data) unless data.empty?
430
+ end
431
+ tech_data << EnvHardwareRegistry.new(array: data_list) unless data_list.empty?
432
+ end
433
+ # Software registry id
434
+ if software_ids
435
+ data_list = []
436
+ software_ids.each do |id|
437
+ data = {
438
+ registryId: id
439
+ }.cleanup
440
+ data_list << OpenStruct.new(data) unless data.empty?
441
+ end
442
+ tech_data << EnvSoftwareRegistry.new(array: data_list) unless data_list.empty?
443
+ end
444
+ # Hardware
445
+ if hardware_infos
446
+ data_list = []
447
+ hardware_infos.each do |hardware|
448
+ data = {
449
+ hardwareName: hardware[:name],
450
+ hardwareType: hardware[:type],
451
+ hardwareOtherInformation: hardware[:info],
452
+ }.cleanup
453
+ data_list << OpenStruct.new(data) unless data.empty?
454
+ end
455
+ tech_data << EnvironmentHardware.new(array: data_list) unless data_list.empty?
456
+ end
457
+ # Software
458
+ if software_infos
459
+ data_list = []
460
+ software_infos.each do |software|
461
+ data = {
462
+ softwareName: software[:name],
463
+ softwareVersion: software[:version],
464
+ softwareType: software[:type],
465
+ softwareOtherInformation: software[:info],
466
+ softwareDependancy: software[:dependency],
467
+ }.cleanup
468
+ data_list << OpenStruct.new(data) unless data.empty?
469
+ end
470
+ tech_data << EnvironmentSoftware.new(array: data_list) unless data_list.empty?
471
+ end
472
+ # Relationship
473
+ if relationship_infos
474
+ data_list = []
475
+ relationship_infos.each do |relationship|
476
+ data = {
477
+ relationshipType: relationship[:type],
478
+ relationshipSubType: relationship[:subtype],
479
+ relatedObjectIdentifierType1: relationship[:type1],
480
+ relatedObjectIdentifierValue1: relationship[:id1],
481
+ relatedObjectSequence1: relationship[:seq1],
482
+ relatedObjectIdentifierType2: relationship[:type2],
483
+ relatedObjectIdentifierValue2: relationship[:id2],
484
+ relatedObjectSequence2: relationship[:seq2],
485
+ relatedObjectIdentifierType3: relationship[:type3],
486
+ relatedObjectIdentifierValue3: relationship[:id3],
487
+ relatedObjectSequence3: relationship[:seq3],
488
+ }.cleanup
489
+ data_list << OpenStruct.new(data) unless data.empty?
490
+ end
491
+ tech_data << RelationShip.new(array: data_list) unless data_list.empty?
492
+ end
493
+ # Environment
494
+ if environments
495
+ data_list = []
496
+ environments.each do |environment|
497
+ data = {
498
+ environmentCharacteristic: environment[:characteristic],
499
+ environmentPurpose: environment[:purpose],
500
+ environmentNote: environment[:note],
501
+ }.cleanup
502
+ data_list << OpenStruct.new(data) unless data.empty?
503
+ end
504
+ tech_data << Environment.new(array: data_list) unless data_list.empty?
505
+ end
506
+ # Finally assemble technical section
507
+ dnx[:tech] = tech_data unless tech_data.empty?
508
+ # Rights section
509
+ rights_data = []
510
+ data = {
511
+ policyId: access_right_id
512
+ }.cleanup
513
+ rights_data << AccessRightsPolicy.new(data) unless data.empty?
514
+ dnx[:rights] = rights_data unless rights_data.empty?
515
+ # Source metadata
516
+ if source_metadata
517
+ source_metadata.each_with_index do |metadata, i|
518
+ dnx["source-#{metadata[:type].to_s.upcase}-#{i}"] = metadata[:data]
519
+ end
520
+ end
521
+ dnx
522
+ end
523
+
524
+ end
525
+
527
526
  # Container class for creating a structmap in the METS.
528
527
  class Map
529
528
  include MetsObject
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Tools
3
- VERSION = '1.0.15'
3
+ VERSION = '1.0.17'
4
4
  end
5
5
  end
@@ -88,7 +88,7 @@ module Libis
88
88
 
89
89
  # Export the XML Document to an XML string.
90
90
  # @param [Hash] options options passed to the underlying Nokogiri::XML::Document#to_xml; default is:
91
- # !{indent: 2, encoding: 'utf-8'}
91
+ # {indent: 2, encoding: 'utf-8'}
92
92
  # @return [String] a string
93
93
  def to_xml(options = {})
94
94
  options = {indent: 2, encoding: 'utf-8', save_with: Nokogiri::XML::Node::SaveOptions::DEFAULT_XML}.merge(options)
@@ -220,4 +220,426 @@ describe 'METS File' do
220
220
  end
221
221
  end
222
222
 
223
+ context 'builder' do
224
+
225
+ let(:dc_record) {
226
+ Libis::Tools::XmlDocument.parse <<-STR
227
+ <?xml version="1.0" encoding="UTF-8"?>
228
+ <dc:record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
229
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
230
+ xmlns:dcterms="http://purl.org/dc/terms/">
231
+ <dc:title>âbç d€f</dc:title>
232
+ </dc:record>
233
+ STR
234
+ }
235
+
236
+ let(:sample) {
237
+ {
238
+ dc_record: dc_record.root.to_xml,
239
+ amd: {
240
+ status: "ACTIVE",
241
+ access_right: "AR_EVERYONE"
242
+ },
243
+ representations: [
244
+ {
245
+ preservation_type: "PRESERVATION_MASTER",
246
+ usage_type: "VIEW",
247
+ label: "Archiefkopie"
248
+ },
249
+ ],
250
+ files: [
251
+ {
252
+ creation_date: '2021-08-27 14:14:26.367 UTC',
253
+ modification_date: '2018-04-06 05:12:27.077 UTC',
254
+ location: "/nas/upload/demo/test_diacritics/âbç d€f/aaa á aaa/b/abc.doc",
255
+ target_location: "aaa á aaa/b/abc.doc",
256
+ mimetype: "application/msword",
257
+ size: 56320,
258
+ puid: "fmt/39",
259
+ checksum_MD5: "16ddbd5ad80411d8ac1b6acf8348adfb",
260
+ label: "abc.doc",
261
+ representation: 1,
262
+ }, {
263
+ creation_date: '2021-08-27 14:14:26.367 UTC',
264
+ modification_date: '2018-04-06 05:13:04.635 UTC',
265
+ location: "/nas/upload/demo/test_diacritics/âbç d€f/aaa á aaa/b/def.dóc",
266
+ target_location: "aaa á aaa/b/def.dóc",
267
+ mimetype: "application/msword",
268
+ size: 45056,
269
+ puid: "fmt/39",
270
+ checksum_MD5: "b2907905a58f8599f07334cdc295c2f1",
271
+ label: "def.dóc",
272
+ representation: 1,
273
+ }, {
274
+ creation_date: '2021-08-27 14:14:26.366 UTC',
275
+ modification_date: '2018-04-06 05:12:17.935 UTC',
276
+ location: "/nas/upload/demo/test_diacritics/âbç d€f/aaa á aaa/b/ábc.doc",
277
+ target_location: "aaa á aaa/b/ábc.doc",
278
+ mimetype: "application/msword",
279
+ size: 61440,
280
+ puid: "fmt/39",
281
+ checksum_MD5: "312bba1438acdb17e3d69d19fe4cac4b",
282
+ label: "ábc.doc",
283
+ representation: 1,
284
+ }, {
285
+ creation_date: '2021-08-27 14:14:26.346 UTC',
286
+ modification_date: '2018-04-06 05:06:40.297 UTC',
287
+ location: "/nas/upload/demo/test_diacritics/âbç d€f/aaa á aaa/ccçcc/ã b ç d ë ¼.doc",
288
+ target_location: "aaa á aaa/ccçcc/ã b ç d ë ¼.doc",
289
+ mimetype: "application/msword",
290
+ size: 50688,
291
+ puid: "fmt/39",
292
+ checksum_MD5: "cd3e8cfa9cf5ada3485e205d706cee09",
293
+ label: "ã b ç d ë ¼.doc",
294
+ representation: 1,
295
+ }, {
296
+ creation_date: '2021-08-27 14:14:26.356 UTC',
297
+ modification_date: '2018-04-06 05:11:07.095 UTC',
298
+ location: "/nas/upload/demo/test_diacritics/âbç d€f/aaa á aaa/ss$ss/ã b ç d ë ¼.doc",
299
+ target_location: "aaa á aaa/ss$ss/ã b ç d ë ¼.doc",
300
+ mimetype: "application/msword",
301
+ size: 61440,
302
+ puid: "fmt/39",
303
+ checksum_MD5: "312bba1438acdb17e3d69d19fe4cac4b",
304
+ label: "ã b ç d ë ¼.doc",
305
+ representation: 1,
306
+ },
307
+ ],
308
+ divs: [
309
+ {
310
+ label: "âbç d€f"
311
+ }, {
312
+ parent: 1,
313
+ label: "aaa á aaa",
314
+ }, {
315
+ parent: 2,
316
+ label: "b",
317
+ files: [1,2,3]
318
+ }, {
319
+ parent: 2,
320
+ label: "ccçcc",
321
+ files: [4]
322
+ }, {
323
+ parent: 2,
324
+ label: "ss$ss",
325
+ files: [5]
326
+ },
327
+ ],
328
+ maps: [
329
+ {
330
+ representation: 1,
331
+ div: 1,
332
+ is_logical: false
333
+ }
334
+ ]
335
+ }
336
+ }
337
+
338
+ let(:target) {
339
+ ::Libis::Tools::XmlDocument.build do |xml|
340
+ xml[:mets].mets 'xmlns:mets' => 'http://www.loc.gov/METS/' do
341
+ xml[:mets].dmdSec ID: 'ie-dmd' do
342
+ xml[:mets].mdWrap MDTYPE: 'DC' do
343
+ xml[:mets].xmlData do
344
+ xml << dc_record.root.to_xml
345
+ # xml[:dc].record(
346
+ # 'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
347
+ # 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
348
+ # 'xmlns:dcterms' => 'http://purl.org/dc/terms/'
349
+ # ) do
350
+ # xml[:dc].title 'âbç d€f'
351
+ # end
352
+ end
353
+ end
354
+ end
355
+ xml[:mets].amdSec ID: 'ie-amd' do
356
+ xml[:mets].techMD ID: 'ie-amd-tech' do
357
+ xml[:mets].mdWrap MDTYPE: 'OTHER', OTHERMDTYPE: 'dnx' do
358
+ xml[:mets].xmlData do
359
+ xml.dnx xmlns: 'http://www.exlibrisgroup.com/dps/dnx' do
360
+ xml.section.generalIECharacteristics! do
361
+ xml.record do
362
+ xml.key.status! 'ACTIVE'
363
+ end
364
+ end
365
+ end
366
+ end
367
+ end
368
+ end
369
+ xml[:mets].rightsMD ID: 'ie-amd-rights' do
370
+ xml[:mets].mdWrap MDTYPE: 'OTHER', OTHERMDTYPE: 'dnx' do
371
+ xml[:mets].xmlData do
372
+ xml.dnx xmlns: 'http://www.exlibrisgroup.com/dps/dnx' do
373
+ xml.section.accessRightsPolicy! do
374
+ xml.record do
375
+ xml.key.policyId! 'AR_EVERYONE'
376
+ end
377
+ end
378
+ end
379
+ end
380
+ end
381
+ end
382
+ end
383
+ xml[:mets].amdSec ID: 'rep1-amd' do
384
+ xml[:mets].techMD ID: 'rep1-amd-tech' do
385
+ xml[:mets].mdWrap MDTYPE: 'OTHER', OTHERMDTYPE: 'dnx' do
386
+ xml[:mets].xmlData do
387
+ xml.dnx xmlns: 'http://www.exlibrisgroup.com/dps/dnx' do
388
+ xml.section.generalRepCharacteristics! do
389
+ xml.record do
390
+ xml.key.preservationType! 'PRESERVATION_MASTER'
391
+ xml.key.usageType! 'VIEW'
392
+ xml.key.label! 'Archiefkopie'
393
+ end
394
+ end
395
+ end
396
+ end
397
+ end
398
+ end
399
+ end
400
+ xml[:mets].amdSec ID: 'fid1-amd' do
401
+ xml[:mets].techMD ID: 'fid1-amd-tech' do
402
+ xml[:mets].mdWrap MDTYPE: 'OTHER', OTHERMDTYPE: 'dnx' do
403
+ xml[:mets].xmlData do
404
+ xml.dnx xmlns: 'http://www.exlibrisgroup.com/dps/dnx' do
405
+ xml.section.generalFileCharacteristics! do
406
+ xml.record do
407
+ xml.key.label! 'abc.doc'
408
+ xml.key.fileCreationDate! '2021-08-27 14:14:26.367 UTC'
409
+ xml.key.fileModificationDate! '2018-04-06 05:12:27.077 UTC'
410
+ xml.key.fileLocation! '/nas/upload/demo/test_diacritics/âbç d€f/aaa á aaa/b/abc.doc'
411
+ xml.key.fileOriginalName! 'abc.doc'
412
+ xml.key.fileOriginalPath! 'aaa á aaa/b'
413
+ xml.key.fileMIMEType! 'application/msword'
414
+ xml.key.fileSizeBytes! '56320'
415
+ end
416
+ end
417
+ xml.section.fileFixity! do
418
+ xml.record do
419
+ xml.key.fixityType! 'MD5'
420
+ xml.key.fixityValue! '16ddbd5ad80411d8ac1b6acf8348adfb'
421
+ end
422
+ end
423
+ xml.section.objectCharacteristics! do
424
+ xml.record do
425
+ xml.key.groupID! 'grp'
426
+ end
427
+ end
428
+ end
429
+ end
430
+ end
431
+ end
432
+ end
433
+ xml[:mets].amdSec ID: 'fid2-amd' do
434
+ xml[:mets].techMD ID: 'fid2-amd-tech' do
435
+ xml[:mets].mdWrap MDTYPE: 'OTHER', OTHERMDTYPE: 'dnx' do
436
+ xml[:mets].xmlData do
437
+ xml.dnx xmlns: 'http://www.exlibrisgroup.com/dps/dnx' do
438
+ xml.section.generalFileCharacteristics! do
439
+ xml.record do
440
+ xml.key.label! 'def.dóc'
441
+ xml.key.fileCreationDate! '2021-08-27 14:14:26.367 UTC'
442
+ xml.key.fileModificationDate! '2018-04-06 05:13:04.635 UTC'
443
+ xml.key.fileLocation! '/nas/upload/demo/test_diacritics/âbç d€f/aaa á aaa/b/def.dóc'
444
+ xml.key.fileOriginalName! 'def.dóc'
445
+ xml.key.fileOriginalPath! 'aaa á aaa/b'
446
+ xml.key.fileMIMEType! 'application/msword'
447
+ xml.key.fileSizeBytes! '45056'
448
+ end
449
+ end
450
+ xml.section.fileFixity! do
451
+ xml.record do
452
+ xml.key.fixityType! 'MD5'
453
+ xml.key.fixityValue! 'b2907905a58f8599f07334cdc295c2f1'
454
+ end
455
+ end
456
+ xml.section.objectCharacteristics! do
457
+ xml.record do
458
+ xml.key.groupID! 'grp'
459
+ end
460
+ end
461
+ end
462
+ end
463
+ end
464
+ end
465
+ end
466
+ xml[:mets].amdSec ID: 'fid3-amd' do
467
+ xml[:mets].techMD ID: 'fid3-amd-tech' do
468
+ xml[:mets].mdWrap MDTYPE: 'OTHER', OTHERMDTYPE: 'dnx' do
469
+ xml[:mets].xmlData do
470
+ xml.dnx xmlns: 'http://www.exlibrisgroup.com/dps/dnx' do
471
+ xml.section.generalFileCharacteristics! do
472
+ xml.record do
473
+ xml.key.label! 'ábc.doc'
474
+ xml.key.fileCreationDate! '2021-08-27 14:14:26.366 UTC'
475
+ xml.key.fileModificationDate! '2018-04-06 05:12:17.935 UTC'
476
+ xml.key.fileLocation! '/nas/upload/demo/test_diacritics/âbç d€f/aaa á aaa/b/ábc.doc'
477
+ xml.key.fileOriginalName! 'ábc.doc'
478
+ xml.key.fileOriginalPath! 'aaa á aaa/b'
479
+ xml.key.fileMIMEType! 'application/msword'
480
+ xml.key.fileSizeBytes! '61440'
481
+ end
482
+ end
483
+ xml.section.fileFixity! do
484
+ xml.record do
485
+ xml.key.fixityType! 'MD5'
486
+ xml.key.fixityValue! '312bba1438acdb17e3d69d19fe4cac4b'
487
+ end
488
+ end
489
+ xml.section.objectCharacteristics! do
490
+ xml.record do
491
+ xml.key.groupID! 'grp'
492
+ end
493
+ end
494
+ end
495
+ end
496
+ end
497
+ end
498
+ end
499
+ xml[:mets].amdSec ID: 'fid4-amd' do
500
+ xml[:mets].techMD ID: 'fid4-amd-tech' do
501
+ xml[:mets].mdWrap MDTYPE: 'OTHER', OTHERMDTYPE: 'dnx' do
502
+ xml[:mets].xmlData do
503
+ xml.dnx xmlns: 'http://www.exlibrisgroup.com/dps/dnx' do
504
+ xml.section.generalFileCharacteristics! do
505
+ xml.record do
506
+ xml.key.label! 'ã b ç d ë ¼.doc'
507
+ xml.key.fileCreationDate! '2021-08-27 14:14:26.346 UTC'
508
+ xml.key.fileModificationDate! '2018-04-06 05:06:40.297 UTC'
509
+ xml.key.fileLocation! '/nas/upload/demo/test_diacritics/âbç d€f/aaa á aaa/ccçcc/ã b ç d ë ¼.doc'
510
+ xml.key.fileOriginalName! 'ã b ç d ë ¼.doc'
511
+ xml.key.fileOriginalPath! 'aaa á aaa/ccçcc'
512
+ xml.key.fileMIMEType! 'application/msword'
513
+ xml.key.fileSizeBytes! '50688'
514
+ end
515
+ end
516
+ xml.section.fileFixity! do
517
+ xml.record do
518
+ xml.key.fixityType! 'MD5'
519
+ xml.key.fixityValue! 'cd3e8cfa9cf5ada3485e205d706cee09'
520
+ end
521
+ end
522
+ xml.section.objectCharacteristics! do
523
+ xml.record do
524
+ xml.key.groupID! 'grp'
525
+ end
526
+ end
527
+ end
528
+ end
529
+ end
530
+ end
531
+ end
532
+ xml[:mets].amdSec ID: 'fid5-amd' do
533
+ xml[:mets].techMD ID: 'fid5-amd-tech' do
534
+ xml[:mets].mdWrap MDTYPE: 'OTHER', OTHERMDTYPE: 'dnx' do
535
+ xml[:mets].xmlData do
536
+ xml.dnx xmlns: 'http://www.exlibrisgroup.com/dps/dnx' do
537
+ xml.section.generalFileCharacteristics! do
538
+ xml.record do
539
+ xml.key.label! 'ã b ç d ë ¼.doc'
540
+ xml.key.fileCreationDate! '2021-08-27 14:14:26.356 UTC'
541
+ xml.key.fileModificationDate! '2018-04-06 05:11:07.095 UTC'
542
+ xml.key.fileLocation! '/nas/upload/demo/test_diacritics/âbç d€f/aaa á aaa/ss$ss/ã b ç d ë ¼.doc'
543
+ xml.key.fileOriginalName! 'ã b ç d ë ¼.doc'
544
+ xml.key.fileOriginalPath! 'aaa á aaa/ss$ss'
545
+ xml.key.fileMIMEType! 'application/msword'
546
+ xml.key.fileSizeBytes! '61440'
547
+ end
548
+ end
549
+ xml.section.fileFixity! do
550
+ xml.record do
551
+ xml.key.fixityType! 'MD5'
552
+ xml.key.fixityValue! '312bba1438acdb17e3d69d19fe4cac4b'
553
+ end
554
+ end
555
+ xml.section.objectCharacteristics! do
556
+ xml.record do
557
+ xml.key.groupID! 'grp'
558
+ end
559
+ end
560
+ end
561
+ end
562
+ end
563
+ end
564
+ end
565
+ xml[:mets].fileSec do
566
+ xml[:mets].fileGrp ID: 'rep1', USE: 'VIEW', ADMID: 'rep1-amd' do
567
+ xml[:mets].file ID: 'fid1', MIMETYPE: 'application/msword', ADMID: 'fid1-amd', GROUPID: 'grp' do
568
+ xml[:mets].FLocat 'xmlns:xlin' => 'http://www.w3.org/1999/xlink', LOCTYPE: 'URL', 'xlin:href' => 'aaa á aaa/b/abc.doc'
569
+ end
570
+ xml[:mets].file ID: 'fid2', MIMETYPE: 'application/msword', ADMID: 'fid2-amd', GROUPID: 'grp' do
571
+ xml[:mets].FLocat 'xmlns:xlin' => 'http://www.w3.org/1999/xlink', LOCTYPE: 'URL', 'xlin:href' => 'aaa á aaa/b/def.dóc'
572
+ end
573
+ xml[:mets].file ID: 'fid3', MIMETYPE: 'application/msword', ADMID: 'fid3-amd', GROUPID: 'grp' do
574
+ xml[:mets].FLocat 'xmlns:xlin' => 'http://www.w3.org/1999/xlink', LOCTYPE: 'URL', 'xlin:href' => 'aaa á aaa/b/ábc.doc'
575
+ end
576
+ xml[:mets].file ID: 'fid4', MIMETYPE: 'application/msword', ADMID: 'fid4-amd', GROUPID: 'grp' do
577
+ xml[:mets].FLocat 'xmlns:xlin' => 'http://www.w3.org/1999/xlink', LOCTYPE: 'URL', 'xlin:href' => 'aaa á aaa/ccçcc/ã b ç d ë ¼.doc'
578
+ end
579
+ xml[:mets].file ID: 'fid5', MIMETYPE: 'application/msword', ADMID: 'fid5-amd', GROUPID: 'grp' do
580
+ xml[:mets].FLocat 'xmlns:xlin' => 'http://www.w3.org/1999/xlink', LOCTYPE: 'URL', 'xlin:href' => 'aaa á aaa/ss$ss/ã b ç d ë ¼.doc'
581
+ end
582
+ end
583
+ end
584
+ xml[:mets].structMap ID: 'rep1-1', TYPE: 'PHYSICAL' do
585
+ xml[:mets].div LABEL: 'Archiefkopie' do
586
+ xml[:mets].div LABEL: 'âbç d€f' do
587
+ xml[:mets].div LABEL: 'aaa á aaa' do
588
+ xml[:mets].div LABEL: 'b' do
589
+ xml[:mets].div LABEL: 'abc.doc', TYPE: 'FILE' do
590
+ xml[:mets].fptr FILEID: 'fid1'
591
+ end
592
+ xml[:mets].div LABEL: 'def.dóc', TYPE: 'FILE' do
593
+ xml[:mets].fptr FILEID: 'fid2'
594
+ end
595
+ xml[:mets].div LABEL: 'ábc.doc', TYPE: 'FILE' do
596
+ xml[:mets].fptr FILEID: 'fid3'
597
+ end
598
+ end
599
+ xml[:mets].div LABEL: 'ccçcc' do
600
+ xml[:mets].div LABEL: 'ã b ç d ë ¼.doc', TYPE: 'FILE' do
601
+ xml[:mets].fptr FILEID: 'fid4'
602
+ end
603
+ end
604
+ xml[:mets].div LABEL: 'ss$ss' do
605
+ xml[:mets].div LABEL: 'ã b ç d ë ¼.doc', TYPE: 'FILE' do
606
+ xml[:mets].fptr FILEID: 'fid5'
607
+ end
608
+ end
609
+ end
610
+ end
611
+ end
612
+ end
613
+ end
614
+ end.document
615
+ }
616
+
617
+ it 'produces METS XML' do
618
+ mets_file.dc_record = sample[:dc_record]
619
+ mets_file.amd_info = sample[:amd]
620
+ sample[:representations].each do |rep|
621
+ mets_file.representation(rep)
622
+ end
623
+ sample[:files].each do |file|
624
+ rep_id = file.delete(:representation)
625
+ rep = mets_file.representations[rep_id]
626
+ mets_file.file(file).representation = rep
627
+ end
628
+ sample[:divs].each do |div|
629
+ parent = div.delete(:parent)
630
+ files = div.delete(:files)
631
+ d = mets_file.div(div)
632
+ files.each { |f| d << mets_file.files[f] } if files
633
+ mets_file.divs[parent] << d if parent
634
+ end
635
+ sample[:maps].each do |map|
636
+ rep = mets_file.representations[map[:representation]]
637
+ div = mets_file.divs[map[:div]]
638
+ mets_file.map(rep, div)
639
+ end
640
+
641
+ expect(mets_file.xml_doc.root).to be_equivalent_to target.root
642
+ end
643
+ end
644
+
223
645
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libis-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.15
4
+ version: 1.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-30 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -386,7 +386,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
386
386
  - !ruby/object:Gem::Version
387
387
  version: '0'
388
388
  requirements: []
389
- rubygems_version: 3.2.15
389
+ rubygems_version: 3.1.6
390
390
  signing_key:
391
391
  specification_version: 4
392
392
  summary: LIBIS toolbox.