relaton-bib 1.10.7 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/grammars/biblio.rng +24 -1
- data/grammars/isodoc.rng +73 -3
- data/lib/relaton_bib/bib_item_locality.rb +62 -0
- data/lib/relaton_bib/bibliographic_item.rb +12 -12
- data/lib/relaton_bib/bibliographic_size.rb +103 -0
- data/lib/relaton_bib/hash_converter.rb +36 -15
- data/lib/relaton_bib/medium.rb +45 -13
- data/lib/relaton_bib/series.rb +21 -31
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +20 -10
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a787155aa8128f6bbd98734d80eb23d60d890f564b0357b3d79070659a1322eb
|
4
|
+
data.tar.gz: 92f839bcc00d8346aece24347903e833268d6c89df5da8150e108f680ae171fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9a7e7163e3d93cea465b269aea55a18e585fa65165512cfa383f05a081605c66680912d77b0a4878ff27690713cee8d8b28dc9bbb84bb2477cf854a799e1a23
|
7
|
+
data.tar.gz: 017ea5aab785898a8ed574bc685a14006b2b60c936996a97b5b96e18746f1ac23d1dc43ebfd5886cec7416469e0a8843886277f8d4e5e4ade1cd907739318a2e
|
data/grammars/biblio.rng
CHANGED
@@ -677,6 +677,9 @@
|
|
677
677
|
<zeroOrMore>
|
678
678
|
<ref name="extent"/>
|
679
679
|
</zeroOrMore>
|
680
|
+
<optional>
|
681
|
+
<ref name="bibliographic_size"/>
|
682
|
+
</optional>
|
680
683
|
<zeroOrMore>
|
681
684
|
<ref name="accesslocation"/>
|
682
685
|
</zeroOrMore>
|
@@ -922,9 +925,29 @@
|
|
922
925
|
<text/>
|
923
926
|
</element>
|
924
927
|
</define>
|
928
|
+
<define name="sizevalue">
|
929
|
+
<element name="value">
|
930
|
+
<attribute name="type"/>
|
931
|
+
<text/>
|
932
|
+
</element>
|
933
|
+
</define>
|
934
|
+
<define name="bibliographic_size">
|
935
|
+
<element name="size">
|
936
|
+
<oneOrMore>
|
937
|
+
<ref name="sizevalue"/>
|
938
|
+
</oneOrMore>
|
939
|
+
</element>
|
940
|
+
</define>
|
925
941
|
<define name="extent">
|
926
942
|
<element name="extent">
|
927
|
-
<
|
943
|
+
<choice>
|
944
|
+
<zeroOrMore>
|
945
|
+
<ref name="locality"/>
|
946
|
+
</zeroOrMore>
|
947
|
+
<zeroOrMore>
|
948
|
+
<ref name="localityStack"/>
|
949
|
+
</zeroOrMore>
|
950
|
+
</choice>
|
928
951
|
</element>
|
929
952
|
</define>
|
930
953
|
<define name="series">
|
data/grammars/isodoc.rng
CHANGED
@@ -152,9 +152,7 @@
|
|
152
152
|
<data type="boolean"/>
|
153
153
|
</attribute>
|
154
154
|
</optional>
|
155
|
-
<
|
156
|
-
<ref name="PureTextElement"/>
|
157
|
-
</oneOrMore>
|
155
|
+
<ref name="XrefBody"/>
|
158
156
|
</element>
|
159
157
|
</define>
|
160
158
|
<define name="erefType">
|
@@ -188,6 +186,42 @@
|
|
188
186
|
<ref name="PureTextElement"/>
|
189
187
|
</oneOrMore>
|
190
188
|
</define>
|
189
|
+
<define name="localityStack">
|
190
|
+
<element name="localityStack">
|
191
|
+
<optional>
|
192
|
+
<attribute name="connective">
|
193
|
+
<choice>
|
194
|
+
<value>and</value>
|
195
|
+
<value>or</value>
|
196
|
+
<value>from</value>
|
197
|
+
<value>to</value>
|
198
|
+
<value/>
|
199
|
+
</choice>
|
200
|
+
</attribute>
|
201
|
+
</optional>
|
202
|
+
<zeroOrMore>
|
203
|
+
<ref name="locality"/>
|
204
|
+
</zeroOrMore>
|
205
|
+
</element>
|
206
|
+
</define>
|
207
|
+
<define name="sourceLocalityStack">
|
208
|
+
<element name="sourceLocalityStack">
|
209
|
+
<optional>
|
210
|
+
<attribute name="connective">
|
211
|
+
<choice>
|
212
|
+
<value>and</value>
|
213
|
+
<value>or</value>
|
214
|
+
<value>from</value>
|
215
|
+
<value>to</value>
|
216
|
+
<value/>
|
217
|
+
</choice>
|
218
|
+
</attribute>
|
219
|
+
</optional>
|
220
|
+
<zeroOrMore>
|
221
|
+
<ref name="sourceLocality"/>
|
222
|
+
</zeroOrMore>
|
223
|
+
</element>
|
224
|
+
</define>
|
191
225
|
<define name="ul">
|
192
226
|
<element name="ul">
|
193
227
|
<attribute name="id">
|
@@ -1098,6 +1132,16 @@
|
|
1098
1132
|
</define>
|
1099
1133
|
</include>
|
1100
1134
|
<!-- end overrides -->
|
1135
|
+
<define name="image" combine="choice">
|
1136
|
+
<element name="svg">
|
1137
|
+
<oneOrMore>
|
1138
|
+
<choice>
|
1139
|
+
<text/>
|
1140
|
+
<ref name="AnyElement"/>
|
1141
|
+
</choice>
|
1142
|
+
</oneOrMore>
|
1143
|
+
</element>
|
1144
|
+
</define>
|
1101
1145
|
<define name="MultilingualRenderingType">
|
1102
1146
|
<choice>
|
1103
1147
|
<value>common</value>
|
@@ -2631,4 +2675,30 @@
|
|
2631
2675
|
</zeroOrMore>
|
2632
2676
|
</element>
|
2633
2677
|
</define>
|
2678
|
+
<define name="XrefBody">
|
2679
|
+
<zeroOrMore>
|
2680
|
+
<ref name="XrefTarget"/>
|
2681
|
+
</zeroOrMore>
|
2682
|
+
<oneOrMore>
|
2683
|
+
<ref name="PureTextElement"/>
|
2684
|
+
</oneOrMore>
|
2685
|
+
</define>
|
2686
|
+
<define name="XrefTarget">
|
2687
|
+
<element name="location">
|
2688
|
+
<attribute name="target">
|
2689
|
+
<data type="string">
|
2690
|
+
<param name="pattern">\i\c*|\c+#\c+</param>
|
2691
|
+
</data>
|
2692
|
+
</attribute>
|
2693
|
+
<attribute name="connective">
|
2694
|
+
<choice>
|
2695
|
+
<value>and</value>
|
2696
|
+
<value>or</value>
|
2697
|
+
<value>from</value>
|
2698
|
+
<value>to</value>
|
2699
|
+
<value/>
|
2700
|
+
</choice>
|
2701
|
+
</attribute>
|
2702
|
+
</element>
|
2703
|
+
</define>
|
2634
2704
|
</grammar>
|
@@ -51,6 +51,22 @@ module RelatonBib
|
|
51
51
|
out += "#{pref}reference_to:: #{reference_to}\n" if reference_to
|
52
52
|
out
|
53
53
|
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Render locality as BibTeX.
|
57
|
+
#
|
58
|
+
# @param [BibTeX::Entry] item BibTeX entry.
|
59
|
+
#
|
60
|
+
def to_bibtex(item)
|
61
|
+
case type
|
62
|
+
when "chapter" then item.chapter = reference_from
|
63
|
+
when "page"
|
64
|
+
value = reference_from
|
65
|
+
value += "-#{reference_to}" if reference_to
|
66
|
+
item.pages = value
|
67
|
+
when "volume" then item.volume = reference_from
|
68
|
+
end
|
69
|
+
end
|
54
70
|
end
|
55
71
|
|
56
72
|
class Locality < BibItemLocality
|
@@ -58,6 +74,28 @@ module RelatonBib
|
|
58
74
|
def to_xml(builder)
|
59
75
|
builder.locality { |b| super(b) }
|
60
76
|
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# Render locality as hash.
|
80
|
+
#
|
81
|
+
# @return [Hash] locality as hash.
|
82
|
+
#
|
83
|
+
def to_hash
|
84
|
+
{ "locality" => super }
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# Render locality as AsciiBib.
|
89
|
+
#
|
90
|
+
# @param [String] prefix prefix of locality
|
91
|
+
# @param [Integer] count number of localities
|
92
|
+
#
|
93
|
+
# @return [String] AsciiBib.
|
94
|
+
#
|
95
|
+
def to_asciibib(prefix = "", count = 1)
|
96
|
+
pref = prefix.empty? ? "locality" : "#{prefix}.locality"
|
97
|
+
super(pref, count)
|
98
|
+
end
|
61
99
|
end
|
62
100
|
|
63
101
|
class LocalityStack
|
@@ -82,6 +120,30 @@ module RelatonBib
|
|
82
120
|
def to_hash
|
83
121
|
{ "locality_stack" => single_element_array(locality) }
|
84
122
|
end
|
123
|
+
|
124
|
+
#
|
125
|
+
# Render locality stack as AsciiBib.
|
126
|
+
#
|
127
|
+
# @param [String] prefix <description>
|
128
|
+
# @param [Integer] size size of locality stack
|
129
|
+
#
|
130
|
+
# @return [String] AsciiBib.
|
131
|
+
#
|
132
|
+
def to_asciibib(prefix = "", size = 1)
|
133
|
+
pref = prefix.empty? ? "locality_stack" : "#{prefix}.locality_stack"
|
134
|
+
out = ""
|
135
|
+
out << "#{pref}::\n" if size > 1
|
136
|
+
out << locality.map { |l| l.to_asciibib(pref, locality.size) }.join
|
137
|
+
end
|
138
|
+
|
139
|
+
#
|
140
|
+
# Render locality stack as BibTeX.
|
141
|
+
#
|
142
|
+
# @param [BibTeX::Entry] item BibTeX entry.
|
143
|
+
#
|
144
|
+
def to_bibtex(item)
|
145
|
+
locality.each { |l| l.to_bibtex(item) }
|
146
|
+
end
|
85
147
|
end
|
86
148
|
|
87
149
|
class SourceLocality < BibItemLocality
|
@@ -27,6 +27,7 @@ require "relaton_bib/place"
|
|
27
27
|
require "relaton_bib/structured_identifier"
|
28
28
|
require "relaton_bib/editorial_group"
|
29
29
|
require "relaton_bib/ics"
|
30
|
+
require "relaton_bib/bibliographic_size"
|
30
31
|
|
31
32
|
module RelatonBib
|
32
33
|
# Bibliographic item
|
@@ -95,7 +96,7 @@ module RelatonBib
|
|
95
96
|
# @return [Array<RelatonBib::Place>]
|
96
97
|
attr_reader :place
|
97
98
|
|
98
|
-
# @return [Array<RelatonBib::
|
99
|
+
# @return [Array<RelatonBib::Locality, RelatonBib::LocalityStack>]
|
99
100
|
attr_reader :extent
|
100
101
|
|
101
102
|
# @return [Array<Strig>]
|
@@ -122,6 +123,9 @@ module RelatonBib
|
|
122
123
|
# @return [RelatonBib::StructuredIdentifierCollection]
|
123
124
|
attr_reader :structuredidentifier
|
124
125
|
|
126
|
+
# @return [RelatonBib::BibliographicSize, nil]
|
127
|
+
attr_reader :size
|
128
|
+
|
125
129
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
126
130
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
127
131
|
|
@@ -141,7 +145,7 @@ module RelatonBib
|
|
141
145
|
# @param series [Array<RelatonBib::Series>]
|
142
146
|
# @param medium [RelatonBib::Medium, NilClas]
|
143
147
|
# @param place [Array<String, RelatonBib::Place>]
|
144
|
-
# @param extent [Array<Relaton::
|
148
|
+
# @param extent [Array<Relaton::Locality, RelatonBib::LocalityStack>]
|
145
149
|
# @param accesslocation [Array<String>]
|
146
150
|
# @param classification [Array<RelatonBib::Classification>]
|
147
151
|
# @param validity [RelatonBib:Validity, NilClass]
|
@@ -152,6 +156,7 @@ module RelatonBib
|
|
152
156
|
# @param editorialgroup [RelatonBib::EditorialGroup, nil]
|
153
157
|
# @param ics [Array<RelatonBib::ICS>]
|
154
158
|
# @param structuredidentifier [RelatonBib::StructuredIdentifierCollection]
|
159
|
+
# @param size [RelatonBib::BibliographicSize, nil]
|
155
160
|
#
|
156
161
|
# @param copyright [Array<Hash, RelatonBib::CopyrightAssociation>]
|
157
162
|
# @option copyright [Array<Hash, RelatonBib::ContributionInfo>] :owner
|
@@ -243,6 +248,7 @@ module RelatonBib
|
|
243
248
|
pl.is_a?(String) ? Place.new(name: pl) : pl
|
244
249
|
end
|
245
250
|
@extent = args[:extent] || []
|
251
|
+
@size = args[:size]
|
246
252
|
@accesslocation = args.fetch :accesslocation, []
|
247
253
|
@classification = args.fetch :classification, []
|
248
254
|
@validity = args[:validity]
|
@@ -372,6 +378,7 @@ module RelatonBib
|
|
372
378
|
hash["medium"] = medium.to_hash if medium
|
373
379
|
hash["place"] = single_element_array(place) if place&.any?
|
374
380
|
hash["extent"] = single_element_array(extent) if extent&.any?
|
381
|
+
hash["size"] = size.to_hash if size&.any?
|
375
382
|
if accesslocation&.any?
|
376
383
|
hash["accesslocation"] = single_element_array(accesslocation)
|
377
384
|
end
|
@@ -525,6 +532,7 @@ module RelatonBib
|
|
525
532
|
out += medium.to_asciibib prefix if medium
|
526
533
|
place.each { |pl| out += pl.to_asciibib prefix, place.size }
|
527
534
|
extent.each { |ex| out += ex.to_asciibib "#{pref}extent", extent.size }
|
535
|
+
out += size.to_asciibib pref if size
|
528
536
|
accesslocation.each { |al| out += "#{pref}accesslocation:: #{al}\n" }
|
529
537
|
classification.each do |cl|
|
530
538
|
out += cl.to_asciibib prefix, classification.size
|
@@ -624,16 +632,7 @@ module RelatonBib
|
|
624
632
|
|
625
633
|
# @param [BibTeX::Entry]
|
626
634
|
def bibtex_extent(item)
|
627
|
-
extent.each
|
628
|
-
case e.type
|
629
|
-
when "chapter" then item.chapter = e.reference_from
|
630
|
-
when "page"
|
631
|
-
value = e.reference_from
|
632
|
-
value += "-#{e.reference_to}" if e.reference_to
|
633
|
-
item.pages = value
|
634
|
-
when "volume" then item.volume = e.reference_from
|
635
|
-
end
|
636
|
-
end
|
635
|
+
extent.each { |e| e.to_bibtex(item) }
|
637
636
|
end
|
638
637
|
|
639
638
|
# @param [BibTeX::Entry]
|
@@ -736,6 +735,7 @@ module RelatonBib
|
|
736
735
|
medium&.to_xml builder
|
737
736
|
place.each { |pl| pl.to_xml builder }
|
738
737
|
extent.each { |e| builder.extent { e.to_xml builder } }
|
738
|
+
size&.to_xml builder
|
739
739
|
accesslocation.each { |al| builder.accesslocation al }
|
740
740
|
license.each { |l| builder.license l }
|
741
741
|
classification.each { |cls| cls.to_xml builder }
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module RelatonBib
|
2
|
+
class BibliographicSize
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegators :@size, :any?
|
6
|
+
|
7
|
+
# @return [Array<RelatonBib::BibliographicSize::Value>]
|
8
|
+
attr_reader :size
|
9
|
+
|
10
|
+
#
|
11
|
+
# Initialize a BibliographicSize object.
|
12
|
+
#
|
13
|
+
# @param [<Type>] size <description>
|
14
|
+
#
|
15
|
+
def initialize(size)
|
16
|
+
@size = size
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# Render BibliographicSize object to XML.
|
21
|
+
#
|
22
|
+
# @param [Nokogiri::XML::Builder] builder the XML builder
|
23
|
+
#
|
24
|
+
def to_xml(builder)
|
25
|
+
return if size.empty?
|
26
|
+
|
27
|
+
builder.size do
|
28
|
+
size.each { |s| s.to_xml builder }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Render BibliographicSize object to AsciiBib.
|
34
|
+
#
|
35
|
+
# @param [String] prefix prefix for the size
|
36
|
+
#
|
37
|
+
# @return [String] AsciiBib string
|
38
|
+
#
|
39
|
+
def to_asciibib(prefix = "")
|
40
|
+
pref = prefix.empty? ? "size" : "#{prefix}.size"
|
41
|
+
size.map { |s| s.to_asciibib pref, size.size }.join
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# Render BibliographicSize object to hash.
|
46
|
+
#
|
47
|
+
# @return [<Type>] <description>
|
48
|
+
#
|
49
|
+
def to_hash
|
50
|
+
size.map &:to_hash
|
51
|
+
end
|
52
|
+
|
53
|
+
class Value
|
54
|
+
# @return [String]
|
55
|
+
attr_reader :type, :value
|
56
|
+
|
57
|
+
#
|
58
|
+
# Initialize a BibliographicSize::Value object.
|
59
|
+
#
|
60
|
+
# @param [String] type the type of the size
|
61
|
+
# @param [String] value size value
|
62
|
+
#
|
63
|
+
def initialize(type:, value:)
|
64
|
+
@type = type
|
65
|
+
@value = value
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# Render BibliographicSize::Value object to XML.
|
70
|
+
#
|
71
|
+
# @param [Nokogiri::XML::Builder] builder the XML builder
|
72
|
+
#
|
73
|
+
def to_xml(builder)
|
74
|
+
builder.value value, type: type
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# Render BibliographicSize::Value object to hash.
|
79
|
+
#
|
80
|
+
# @return [<Type>] <description>
|
81
|
+
#
|
82
|
+
def to_hash
|
83
|
+
{ type: type, value: value }
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Render BibliographicSize::Value object to AsciiBib.
|
88
|
+
#
|
89
|
+
# @param [String] prefix prefix for the size
|
90
|
+
# @param [Integer] size size of the array
|
91
|
+
#
|
92
|
+
# @return [String] AsciiBib string
|
93
|
+
#
|
94
|
+
def to_asciibib(prefix, size)
|
95
|
+
pref = prefix.empty? ? "" : "#{prefix}."
|
96
|
+
out = ""
|
97
|
+
out << "#{prefix}::\n" if size.size > 1
|
98
|
+
out << "#{pref}type:: #{type}\n"
|
99
|
+
out << "#{pref}value:: #{value}\n"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -29,6 +29,7 @@ module RelatonBib
|
|
29
29
|
medium_hash_to_bib(ret)
|
30
30
|
place_hash_to_bib(ret)
|
31
31
|
extent_hash_to_bib(ret)
|
32
|
+
size_hash_to_bib(ret)
|
32
33
|
accesslocation_hash_to_bib(ret)
|
33
34
|
classification_hash_to_bib(ret)
|
34
35
|
validity_hash_to_bib(ret)
|
@@ -48,13 +49,32 @@ module RelatonBib
|
|
48
49
|
def extent_hash_to_bib(ret)
|
49
50
|
return unless ret[:extent]
|
50
51
|
|
51
|
-
ret[:extent] = array(ret[:extent])
|
52
|
-
|
53
|
-
ret[:extent][i] =
|
54
|
-
|
52
|
+
ret[:extent] = array(ret[:extent]).map do |e|
|
53
|
+
locality e
|
54
|
+
# ret[:extent][i] = Locality.new(e[:type], e[:reference_from],
|
55
|
+
# e[:reference_to])
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
59
|
+
def locality(loc)
|
60
|
+
if loc[:locality_stack]
|
61
|
+
LocalityStack.new(loc[:locality_stack].map { |l| locality(l) })
|
62
|
+
else
|
63
|
+
l = loc[:locality]
|
64
|
+
Locality.new(l[:type], l[:reference_from], l[:reference_to])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def size_hash_to_bib(ret)
|
69
|
+
return unless ret[:size]
|
70
|
+
|
71
|
+
ret[:size] = array(ret[:size])
|
72
|
+
size = ret[:size]&.map do |val|
|
73
|
+
BibliographicSize::Value.new(**val)
|
74
|
+
end
|
75
|
+
ret[:size] = BibliographicSize.new(size)
|
76
|
+
end
|
77
|
+
|
58
78
|
def title_hash_to_bib(ret)
|
59
79
|
return unless ret[:title]
|
60
80
|
|
@@ -316,18 +336,19 @@ module RelatonBib
|
|
316
336
|
|
317
337
|
# @param rel [Hash] relation
|
318
338
|
# @return [RelatonBib::LocalityStack]
|
319
|
-
def relation_locality_hash_to_bib(rel)
|
339
|
+
def relation_locality_hash_to_bib(rel)
|
320
340
|
rel[:locality] = array(rel[:locality])&.map do |bl|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
341
|
+
LocalityStack.new locality_locality_stack(bl)
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
def locality_locality_stack(lls)
|
346
|
+
if lls[:locality_stack]
|
347
|
+
array(lls[:locality_stack]).map do |l|
|
348
|
+
Locality.new(l[:type], l[:reference_from], l[:reference_to])
|
349
|
+
end
|
350
|
+
else
|
351
|
+
[Locality.new(lls[:type], lls[:reference_from], lls[:reference_to])]
|
331
352
|
end
|
332
353
|
end
|
333
354
|
|
data/lib/relaton_bib/medium.rb
CHANGED
@@ -1,41 +1,73 @@
|
|
1
1
|
module RelatonBib
|
2
2
|
class Medium
|
3
|
-
# @return [String,
|
4
|
-
attr_reader :form, :size, :scale
|
3
|
+
# @return [String, nil]
|
4
|
+
attr_reader :content, :genre, :form, :carrier, :size, :scale
|
5
5
|
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
#
|
7
|
+
# Initialize a Medium object.
|
8
|
+
#
|
9
|
+
# @param content [String, nil] content of the medium
|
10
|
+
# @param genre [String, nil] genre of the medium
|
11
|
+
# @param form [String, nil] form of the medium
|
12
|
+
# @param carrier [String, nil] carrier of the medium
|
13
|
+
# @param size [String, nil] size of the medium
|
14
|
+
# @param scale [String, nil]
|
15
|
+
#
|
16
|
+
def initialize(**args)
|
17
|
+
@content = args[:content]
|
18
|
+
@genre = args[:genre]
|
19
|
+
@form = args[:form]
|
20
|
+
@carrier = args[:carrier]
|
21
|
+
@size = args[:size]
|
22
|
+
@scale = args[:scale]
|
13
23
|
end
|
14
24
|
|
25
|
+
#
|
26
|
+
# Render Medium object to XML.
|
27
|
+
#
|
15
28
|
# @param builder [Nokogiri::XML::Builder]
|
16
|
-
|
29
|
+
#
|
30
|
+
def to_xml(builder) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
17
31
|
builder.medium do
|
32
|
+
builder.content content if content
|
33
|
+
builder.genre genre if genre
|
18
34
|
builder.form form if form
|
35
|
+
builder.carrier carrier if carrier
|
19
36
|
builder.size size if size
|
20
37
|
builder.scale scale if scale
|
21
38
|
end
|
22
39
|
end
|
23
40
|
|
41
|
+
#
|
42
|
+
# Render Medium object to hash.
|
43
|
+
#
|
24
44
|
# @return [Hash]
|
25
|
-
|
45
|
+
#
|
46
|
+
def to_hash # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
26
47
|
hash = {}
|
48
|
+
hash["content"] = content if content
|
49
|
+
hash["genre"] = genre if genre
|
27
50
|
hash["form"] = form if form
|
51
|
+
hash["carrier"] = carrier if carrier
|
28
52
|
hash["size"] = size if size
|
29
53
|
hash["scale"] = scale if scale
|
30
54
|
hash
|
31
55
|
end
|
32
56
|
|
57
|
+
#
|
58
|
+
# Render Medium object to AsciiBib.
|
59
|
+
#
|
33
60
|
# @param prefix [String]
|
61
|
+
#
|
34
62
|
# @return [String]
|
35
|
-
|
36
|
-
|
63
|
+
#
|
64
|
+
def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
65
|
+
pref = prefix.empty? ? "medium." : "#{prefix}.medium."
|
37
66
|
out = ""
|
67
|
+
out += "#{pref}content:: #{content}\n" if content
|
68
|
+
out += "#{pref}genre:: #{genre}\n" if genre
|
38
69
|
out += "#{pref}form:: #{form}\n" if form
|
70
|
+
out += "#{pref}carrier:: #{carrier}\n" if carrier
|
39
71
|
out += "#{pref}size:: #{size}\n" if size
|
40
72
|
out += "#{pref}scale:: #{scale}\n" if scale
|
41
73
|
out
|
data/lib/relaton_bib/series.rb
CHANGED
@@ -7,49 +7,35 @@ module RelatonBib
|
|
7
7
|
class Series
|
8
8
|
# TYPES = %w[main alt].freeze
|
9
9
|
|
10
|
-
# @return [String,
|
10
|
+
# @return [String, nil] allowed values: "main" or "alt"
|
11
11
|
attr_reader :type
|
12
12
|
|
13
|
-
# @return [RelatonBib::FormattedRef,
|
13
|
+
# @return [RelatonBib::FormattedRef, nil]
|
14
14
|
attr_reader :formattedref
|
15
15
|
|
16
|
-
# @return [RelatonBib::TypedTitleString,
|
16
|
+
# @return [RelatonBib::TypedTitleString, nil] title
|
17
17
|
attr_reader :title
|
18
18
|
|
19
|
-
# @return [String,
|
20
|
-
attr_reader :place
|
19
|
+
# @return [String, nil]
|
20
|
+
attr_reader :place, :organization, :from, :to, :number, :partnumber, :run
|
21
21
|
|
22
|
-
# @return [
|
23
|
-
attr_reader :organization
|
24
|
-
|
25
|
-
# @return [RelatonBib::LocalizedString, NilClass]
|
22
|
+
# @return [RelatonBib::LocalizedString, nil]
|
26
23
|
attr_reader :abbreviation
|
27
24
|
|
28
|
-
# @return [String, NilClass] date or year
|
29
|
-
attr_reader :from
|
30
|
-
|
31
|
-
# @return [String, NilClass] date or year
|
32
|
-
attr_reader :to
|
33
|
-
|
34
|
-
# @return [String, NilClass]
|
35
|
-
attr_reader :number
|
36
|
-
|
37
|
-
# @return [String, NilClass]
|
38
|
-
attr_reader :partnumber
|
39
|
-
|
40
25
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
41
26
|
|
42
|
-
# @param type [String,
|
43
|
-
# @param formattedref [RelatonBib::FormattedRef,
|
44
|
-
# @param title [RelatonBib::TypedTitleString,
|
27
|
+
# @param type [String, nil]
|
28
|
+
# @param formattedref [RelatonBib::FormattedRef, nil]
|
29
|
+
# @param title [RelatonBib::TypedTitleString, nil] title or
|
45
30
|
# formattedref argument should be passed
|
46
|
-
# @param place [String,
|
47
|
-
# @param orgaization [String,
|
48
|
-
# @param abbreviation [RelatonBib::LocalizedString,
|
49
|
-
# @param from [String,
|
50
|
-
# @param to [String,
|
51
|
-
# @param number [String,
|
52
|
-
# @param partnumber [String,
|
31
|
+
# @param place [String, nil]
|
32
|
+
# @param orgaization [String, nil]
|
33
|
+
# @param abbreviation [RelatonBib::LocalizedString, nil]
|
34
|
+
# @param from [String, nil]
|
35
|
+
# @param to [String, nil]
|
36
|
+
# @param number [String, nil]
|
37
|
+
# @param partnumber [String, nil]
|
38
|
+
# @param run [String, nil]
|
53
39
|
def initialize(**args)
|
54
40
|
unless args[:title].is_a?(RelatonBib::TypedTitleString) ||
|
55
41
|
args[:formattedref]
|
@@ -70,6 +56,7 @@ module RelatonBib
|
|
70
56
|
@to = args[:to]
|
71
57
|
@number = args[:number]
|
72
58
|
@partnumber = args[:partnumber]
|
59
|
+
@run = args[:run]
|
73
60
|
end
|
74
61
|
# rubocop:enable Metrics/MethodLength
|
75
62
|
|
@@ -89,6 +76,7 @@ module RelatonBib
|
|
89
76
|
builder.to to if to
|
90
77
|
builder.number number if number
|
91
78
|
builder.partnumber partnumber if partnumber
|
79
|
+
builder.run run if run
|
92
80
|
end
|
93
81
|
end
|
94
82
|
xml[:type] = type if type
|
@@ -109,6 +97,7 @@ module RelatonBib
|
|
109
97
|
hash["to"] = to if to
|
110
98
|
hash["number"] = number if number
|
111
99
|
hash["partnumber"] = partnumber if partnumber
|
100
|
+
hash["run"] = run if run
|
112
101
|
hash
|
113
102
|
end
|
114
103
|
|
@@ -128,6 +117,7 @@ module RelatonBib
|
|
128
117
|
out += "#{pref}.to:: #{to}\n" if to
|
129
118
|
out += "#{pref}.number:: #{number}\n" if number
|
130
119
|
out += "#{pref}.partnumber:: #{partnumber}\n" if partnumber
|
120
|
+
out += "#{pref}.run:: #{run}\n" if run
|
131
121
|
out
|
132
122
|
end
|
133
123
|
end
|
data/lib/relaton_bib/version.rb
CHANGED
@@ -46,6 +46,7 @@ module RelatonBib
|
|
46
46
|
medium: fetch_medium(bibitem),
|
47
47
|
place: fetch_place(bibitem),
|
48
48
|
extent: fetch_extent(bibitem),
|
49
|
+
size: fetch_size(bibitem),
|
49
50
|
accesslocation: bibitem.xpath("./accesslocation").map(&:text),
|
50
51
|
classification: fetch_classification(bibitem),
|
51
52
|
keyword: bibitem.xpath("keyword").map(&:text),
|
@@ -115,29 +116,38 @@ module RelatonBib
|
|
115
116
|
organization: sr.at("organization")&.text,
|
116
117
|
abbreviation: abbreviation, from: sr.at("from")&.text,
|
117
118
|
to: sr.at("to")&.text, number: sr.at("number")&.text,
|
118
|
-
partnumber: sr.at("partnumber")&.text
|
119
|
+
partnumber: sr.at("partnumber")&.text, run: sr.at("run")&.text,
|
119
120
|
)
|
120
121
|
end
|
121
122
|
end
|
122
123
|
|
123
|
-
def fetch_medium(item)
|
124
|
+
def fetch_medium(item) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/AbcSize,Metrics/PerceivedComplexity
|
124
125
|
medium = item.at("./medium")
|
125
126
|
return unless medium
|
126
127
|
|
127
128
|
Medium.new(
|
128
|
-
|
129
|
-
|
129
|
+
content: medium.at("content")&.text, genre: medium.at("genre")&.text,
|
130
|
+
form: medium.at("form")&.text, carrier: medium.at("carrier")&.text,
|
131
|
+
size: medium.at("size")&.text, scale: medium.at("scale")&.text
|
130
132
|
)
|
131
133
|
end
|
132
134
|
|
133
135
|
def fetch_extent(item)
|
134
|
-
item.xpath("./extent").
|
135
|
-
|
136
|
-
|
137
|
-
)
|
136
|
+
item.xpath("./extent").reduce([]) do |a, ex|
|
137
|
+
a + localities(ex)
|
138
|
+
# Locality.new(
|
139
|
+
# ex[:type], ex.at("referenceFrom")&.text, ex.at("referenceTo")&.text
|
140
|
+
# )
|
138
141
|
end
|
139
142
|
end
|
140
143
|
|
144
|
+
def fetch_size(item)
|
145
|
+
size = item.xpath("./size/value").map do |sz|
|
146
|
+
BibliographicSize::Value.new type: sz[:type], value: sz.text
|
147
|
+
end
|
148
|
+
BibliographicSize.new size if size.any?
|
149
|
+
end
|
150
|
+
|
141
151
|
def fetch_classification(item)
|
142
152
|
item.xpath("classification").map do |cls|
|
143
153
|
Classification.new type: cls[:type], value: cls.text
|
@@ -390,8 +400,8 @@ module RelatonBib
|
|
390
400
|
# @return [Array<RelatonBib::Locality, RelatonBib::LocalityStack>]
|
391
401
|
def localities(rel)
|
392
402
|
rel.xpath("./locality|./localityStack").map do |lc|
|
393
|
-
if lc
|
394
|
-
|
403
|
+
if lc.name == "locality"
|
404
|
+
Locality.new lc[:type], lc.at("referenceFrom").text, lc.at("referenceTo")&.text
|
395
405
|
else
|
396
406
|
LocalityStack.new(lc.xpath("./locality").map { |l| locality l })
|
397
407
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-bib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -223,6 +223,7 @@ files:
|
|
223
223
|
- lib/relaton_bib/biblio_version.rb
|
224
224
|
- lib/relaton_bib/bibliographic_date.rb
|
225
225
|
- lib/relaton_bib/bibliographic_item.rb
|
226
|
+
- lib/relaton_bib/bibliographic_size.rb
|
226
227
|
- lib/relaton_bib/bibtex_parser.rb
|
227
228
|
- lib/relaton_bib/bibxml_parser.rb
|
228
229
|
- lib/relaton_bib/classification.rb
|