relaton-bib 1.8.2 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -11
- data/.rubocop.yml +1 -1
- data/grammars/biblio.rng +1 -0
- data/grammars/isodoc.rng +72 -10
- data/lib/relaton_bib/bibliographic_date.rb +1 -1
- data/lib/relaton_bib/bibliographic_item.rb +22 -16
- data/lib/relaton_bib/document_status.rb +5 -4
- data/lib/relaton_bib/editorial_group.rb +1 -1
- data/lib/relaton_bib/formatted_ref.rb +1 -1
- data/lib/relaton_bib/hash_converter.rb +17 -18
- data/lib/relaton_bib/hit.rb +6 -6
- data/lib/relaton_bib/organization.rb +2 -2
- data/lib/relaton_bib/typed_uri.rb +1 -1
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/workgroup.rb +24 -12
- data/lib/relaton_bib/xml_parser.rb +13 -10
- data/lib/relaton_bib.rb +2 -2
- data/relaton-bib.gemspec +1 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd7a8d6375ee7685203318f381c2f2b83c108460a2b9df8baceffe069e2e9915
|
4
|
+
data.tar.gz: 86b951c16a4f547c343347e001cbe06380fda97fccfb6e4ee3a58b92af81cc95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a342b2f2ea573d678746d3d219e0848beb5e12f55aca30004c19884e033f8347416f41d40ce188a908a06efdb85d0637ac0b90a83bede39d78a366bbe52778fc
|
7
|
+
data.tar.gz: 36c96c90ecc6563973520f1991ad1322b6cefce62a5c7d8bbd0bd9bf4c66c6dcb585ba9cc5c00f8d2c67f582d0a5f02f220656d27cb54b4c4396100085057a7f
|
data/.github/workflows/rake.yml
CHANGED
@@ -16,19 +16,9 @@ jobs:
|
|
16
16
|
strategy:
|
17
17
|
fail-fast: false
|
18
18
|
matrix:
|
19
|
-
ruby: [ '
|
19
|
+
ruby: [ '3.0', '2.7', '2.6', '2.5' ]
|
20
20
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
21
|
experimental: [ false ]
|
22
|
-
include:
|
23
|
-
- ruby: '3.0'
|
24
|
-
os: 'ubuntu-latest'
|
25
|
-
experimental: true
|
26
|
-
- ruby: '3.0'
|
27
|
-
os: 'windows-latest'
|
28
|
-
experimental: true
|
29
|
-
- ruby: '3.0'
|
30
|
-
os: 'macos-latest'
|
31
|
-
experimental: true
|
32
22
|
steps:
|
33
23
|
- uses: actions/checkout@v2
|
34
24
|
with:
|
data/.rubocop.yml
CHANGED
data/grammars/biblio.rng
CHANGED
data/grammars/isodoc.rng
CHANGED
@@ -45,6 +45,11 @@
|
|
45
45
|
<optional>
|
46
46
|
<attribute name="alt"/>
|
47
47
|
</optional>
|
48
|
+
<optional>
|
49
|
+
<attribute name="updatetype">
|
50
|
+
<data type="boolean"/>
|
51
|
+
</attribute>
|
52
|
+
</optional>
|
48
53
|
<text/>
|
49
54
|
</element>
|
50
55
|
</define>
|
@@ -199,6 +204,18 @@
|
|
199
204
|
</zeroOrMore>
|
200
205
|
</element>
|
201
206
|
</define>
|
207
|
+
<define name="dt">
|
208
|
+
<element name="dt">
|
209
|
+
<optional>
|
210
|
+
<attribute name="id">
|
211
|
+
<data type="ID"/>
|
212
|
+
</attribute>
|
213
|
+
</optional>
|
214
|
+
<zeroOrMore>
|
215
|
+
<ref name="TextElement"/>
|
216
|
+
</zeroOrMore>
|
217
|
+
</element>
|
218
|
+
</define>
|
202
219
|
<define name="example">
|
203
220
|
<element name="example">
|
204
221
|
<attribute name="id">
|
@@ -543,6 +560,9 @@
|
|
543
560
|
</define>
|
544
561
|
<define name="BibDataExtensionType">
|
545
562
|
<ref name="doctype"/>
|
563
|
+
<optional>
|
564
|
+
<ref name="docsubtype"/>
|
565
|
+
</optional>
|
546
566
|
<optional>
|
547
567
|
<ref name="editorialgroup"/>
|
548
568
|
</optional>
|
@@ -890,6 +910,14 @@
|
|
890
910
|
</define>
|
891
911
|
</include>
|
892
912
|
<!-- end overrides -->
|
913
|
+
<define name="docsubtype">
|
914
|
+
<element name="subdoctype">
|
915
|
+
<ref name="DocumentSubtype"/>
|
916
|
+
</element>
|
917
|
+
</define>
|
918
|
+
<define name="DocumentSubtype">
|
919
|
+
<text/>
|
920
|
+
</define>
|
893
921
|
<define name="colgroup">
|
894
922
|
<element name="colgroup">
|
895
923
|
<oneOrMore>
|
@@ -939,7 +967,34 @@
|
|
939
967
|
<define name="concept">
|
940
968
|
<element name="concept">
|
941
969
|
<optional>
|
942
|
-
<attribute name="
|
970
|
+
<attribute name="ital">
|
971
|
+
<data type="boolean"/>
|
972
|
+
</attribute>
|
973
|
+
</optional>
|
974
|
+
<optional>
|
975
|
+
<attribute name="ref">
|
976
|
+
<data type="boolean"/>
|
977
|
+
</attribute>
|
978
|
+
</optional>
|
979
|
+
<optional>
|
980
|
+
<element name="refterm">
|
981
|
+
<zeroOrMore>
|
982
|
+
<choice>
|
983
|
+
<ref name="PureTextElement"/>
|
984
|
+
<ref name="stem"/>
|
985
|
+
</choice>
|
986
|
+
</zeroOrMore>
|
987
|
+
</element>
|
988
|
+
</optional>
|
989
|
+
<optional>
|
990
|
+
<element name="renderterm">
|
991
|
+
<zeroOrMore>
|
992
|
+
<choice>
|
993
|
+
<ref name="PureTextElement"/>
|
994
|
+
<ref name="stem"/>
|
995
|
+
</choice>
|
996
|
+
</zeroOrMore>
|
997
|
+
</element>
|
943
998
|
</optional>
|
944
999
|
<choice>
|
945
1000
|
<ref name="eref"/>
|
@@ -965,6 +1020,9 @@
|
|
965
1020
|
</attribute>
|
966
1021
|
<attribute name="name"/>
|
967
1022
|
<attribute name="action"/>
|
1023
|
+
<optional>
|
1024
|
+
<attribute name="class"/>
|
1025
|
+
</optional>
|
968
1026
|
<zeroOrMore>
|
969
1027
|
<choice>
|
970
1028
|
<ref name="TextElement"/>
|
@@ -1191,13 +1249,17 @@
|
|
1191
1249
|
</define>
|
1192
1250
|
<define name="IsoWorkgroup">
|
1193
1251
|
<optional>
|
1194
|
-
<attribute name="number"
|
1195
|
-
<data type="int"/>
|
1196
|
-
</attribute>
|
1252
|
+
<attribute name="number"/>
|
1197
1253
|
</optional>
|
1198
1254
|
<optional>
|
1199
1255
|
<attribute name="type"/>
|
1200
1256
|
</optional>
|
1257
|
+
<optional>
|
1258
|
+
<attribute name="identifier"/>
|
1259
|
+
</optional>
|
1260
|
+
<optional>
|
1261
|
+
<attribute name="prefix"/>
|
1262
|
+
</optional>
|
1201
1263
|
<text/>
|
1202
1264
|
</define>
|
1203
1265
|
<define name="ics">
|
@@ -1459,26 +1521,26 @@
|
|
1459
1521
|
<optional>
|
1460
1522
|
<ref name="section-title"/>
|
1461
1523
|
</optional>
|
1462
|
-
<
|
1524
|
+
<choice>
|
1463
1525
|
<choice>
|
1464
1526
|
<group>
|
1465
|
-
<
|
1527
|
+
<oneOrMore>
|
1466
1528
|
<ref name="BasicBlock"/>
|
1467
|
-
</
|
1529
|
+
</oneOrMore>
|
1468
1530
|
<zeroOrMore>
|
1469
1531
|
<ref name="note"/>
|
1470
1532
|
</zeroOrMore>
|
1471
1533
|
</group>
|
1472
1534
|
<ref name="amend"/>
|
1473
1535
|
</choice>
|
1474
|
-
<
|
1536
|
+
<oneOrMore>
|
1475
1537
|
<choice>
|
1476
1538
|
<ref name="clause-subsection"/>
|
1477
1539
|
<ref name="terms"/>
|
1478
1540
|
<ref name="definitions"/>
|
1479
1541
|
</choice>
|
1480
|
-
</
|
1481
|
-
</
|
1542
|
+
</oneOrMore>
|
1543
|
+
</choice>
|
1482
1544
|
</define>
|
1483
1545
|
<define name="Annex-Section">
|
1484
1546
|
<optional>
|
@@ -7,7 +7,7 @@ module RelatonBib
|
|
7
7
|
class BibliographicDate
|
8
8
|
TYPES = %w[published accessed created implemented obsoleted confirmed
|
9
9
|
updated issued transmitted copied unchanged circulated adapted
|
10
|
-
vote-started vote-ended].freeze
|
10
|
+
vote-started vote-ended announced].freeze
|
11
11
|
|
12
12
|
# @return [String]
|
13
13
|
attr_reader :type
|
@@ -42,7 +42,7 @@ module RelatonBib
|
|
42
42
|
attr_accessor :all_parts
|
43
43
|
|
44
44
|
# @return [String, NilClass]
|
45
|
-
attr_reader :id, :type, :docnumber, :edition, :doctype
|
45
|
+
attr_reader :id, :type, :docnumber, :edition, :doctype, :subdoctype
|
46
46
|
|
47
47
|
# @!attribute [r] title
|
48
48
|
# @return [RelatonBib::TypedTitleStringCollection]
|
@@ -148,6 +148,7 @@ module RelatonBib
|
|
148
148
|
# @param fetched [Date, NilClass] default nil
|
149
149
|
# @param keyword [Array<String>]
|
150
150
|
# @param doctype [String]
|
151
|
+
# @param subdoctype [String]
|
151
152
|
# @param editorialgroup [RelatonBib::EditorialGroup, nil]
|
152
153
|
# @param ics [Array<RelatonBib::ICS>]
|
153
154
|
# @param structuredidentifier [RelatonBib::StructuredIdentifierCollection]
|
@@ -229,8 +230,9 @@ module RelatonBib
|
|
229
230
|
@status = args[:docstatus]
|
230
231
|
@relation = DocRelationCollection.new(args[:relation] || [])
|
231
232
|
@link = args.fetch(:link, []).map do |s|
|
232
|
-
|
233
|
-
|
233
|
+
case s
|
234
|
+
when Hash then TypedUri.new(**s)
|
235
|
+
when String then TypedUri.new(content: s)
|
234
236
|
else s
|
235
237
|
end
|
236
238
|
end
|
@@ -250,6 +252,7 @@ module RelatonBib
|
|
250
252
|
end
|
251
253
|
@license = args.fetch :license, []
|
252
254
|
@doctype = args[:doctype]
|
255
|
+
@subdoctype = args[:subdoctype]
|
253
256
|
@editorialgroup = args[:editorialgroup]
|
254
257
|
@ics = args.fetch :ics, []
|
255
258
|
@structuredidentifier = args[:structuredidentifier]
|
@@ -260,8 +263,8 @@ module RelatonBib
|
|
260
263
|
# @param hash [Hash]
|
261
264
|
# @return [RelatonBipm::BipmBibliographicItem]
|
262
265
|
def self.from_hash(hash)
|
263
|
-
item_hash = Object.const_get(
|
264
|
-
new
|
266
|
+
item_hash = Object.const_get(name.split("::")[0])::HashConverter.hash_to_bib(hash)
|
267
|
+
new(**item_hash)
|
265
268
|
end
|
266
269
|
|
267
270
|
# @param lang [String] language code Iso639
|
@@ -286,7 +289,7 @@ module RelatonBib
|
|
286
289
|
# contribs = publishers.map { |p| p&.entity&.abbreviation }.join '/'
|
287
290
|
# idstr = "#{contribs}#{delim}#{id.project_number}"
|
288
291
|
# idstr = id.project_number.to_s
|
289
|
-
idstr = id.id.gsub(/:/, "-").gsub
|
292
|
+
idstr = id.id.gsub(/:/, "-").gsub(/\s/, "")
|
290
293
|
# if id.part_number&.size&.positive? then idstr += "-#{id.part_number}"
|
291
294
|
idstr.strip
|
292
295
|
end
|
@@ -299,7 +302,7 @@ module RelatonBib
|
|
299
302
|
def shortref(identifier, **opts) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/AbcSize,Metrics/PerceivedComplexity
|
300
303
|
pubdate = date.select { |d| d.type == "published" }
|
301
304
|
year = if opts[:no_year] || pubdate.empty? then ""
|
302
|
-
else "
|
305
|
+
else ":#{pubdate&.first&.on(:year)}"
|
303
306
|
end
|
304
307
|
year += ": All Parts" if opts[:all_parts] || @all_parts
|
305
308
|
|
@@ -314,7 +317,7 @@ module RelatonBib
|
|
314
317
|
# @return [String] XML
|
315
318
|
def to_xml(**opts, &block)
|
316
319
|
if opts[:builder]
|
317
|
-
render_xml
|
320
|
+
render_xml(**opts, &block)
|
318
321
|
else
|
319
322
|
Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
|
320
323
|
render_xml builder: xml, **opts, &block
|
@@ -361,6 +364,7 @@ module RelatonBib
|
|
361
364
|
hash["keyword"] = single_element_array(keyword) if keyword&.any?
|
362
365
|
hash["license"] = single_element_array(license) if license&.any?
|
363
366
|
hash["doctype"] = doctype if doctype
|
367
|
+
hash["subdoctype"] = subdoctype if subdoctype
|
364
368
|
if editorialgroup&.presence?
|
365
369
|
hash["editorialgroup"] = editorialgroup.to_hash
|
366
370
|
end
|
@@ -460,7 +464,7 @@ module RelatonBib
|
|
460
464
|
me.date = []
|
461
465
|
me.docidentifier.each &:remove_date
|
462
466
|
me.structuredidentifier&.remove_date
|
463
|
-
me.id&.sub!
|
467
|
+
me.id&.sub!(/-[12]\d\d\d/, "")
|
464
468
|
me
|
465
469
|
end
|
466
470
|
|
@@ -477,7 +481,7 @@ module RelatonBib
|
|
477
481
|
# @param prefix [String]
|
478
482
|
# @return [String]
|
479
483
|
def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
480
|
-
pref = prefix.empty? ? prefix : prefix
|
484
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
481
485
|
out = prefix.empty? ? "[%bibitem]\n== {blank}\n" : ""
|
482
486
|
out += "#{pref}id:: #{id}\n" if id
|
483
487
|
out += "#{pref}fetched:: #{fetched}\n" if fetched
|
@@ -513,6 +517,7 @@ module RelatonBib
|
|
513
517
|
out += relation.to_asciibib prefix if relation
|
514
518
|
series.each { |s| out += s.to_asciibib prefix, series.size }
|
515
519
|
out += "#{pref}doctype:: #{doctype}\n" if doctype
|
520
|
+
out += "#{pref}subdoctype:: #{subdoctype}\n" if subdoctype
|
516
521
|
out += "#{pref}formattedref:: #{formattedref}\n" if formattedref
|
517
522
|
keyword.each { |kw| out += kw.to_asciibib "#{pref}keyword", keyword.size }
|
518
523
|
out += editorialgroup.to_asciibib prefix if editorialgroup
|
@@ -682,21 +687,21 @@ module RelatonBib
|
|
682
687
|
root = opts[:bibdata] ? :bibdata : :bibitem
|
683
688
|
xml = opts[:builder].send(root) do |builder|
|
684
689
|
builder.fetched fetched if fetched
|
685
|
-
title.to_xml
|
690
|
+
title.to_xml(**opts)
|
686
691
|
formattedref&.to_xml builder
|
687
692
|
link.each { |s| s.to_xml builder }
|
688
|
-
docidentifier.each { |di| di.to_xml
|
693
|
+
docidentifier.each { |di| di.to_xml(**opts) }
|
689
694
|
builder.docnumber docnumber if docnumber
|
690
695
|
date.each { |d| d.to_xml builder, **opts }
|
691
696
|
contributor.each do |c|
|
692
697
|
builder.contributor do
|
693
|
-
c.role.each { |r| r.to_xml
|
694
|
-
c.to_xml
|
698
|
+
c.role.each { |r| r.to_xml(**opts) }
|
699
|
+
c.to_xml(**opts)
|
695
700
|
end
|
696
701
|
end
|
697
702
|
builder.edition edition if edition
|
698
703
|
version&.to_xml builder
|
699
|
-
biblionote.to_xml
|
704
|
+
biblionote.to_xml(**opts)
|
700
705
|
opts[:note]&.each do |n|
|
701
706
|
builder.note(n[:text], format: "text/plain", type: n[:type])
|
702
707
|
end
|
@@ -706,7 +711,7 @@ module RelatonBib
|
|
706
711
|
abstr = abstract unless abstr.any?
|
707
712
|
abstr.each { |a| builder.abstract { a.to_xml(builder) } }
|
708
713
|
status&.to_xml builder
|
709
|
-
copyright&.each { |c| c.to_xml
|
714
|
+
copyright&.each { |c| c.to_xml(**opts) }
|
710
715
|
relation.each { |r| r.to_xml builder, **opts }
|
711
716
|
series.each { |s| s.to_xml builder }
|
712
717
|
medium&.to_xml builder
|
@@ -724,6 +729,7 @@ module RelatonBib
|
|
724
729
|
structuredidentifier&.presence?)
|
725
730
|
builder.ext do |b|
|
726
731
|
b.doctype doctype if doctype
|
732
|
+
b.subdoctype subdoctype if subdoctype
|
727
733
|
editorialgroup&.to_xml b
|
728
734
|
ics.each { |i| i.to_xml b }
|
729
735
|
structuredidentifier&.to_xml b
|
@@ -42,7 +42,7 @@ module RelatonBib
|
|
42
42
|
# @param prefix [String]
|
43
43
|
# @return [String]
|
44
44
|
def to_asciibib(prefix = "")
|
45
|
-
pref = prefix.empty? ? prefix : prefix
|
45
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
46
46
|
out = "#{pref}docstatus.stage:: #{stage.value}\n"
|
47
47
|
out += "#{pref}docstatus.substage:: #{substage.value}\n" if substage
|
48
48
|
out += "#{pref}docstatus.iteration:: #{iteration}\n" if iteration
|
@@ -54,9 +54,10 @@ module RelatonBib
|
|
54
54
|
# @param stg [RelatonBib::DocumentStatus::Stage, Hash, String, NilClass]
|
55
55
|
# @return [RelatonBib::DocumentStatus::Stage]
|
56
56
|
def stage_new(stg)
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
case stg
|
58
|
+
when Stage then stg
|
59
|
+
when Hash then Stage.new(**stg)
|
60
|
+
when String then Stage.new(value: stg)
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
@@ -27,7 +27,7 @@ module RelatonBib
|
|
27
27
|
# @param prefix [String]
|
28
28
|
# @return [String]
|
29
29
|
def to_asciibib(prefix = "")
|
30
|
-
pref = prefix.empty? ? "editorialgroup" : prefix
|
30
|
+
pref = prefix.empty? ? "editorialgroup" : "#{prefix}.editorialgroup"
|
31
31
|
technical_committee.map do |tc|
|
32
32
|
tc.to_asciibib pref, technical_committee.size
|
33
33
|
end.join
|
@@ -10,7 +10,7 @@ module RelatonBib
|
|
10
10
|
# @param prefix [String]
|
11
11
|
# @return [String]
|
12
12
|
def to_asciibib(prefix = "")
|
13
|
-
pref = prefix.empty? ? "formattedref" : prefix
|
13
|
+
pref = prefix.empty? ? "formattedref" : "#{prefix}.formattedref"
|
14
14
|
super pref
|
15
15
|
end
|
16
16
|
end
|
@@ -107,7 +107,7 @@ module RelatonBib
|
|
107
107
|
ret[:accesslocation] = array(ret[:accesslocation])
|
108
108
|
end
|
109
109
|
|
110
|
-
def dates_hash_to_bib(ret)
|
110
|
+
def dates_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize
|
111
111
|
return unless ret[:date]
|
112
112
|
|
113
113
|
ret[:date] = array(ret[:date])
|
@@ -160,7 +160,7 @@ module RelatonBib
|
|
160
160
|
ret[:docstatus] && ret[:docstatus] = DocumentStatus.new(
|
161
161
|
stage: stage(ret[:docstatus][:stage]),
|
162
162
|
substage: stage(ret[:docstatus][:substage]),
|
163
|
-
iteration: ret[:docstatus][:iteration]
|
163
|
+
iteration: ret[:docstatus][:iteration],
|
164
164
|
)
|
165
165
|
end
|
166
166
|
|
@@ -215,7 +215,7 @@ module RelatonBib
|
|
215
215
|
name: fullname_hash_to_bib(person),
|
216
216
|
affiliation: affiliation_hash_to_bib(person),
|
217
217
|
contact: contacts_hash_to_bib(person),
|
218
|
-
identifier: person_identifiers_hash_to_bib(person)
|
218
|
+
identifier: person_identifiers_hash_to_bib(person),
|
219
219
|
)
|
220
220
|
end
|
221
221
|
|
@@ -227,7 +227,7 @@ module RelatonBib
|
|
227
227
|
addition: array(n[:addition])&.map { |f| localname(f, person) },
|
228
228
|
prefix: array(n[:prefix])&.map { |f| localname(f, person) },
|
229
229
|
surname: localname(n[:surname], person),
|
230
|
-
completename: localname(n[:completename], person)
|
230
|
+
completename: localname(n[:completename], person),
|
231
231
|
)
|
232
232
|
end
|
233
233
|
|
@@ -247,11 +247,11 @@ module RelatonBib
|
|
247
247
|
script: d[:script], format: d[:format] }
|
248
248
|
else { content: d }
|
249
249
|
end
|
250
|
-
FormattedString.new
|
250
|
+
FormattedString.new(**cnt)
|
251
251
|
end
|
252
252
|
Affiliation.new(
|
253
253
|
organization: Organization.new(**org_hash_to_bib(a[:organization])),
|
254
|
-
description: a[:description]
|
254
|
+
description: a[:description],
|
255
255
|
)
|
256
256
|
end
|
257
257
|
end
|
@@ -288,7 +288,7 @@ module RelatonBib
|
|
288
288
|
ret[:relation] = array(ret[:relation])
|
289
289
|
ret[:relation]&.each do |r|
|
290
290
|
if r[:description]
|
291
|
-
r[:description] = FormattedString.new
|
291
|
+
r[:description] = FormattedString.new(**r[:description])
|
292
292
|
end
|
293
293
|
relation_bibitem_hash_to_bib(r)
|
294
294
|
relation_locality_hash_to_bib(r)
|
@@ -309,7 +309,7 @@ module RelatonBib
|
|
309
309
|
# @param item_hash [Hash]
|
310
310
|
# @return [RelatonBib::BibliographicItem]
|
311
311
|
def bib_item(item_hash)
|
312
|
-
BibliographicItem.new
|
312
|
+
BibliographicItem.new(**item_hash)
|
313
313
|
end
|
314
314
|
|
315
315
|
# @param rel [Hash] relation
|
@@ -363,7 +363,7 @@ module RelatonBib
|
|
363
363
|
# @param title [Hash]
|
364
364
|
# @return [RelatonBib::TypedTitleString]
|
365
365
|
def typed_title_strig(title)
|
366
|
-
TypedTitleString.new
|
366
|
+
TypedTitleString.new(**title)
|
367
367
|
end
|
368
368
|
|
369
369
|
# @param ret [Hash]
|
@@ -375,7 +375,7 @@ module RelatonBib
|
|
375
375
|
def classification_hash_to_bib(ret)
|
376
376
|
if ret[:classification]
|
377
377
|
ret[:classification] = array(ret[:classification]).map do |cls|
|
378
|
-
Classification.new
|
378
|
+
Classification.new(**cls)
|
379
379
|
end
|
380
380
|
end
|
381
381
|
end
|
@@ -418,7 +418,7 @@ module RelatonBib
|
|
418
418
|
def ics_hash_to_bib(ret)
|
419
419
|
return unless ret[:ics]
|
420
420
|
|
421
|
-
ret[:ics] = array(ret[:ics]).map { |ics| ICS.new
|
421
|
+
ret[:ics] = array(ret[:ics]).map { |ics| ICS.new(**ics) }
|
422
422
|
end
|
423
423
|
|
424
424
|
# @param ret [Hash]
|
@@ -427,7 +427,7 @@ module RelatonBib
|
|
427
427
|
|
428
428
|
sids = array(ret[:structuredidentifier]).map do |si|
|
429
429
|
si[:agency] = array si[:agency]
|
430
|
-
StructuredIdentifier.new
|
430
|
+
StructuredIdentifier.new(**si)
|
431
431
|
end
|
432
432
|
ret[:structuredidentifier] = StructuredIdentifierCollection.new sids
|
433
433
|
end
|
@@ -435,15 +435,14 @@ module RelatonBib
|
|
435
435
|
# @param ogj [Hash, Array, String]
|
436
436
|
# @return [Hash, Array, String]
|
437
437
|
def symbolize(obj)
|
438
|
-
|
438
|
+
case obj
|
439
|
+
when Hash
|
439
440
|
obj.reduce({}) do |memo, (k, v)|
|
440
441
|
memo[k.to_sym] = symbolize(v)
|
441
442
|
memo
|
442
443
|
end
|
443
|
-
|
444
|
-
|
445
|
-
else
|
446
|
-
obj
|
444
|
+
when Array then obj.reduce([]) { |memo, v| memo << symbolize(v) }
|
445
|
+
else obj
|
447
446
|
end
|
448
447
|
end
|
449
448
|
|
@@ -459,7 +458,7 @@ module RelatonBib
|
|
459
458
|
# @param name [Hash, String, NilClass]
|
460
459
|
# @param person [Hash]
|
461
460
|
# @return [RelatonBib::LocalizedString]
|
462
|
-
def localname(name, person) # rubocop:disable Metrics/CyclomaticComplexity
|
461
|
+
def localname(name, person) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/AbcSize
|
463
462
|
return nil if name.nil?
|
464
463
|
|
465
464
|
lang = name[:language] if name.is_a?(Hash)
|
data/lib/relaton_bib/hit.rb
CHANGED
@@ -21,10 +21,10 @@ module RelatonBib
|
|
21
21
|
# @return [String]
|
22
22
|
def inspect
|
23
23
|
"<#{self.class}:#{format('%<id>#.14x', id: object_id << 1)} "\
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
"@text=\"#{@hit_collection&.text}\" "\
|
25
|
+
"@fetched=\"#{!@fetch.nil?}\" "\
|
26
|
+
"@fullIdentifier=\"#{@fetch&.shortref(nil)}\" "\
|
27
|
+
"@title=\"#{@hit[:code]}\">"
|
28
28
|
end
|
29
29
|
|
30
30
|
def fetch
|
@@ -38,10 +38,10 @@ module RelatonBib
|
|
38
38
|
# @return [String] XML
|
39
39
|
def to_xml(**opts)
|
40
40
|
if opts[:builder]
|
41
|
-
fetch.to_xml
|
41
|
+
fetch.to_xml(**opts)
|
42
42
|
else
|
43
43
|
builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
|
44
|
-
fetch.to_xml
|
44
|
+
fetch.to_xml(**opts.merge(builder: xml))
|
45
45
|
end
|
46
46
|
builder.doc.root.to_xml
|
47
47
|
end
|
@@ -40,7 +40,7 @@ module RelatonBib
|
|
40
40
|
# @return [String]
|
41
41
|
def to_asciibib(prefix = "", count = 1)
|
42
42
|
pref = prefix.empty? ? prefix : prefix + "."
|
43
|
-
out = count > 1 ? "#{pref}identifier::\
|
43
|
+
out = count > 1 ? "#{pref}identifier::\n" : ""
|
44
44
|
out += "#{pref}identifier.type:: #{type}\n"
|
45
45
|
out += "#{pref}identifier.value:: #{value}\n"
|
46
46
|
out
|
@@ -119,7 +119,7 @@ module RelatonBib
|
|
119
119
|
# @return [String]
|
120
120
|
def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
|
121
121
|
pref = prefix.sub /\*$/, "organization"
|
122
|
-
out = count > 1 ? "#{pref}::\
|
122
|
+
out = count > 1 ? "#{pref}::\n" : ""
|
123
123
|
name.each { |n| out += n.to_asciibib "#{pref}.name", name.size }
|
124
124
|
out += abbreviation.to_asciibib "#{pref}.abbreviation" if abbreviation
|
125
125
|
subdivision.each do |sd|
|
data/lib/relaton_bib/version.rb
CHANGED
@@ -1,45 +1,57 @@
|
|
1
1
|
module RelatonBib
|
2
2
|
class WorkGroup
|
3
3
|
# @return [String]
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :name
|
5
5
|
|
6
6
|
# @return [Integer, nil]
|
7
7
|
attr_reader :number
|
8
8
|
|
9
9
|
# @return [String, nil]
|
10
|
-
attr_reader :type
|
10
|
+
attr_reader :identifier, :prefix, :type
|
11
11
|
|
12
|
-
# @param
|
12
|
+
# @param name [String]
|
13
|
+
# @param identifier [String, nil]
|
14
|
+
# @param prefix [String, nil]
|
13
15
|
# @param number [Integer, nil]
|
14
16
|
# @param type [String, nil]
|
15
|
-
def initialize(
|
16
|
-
@
|
17
|
+
def initialize(name:, identifier: nil, prefix: nil, number: nil, type: nil)
|
18
|
+
@identifier = identifier
|
19
|
+
@prefix = prefix
|
20
|
+
@name = name
|
17
21
|
@number = number
|
18
22
|
@type = type
|
19
23
|
end
|
20
24
|
|
21
25
|
# @param builder [Nokogiri::XML::Builder]
|
22
|
-
def to_xml(builder)
|
23
|
-
builder.text
|
26
|
+
def to_xml(builder) # rubocop:disable Metrics/AbcSize
|
27
|
+
builder.text name
|
24
28
|
builder.parent[:number] = number if number
|
25
29
|
builder.parent[:type] = type if type
|
30
|
+
builder.parent[:identifier] = identifier if identifier
|
31
|
+
builder.parent[:prefix] = prefix if prefix
|
26
32
|
end
|
27
33
|
|
28
34
|
# @return [Hash]
|
29
35
|
def to_hash
|
30
|
-
hash = { "
|
36
|
+
hash = { "name" => name }
|
31
37
|
hash["number"] = number if number
|
32
38
|
hash["type"] = type if type
|
39
|
+
hash["identifier"] = identifier if identifier
|
40
|
+
hash["prefix"] = prefix if prefix
|
33
41
|
hash
|
34
42
|
end
|
35
43
|
|
36
|
-
# @param
|
44
|
+
# @param prfx [String]
|
45
|
+
# @param count [Integer]
|
37
46
|
# @return [String]
|
38
|
-
def to_asciibib(
|
39
|
-
pref =
|
40
|
-
out = "#{pref}
|
47
|
+
def to_asciibib(prfx = "", count = 1) # rubocop:disable Metrics/CyclomaticComplexity
|
48
|
+
pref = prfx.empty? ? prfx : "#{prfx}."
|
49
|
+
out = count > 1 ? "#{pref}::\n" : ""
|
50
|
+
out += "#{pref}name:: #{name}\n"
|
41
51
|
out += "#{pref}number:: #{number}\n" if number
|
42
52
|
out += "#{pref}type:: #{type}\n" if type
|
53
|
+
out += "#{pref}identifier:: #{identifier}\n" if identifier
|
54
|
+
out += "#{pref}prefix:: #{prefix}\n" if prefix
|
43
55
|
out
|
44
56
|
end
|
45
57
|
end
|
@@ -52,6 +52,7 @@ module RelatonBib
|
|
52
52
|
license: bibitem.xpath("license").map(&:text),
|
53
53
|
validity: fetch_validity(bibitem),
|
54
54
|
doctype: ext&.at("doctype")&.text,
|
55
|
+
subdoctype: ext&.at("subdoctype")&.text,
|
55
56
|
editorialgroup: fetch_editorialgroup(ext),
|
56
57
|
ics: fetch_ics(ext),
|
57
58
|
structuredidentifier: fetch_structuredidentifier(ext),
|
@@ -81,7 +82,7 @@ module RelatonBib
|
|
81
82
|
type: n[:type],
|
82
83
|
format: n[:format],
|
83
84
|
language: n[:language],
|
84
|
-
script: n[:script]
|
85
|
+
script: n[:script],
|
85
86
|
)
|
86
87
|
end
|
87
88
|
BiblioNoteCollection.new bnotes
|
@@ -201,7 +202,7 @@ module RelatonBib
|
|
201
202
|
DocumentStatus.new(
|
202
203
|
stage: stg ? stage(stg) : status.text,
|
203
204
|
substage: stage(status.at("substage")),
|
204
|
-
iteration: status.at("iteration")&.text
|
205
|
+
iteration: status.at("iteration")&.text,
|
205
206
|
)
|
206
207
|
end
|
207
208
|
|
@@ -262,7 +263,7 @@ module RelatonBib
|
|
262
263
|
city: c.at("./city")&.text,
|
263
264
|
state: c.at("./state")&.text,
|
264
265
|
country: c.at("./country")&.text,
|
265
|
-
postcode: c.at("./postcode")&.text
|
266
|
+
postcode: c.at("./postcode")&.text,
|
266
267
|
)
|
267
268
|
else
|
268
269
|
Contact.new(type: c.name, value: c.text)
|
@@ -290,7 +291,7 @@ module RelatonBib
|
|
290
291
|
name: name,
|
291
292
|
affiliation: affiliations,
|
292
293
|
contact: contact,
|
293
|
-
identifier: identifier
|
294
|
+
identifier: identifier,
|
294
295
|
)
|
295
296
|
end
|
296
297
|
|
@@ -358,7 +359,7 @@ module RelatonBib
|
|
358
359
|
description: relation_description(rel),
|
359
360
|
bibitem: bib_item(item_data(rel.at("./bibitem"))),
|
360
361
|
locality: localities(rel),
|
361
|
-
source_locality: source_localities(rel)
|
362
|
+
source_locality: source_localities(rel),
|
362
363
|
)
|
363
364
|
end
|
364
365
|
end
|
@@ -376,7 +377,7 @@ module RelatonBib
|
|
376
377
|
# @param item_hash [Hash]
|
377
378
|
# @return [RelatonBib::BibliographicItem]
|
378
379
|
def bib_item(item_hash)
|
379
|
-
BibliographicItem.new
|
380
|
+
BibliographicItem.new(**item_hash)
|
380
381
|
end
|
381
382
|
|
382
383
|
# @param rel [Nokogiri::XML::Element]
|
@@ -398,7 +399,7 @@ module RelatonBib
|
|
398
399
|
klass.new(
|
399
400
|
loc[:type],
|
400
401
|
LocalizedString.new(loc.at("./referenceFrom").text),
|
401
|
-
ref_to
|
402
|
+
ref_to,
|
402
403
|
)
|
403
404
|
end
|
404
405
|
|
@@ -436,8 +437,10 @@ module RelatonBib
|
|
436
437
|
return unless ext && (eg = ext.at "editorialgroup")
|
437
438
|
|
438
439
|
eg = eg.xpath("technical-committee").map do |tc|
|
439
|
-
wg = WorkGroup.new(
|
440
|
-
|
440
|
+
wg = WorkGroup.new(
|
441
|
+
name: tc.text, number: tc[:number]&.to_i, type: tc[:type],
|
442
|
+
identifier: tc[:identifier], prefix: tc[:prefix]
|
443
|
+
)
|
441
444
|
TechnicalCommittee.new wg
|
442
445
|
end
|
443
446
|
EditorialGroup.new eg if eg.any?
|
@@ -468,7 +471,7 @@ module RelatonBib
|
|
468
471
|
supplementtype: si.at("supplementtype")&.text,
|
469
472
|
supplementnumber: si.at("supplementnumber")&.text,
|
470
473
|
language: si.at("language")&.text,
|
471
|
-
year: si.at("year")&.text
|
474
|
+
year: si.at("year")&.text,
|
472
475
|
)
|
473
476
|
end
|
474
477
|
StructuredIdentifierCollection.new sids
|
data/lib/relaton_bib.rb
CHANGED
@@ -39,11 +39,11 @@ module RelatonBib
|
|
39
39
|
|
40
40
|
# @param array [Array]
|
41
41
|
# @return [Array<String>, String]
|
42
|
-
def single_element_array(array)
|
42
|
+
def single_element_array(array)
|
43
43
|
if array.size > 1
|
44
44
|
array.map { |e| e.is_a?(String) ? e : e.to_hash }
|
45
45
|
else
|
46
|
-
array.first
|
46
|
+
array.first.is_a?(String) ? array[0] : array.first&.to_hash
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
data/relaton-bib.gemspec
CHANGED
@@ -21,14 +21,12 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.bindir = "exe"
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
24
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
25
25
|
|
26
26
|
spec.add_development_dependency "byebug"
|
27
|
-
# ec.add_development_dependency "debase"
|
28
27
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
29
28
|
spec.add_development_dependency "rake", "~> 13.0"
|
30
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
-
# spec.add_development_dependency "ruby-debug-ide"
|
32
30
|
spec.add_development_dependency "ruby-jing"
|
33
31
|
spec.add_development_dependency "simplecov"
|
34
32
|
|
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.9.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: 2021-
|
11
|
+
date: 2021-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -226,7 +226,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
226
226
|
requirements:
|
227
227
|
- - ">="
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: 2.
|
229
|
+
version: 2.5.0
|
230
230
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
231
231
|
requirements:
|
232
232
|
- - ">="
|