libis-metadata 1.0.3 → 1.0.4

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: ca5f166ae86c8c93e6d9a408fd0b9dc11fbfd89a3b4a44bb03b462c681a657b2
4
- data.tar.gz: 1b5a65bfaf9376202a2f9eb8162555a8c590d95400bbc8b154b7f17214d1be96
3
+ metadata.gz: 37c3e827f9942ee3da3f74e7fbd30a4c1154b73c361fd93005e397ce40e267e7
4
+ data.tar.gz: adf1401c4b230653c230caa2c4239bf7b1e253edb7aa3dae6bf2d3046b846599
5
5
  SHA512:
6
- metadata.gz: 15f622fbf1cc08fb5a3377dd8b2ca7621e74879195556307519422ebd4566f9d8d81833fd11d306a05208ab01b41ab92713e971c897d08b23ad21a141020c21b
7
- data.tar.gz: 8ed4749aa82a6978c50582af1e02918cba139b338e123d160cf3ddde583cc82a380d7423facfe1f7888270c54876205874902ef26862d26c3fe701fcc9d2d168
6
+ metadata.gz: d009b0f5a704e3c04c3c337f95f63008e7f2e97ac75af19b9c6e8f2b2c2d01410b964a97cba6a76547011804adc850a147bea37a5f5ab1e94977d10aff6e19fa
7
+ data.tar.gz: 8f0bb5786fa93b23ef1fd02e275b4114bf7896d1b5f2ceef5696ef61eb686c645e28eef2d165c75c4e58700722ce572873ab81060c6d40464a992f4e6ffcf7e0
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Metadata
3
- VERSION = '1.0.3'
3
+ VERSION = '1.0.4'
4
4
  end
5
5
  end
@@ -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.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-03 00:00:00.000000000 Z
11
+ date: 2022-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libis-tools
@@ -223,6 +223,7 @@ 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/standard.rb
226
227
  - lib/libis/metadata/marc21_record.rb
227
228
  - lib/libis/metadata/marc_record.rb
228
229
  - lib/libis/metadata/parser/basic_parser.rb