libis-tools 1.0.12 → 1.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libis/tools/extend/empty.rb +3 -3
- data/lib/libis/tools/extend/roo.rb +12 -0
- data/lib/libis/tools/mets_file.rb +6 -2
- data/lib/libis/tools/mets_objects.rb +1 -1
- data/lib/libis/tools/version.rb +1 -1
- data/lib/libis/tools/xml_document.rb +1 -1
- data/spec/mets_file_spec.rb +422 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e11e0bac24cf562c5834d59510d7899d61e1295e3128fa66f549f40549d6c3e
|
4
|
+
data.tar.gz: 834820ad3715e8321c34af9099a7ff01278f15641ef99fb677eea3df0a0bcef4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5c898f23a098f8c592f9cb0a672e8d5248ffc71b4c93062c759daff7341a0cbdd4e95af9dd1017244afd31627c9c4e8d26df8698d433669f919db338eb83a7f
|
7
|
+
data.tar.gz: 9c90ddab8ff5e79f0c9478eea359baa70117570a5cafad8fc8454050af4b3f7709ba54a1c314b8aa81ea6cbba791cb64e759ccec2e6c5b97360271aa04cbc388
|
@@ -19,10 +19,10 @@ class FalseClass
|
|
19
19
|
end
|
20
20
|
|
21
21
|
class String
|
22
|
-
|
22
|
+
BLANK_REGEX = /\A[[:space:]]^\z/.freeze
|
23
23
|
def blank?
|
24
|
-
empty? ||
|
25
|
-
end
|
24
|
+
empty? || BLANK_REGEX.match?(self)
|
25
|
+
end unless method_defined? :blank?
|
26
26
|
end
|
27
27
|
|
28
28
|
class Object
|
@@ -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
|
@@ -91,14 +91,18 @@ module Libis
|
|
91
91
|
end
|
92
92
|
|
93
93
|
dmd_sec = xml_doc.root.xpath('mets:dmdSec', NS).inject({}) do |hash_dmd, dmd|
|
94
|
-
|
94
|
+
id = dmd[:ID]
|
95
|
+
id = id.slice(0..(id.index('-dmd') + 3))
|
96
|
+
hash_dmd[id] = dmd.xpath('.//dc:record', NS).first.children.inject({}) do |h, c|
|
95
97
|
h[c.name] = c.content if c.name != 'text'
|
96
98
|
h
|
97
99
|
end
|
98
100
|
hash_dmd
|
99
101
|
end
|
100
102
|
amd_sec = xml_doc.root.xpath('mets:amdSec', NS).inject({}) do |hash_amd, amd|
|
101
|
-
|
103
|
+
id = amd[:ID]
|
104
|
+
id = id.slice(0..(id.index('-amd') + 3))
|
105
|
+
hash_amd[id] = [:tech, :rights, :source, :digiprov].inject({}) do |hash_sec, sec|
|
102
106
|
md = amd.xpath("mets:#{sec}MD", NS).first
|
103
107
|
return hash_sec unless md
|
104
108
|
# hash_sec[sec] = md.xpath('mets:mdWrap/dnx:dnx/dnx:section', NS).inject({}) do |hash_md, dnx_sec|
|
@@ -289,7 +289,7 @@ module Libis
|
|
289
289
|
compositionLevel: composition_level,
|
290
290
|
# fileLocationType: 'FILE',
|
291
291
|
fileLocation: location,
|
292
|
-
fileOriginalName:
|
292
|
+
fileOriginalName: original || target_name,
|
293
293
|
fileOriginalPath: target_path,
|
294
294
|
# fileOriginalID: URI.encode(location),
|
295
295
|
# fileExtension: ::File.extname(orig_name),
|
data/lib/libis/tools/version.rb
CHANGED
@@ -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
|
-
#
|
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)
|
data/spec/mets_file_spec.rb
CHANGED
@@ -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.
|
4
|
+
version: 1.0.16
|
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-
|
11
|
+
date: 2021-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|