libis-metadata 1.0.3 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libis/metadata/mappers/scope_vlp.rb +34 -0
- data/lib/libis/metadata/mappers/standard.rb +122 -0
- data/lib/libis/metadata/version.rb +1 -1
- data/lib/libis/metadata.rb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: accda12ccad7ef12d09ea7137ebdaee08f936f0469b50948ba9df05bf35bc20c
|
4
|
+
data.tar.gz: cc14b46dd9f87d3b6f12cd12056c51c232352255fe597c598551723e4aa829f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ba393be7aa902c08184dedfc4904db6dea565b65c09f8581ce3a3cf7d11cd3388600d447bac30dfa8bef6a46f750b250fa6cb76b43d2494bf5232bea40d4a78
|
7
|
+
data.tar.gz: '059ea92156883bd33f4f5bae08d7c17530793fc94b4e9fe5428d255ff8e74537b83160a01b607712a6eca553bea48c842b9ced7c836eebf8a9608041a297126d'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'libis/metadata/dublin_core_record'
|
4
|
+
require 'libis/tools/assert'
|
5
|
+
|
6
|
+
module Libis
|
7
|
+
module Metadata
|
8
|
+
module Mappers
|
9
|
+
# noinspection RubyResolve
|
10
|
+
|
11
|
+
# Mixin for {::Libis::Metadata::DublinCoreRecord} to enable conversion of the Scope exported DC record.
|
12
|
+
module ScopeVlp
|
13
|
+
|
14
|
+
# Main conversion method.
|
15
|
+
# @return [::Libis::Metadata::DublinCoreRecord]
|
16
|
+
def to_dc
|
17
|
+
assert(self.is_a? Libis::Metadata::DublinCoreRecord)
|
18
|
+
|
19
|
+
doc = Libis::Metadata::DublinCoreRecord.new(self.to_xml)
|
20
|
+
|
21
|
+
# set isPartOf
|
22
|
+
doc.isPartOf = doc.title.content
|
23
|
+
|
24
|
+
# remove identifiers with URL
|
25
|
+
doc.xpath('//dc:identifier[@xsi:type = "dcterms:URI"]').remove
|
26
|
+
|
27
|
+
doc
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'libis/metadata/marc_record'
|
4
|
+
require 'libis/metadata/dublin_core_record'
|
5
|
+
require 'libis/tools/assert'
|
6
|
+
|
7
|
+
module Libis
|
8
|
+
module Metadata
|
9
|
+
module Mappers
|
10
|
+
# noinspection RubyResolve
|
11
|
+
|
12
|
+
# Mixin for {::Libis::Metadata::MarcRecord} to enable conversion into
|
13
|
+
# {Libis::Metadata::DublinCoreRecord}. This module implements the standard mapping for KU Leuven.
|
14
|
+
module Standard
|
15
|
+
|
16
|
+
# Main conversion method.
|
17
|
+
# @param [String] label optional extra identified to add to the DC record.
|
18
|
+
# @return [::Libis::Metadata::DublinCoreRecord]
|
19
|
+
def to_dc(label = nil)
|
20
|
+
assert(self.is_a? Libis::Metadata::MarcRecord)
|
21
|
+
|
22
|
+
doc = Libis::Metadata::DublinCoreRecord.new do |xml|
|
23
|
+
marc2dc_identifier(xml, label)
|
24
|
+
marc2dc_title(xml)
|
25
|
+
marc2dc_medium(xml)
|
26
|
+
marc2dc_rights(xml)
|
27
|
+
marc2dc_type(xml)
|
28
|
+
marc2dc_source(xml)
|
29
|
+
end
|
30
|
+
|
31
|
+
# deduplicate the XML
|
32
|
+
found = Set.new
|
33
|
+
doc.root.children.each {|node| node.unlink unless found.add?(node.to_xml)}
|
34
|
+
|
35
|
+
doc
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def marc2dc_identifier(xml, label = nil)
|
42
|
+
# DC:IDENTIFIER
|
43
|
+
marc2dc_identifier_label(label, xml)
|
44
|
+
marc2dc_identifier_001(xml)
|
45
|
+
end
|
46
|
+
|
47
|
+
def marc2dc_title(xml)
|
48
|
+
# DC:TITLE
|
49
|
+
marc2dc_title_245(xml)
|
50
|
+
end
|
51
|
+
|
52
|
+
def marc2dc_medium(xml)
|
53
|
+
# DCTERMS:MEDIUM
|
54
|
+
marc2dc_medium_340(xml)
|
55
|
+
end
|
56
|
+
|
57
|
+
def marc2dc_rights(xml)
|
58
|
+
# DC:RIGHTS
|
59
|
+
marc2dc_rights_542(xml)
|
60
|
+
end
|
61
|
+
|
62
|
+
def marc2dc_type(xml)
|
63
|
+
# DC:TYPE
|
64
|
+
marc2dc_type_653__6_a(xml)
|
65
|
+
end
|
66
|
+
|
67
|
+
def marc2dc_source(xml)
|
68
|
+
# DC: SOURCE
|
69
|
+
marc2dc_source_8528_(xml)
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def marc2dc_identifier_label(label, xml)
|
75
|
+
# noinspection RubyResolve
|
76
|
+
xml['dc'].identifier label if label
|
77
|
+
end
|
78
|
+
|
79
|
+
def marc2dc_identifier_001(xml)
|
80
|
+
# "urn:ControlNumber:" [MARC 001]
|
81
|
+
all_tags('001') { |t|
|
82
|
+
xml['dc'].identifier(element(t.datas, prefix: 'urn:ControlNumber:'), 'xsi:type' => 'dcterms:URI')
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
def marc2dc_title_245(xml)
|
87
|
+
all_tags('245', 'a b') { |t|
|
88
|
+
xml['dc'].title(element(t._ab, join: ' : '))
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
def marc2dc_medium_340(xml)
|
93
|
+
# [MARC 340 ## $a $e]
|
94
|
+
all_tags('340', 'a e') { |t|
|
95
|
+
xml['dcterms'].medium list_s(t._ae)
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
def marc2dc_rights_542(xml)
|
100
|
+
# [MARC 542 ## $l / $n [$u]]
|
101
|
+
all_tags('542') { |t|
|
102
|
+
xml['dc'].rights list_s(element(t._ln, join: ' / '), element(t._u, fix: '[]'))
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
106
|
+
def marc2dc_type_653__6_a(xml)
|
107
|
+
# [MARC 653 #6 $a]
|
108
|
+
each_field('653#6', 'a') { |f| xml['dc'].type f }
|
109
|
+
end
|
110
|
+
|
111
|
+
def marc2dc_source_8528_(xml)
|
112
|
+
# [MARC 852 8_ $b $c, $h]
|
113
|
+
# first_tag('852', 'bch') { |t|
|
114
|
+
# xml['dc'].source list_c(element(t._bc, join(' '), t._h)
|
115
|
+
# }
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
data/lib/libis/metadata.rb
CHANGED
@@ -13,6 +13,7 @@ module Libis
|
|
13
13
|
# Mappers implementations for converting MARC records to Dublin Core.
|
14
14
|
module Mappers
|
15
15
|
|
16
|
+
autoload :Standard, 'libis/metadata/mappers/standard'
|
16
17
|
autoload :Kuleuven, 'libis/metadata/mappers/kuleuven'
|
17
18
|
autoload :Flandrica, 'libis/metadata/mappers/flandrica'
|
18
19
|
autoload :Scope, 'libis/metadata/mappers/scope'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-metadata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libis-tools
|
@@ -223,6 +223,8 @@ files:
|
|
223
223
|
- lib/libis/metadata/mappers/flandrica.rb
|
224
224
|
- lib/libis/metadata/mappers/kuleuven.rb
|
225
225
|
- lib/libis/metadata/mappers/scope.rb
|
226
|
+
- lib/libis/metadata/mappers/scope_vlp.rb
|
227
|
+
- lib/libis/metadata/mappers/standard.rb
|
226
228
|
- lib/libis/metadata/marc21_record.rb
|
227
229
|
- lib/libis/metadata/marc_record.rb
|
228
230
|
- lib/libis/metadata/parser/basic_parser.rb
|
@@ -258,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
260
|
- !ruby/object:Gem::Version
|
259
261
|
version: '0'
|
260
262
|
requirements: []
|
261
|
-
rubygems_version: 3.
|
263
|
+
rubygems_version: 3.1.6
|
262
264
|
signing_key:
|
263
265
|
specification_version: 4
|
264
266
|
summary: All about metadata.
|