relaton-bib 1.13.15 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +95 -115
- data/grammars/basicdoc.rng +3 -27
- data/grammars/biblio-compile.rng +11 -0
- data/grammars/biblio-standoc.rng +164 -0
- data/grammars/biblio.rng +75 -19
- data/grammars/versions.json +31 -0
- data/lib/relaton_bib/bibliographic_item.rb +31 -9
- data/lib/relaton_bib/document_relation.rb +1 -1
- data/lib/relaton_bib/hit_collection.rb +31 -6
- data/lib/relaton_bib/version.rb +1 -1
- metadata +9 -8
- data/grammars/isodoc.rng +0 -2807
- data/grammars/reqt.rng +0 -223
data/grammars/biblio.rng
CHANGED
@@ -33,9 +33,10 @@
|
|
33
33
|
<param name="pattern">([\+\-]?\d{4})((-?)((0[1-9]|1[0-2])((-?)([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6]))))?</param>
|
34
34
|
</data>
|
35
35
|
</define>
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
<!-- start = bibitem -->
|
37
|
+
<define name="BibData">
|
38
|
+
<ref name="BibliographicItem"/>
|
39
|
+
</define>
|
39
40
|
<define name="status">
|
40
41
|
<element name="status">
|
41
42
|
<ref name="stage"/>
|
@@ -73,8 +74,14 @@
|
|
73
74
|
<text/>
|
74
75
|
</element>
|
75
76
|
</define>
|
76
|
-
<define name="
|
77
|
+
<define name="locale">
|
77
78
|
<a:documentation>ISO-639</a:documentation>
|
79
|
+
<element name="locale">
|
80
|
+
<text/>
|
81
|
+
</element>
|
82
|
+
</define>
|
83
|
+
<define name="script">
|
84
|
+
<a:documentation>ISO-3166</a:documentation>
|
78
85
|
<element name="script">
|
79
86
|
<text/>
|
80
87
|
</element>
|
@@ -93,6 +100,9 @@
|
|
93
100
|
<!-- multiple languages and scripts possible: comma delimit them if so -->
|
94
101
|
<attribute name="language"/>
|
95
102
|
</optional>
|
103
|
+
<optional>
|
104
|
+
<attribute name="locale"/>
|
105
|
+
</optional>
|
96
106
|
<optional>
|
97
107
|
<attribute name="script"/>
|
98
108
|
</optional>
|
@@ -136,6 +146,9 @@
|
|
136
146
|
<!-- multiple languages and scripts possible: comma delimit them if so -->
|
137
147
|
<attribute name="language"/>
|
138
148
|
</optional>
|
149
|
+
<optional>
|
150
|
+
<attribute name="locale"/>
|
151
|
+
</optional>
|
139
152
|
<optional>
|
140
153
|
<attribute name="script"/>
|
141
154
|
</optional>
|
@@ -158,27 +171,30 @@
|
|
158
171
|
</define>
|
159
172
|
<define name="contributor">
|
160
173
|
<element name="contributor">
|
161
|
-
<
|
174
|
+
<oneOrMore>
|
162
175
|
<ref name="role"/>
|
163
|
-
</
|
176
|
+
</oneOrMore>
|
164
177
|
<ref name="ContributorInfo"/>
|
165
178
|
</element>
|
166
179
|
</define>
|
167
180
|
<define name="role">
|
168
181
|
<element name="role">
|
169
|
-
<
|
170
|
-
<
|
171
|
-
<
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
</
|
180
|
-
|
181
|
-
|
182
|
+
<attribute name="type">
|
183
|
+
<choice>
|
184
|
+
<value>author</value>
|
185
|
+
<value>performer</value>
|
186
|
+
<value>publisher</value>
|
187
|
+
<value>editor</value>
|
188
|
+
<value>adapter</value>
|
189
|
+
<value>translator</value>
|
190
|
+
<value>distributor</value>
|
191
|
+
<value>realizer</value>
|
192
|
+
<value>owner</value>
|
193
|
+
<value>authorizer</value>
|
194
|
+
<value>enabler</value>
|
195
|
+
<value>subject</value>
|
196
|
+
</choice>
|
197
|
+
</attribute>
|
182
198
|
<zeroOrMore>
|
183
199
|
<ref name="roledescription"/>
|
184
200
|
</zeroOrMore>
|
@@ -500,6 +516,17 @@
|
|
500
516
|
</define>
|
501
517
|
<define name="localityStack">
|
502
518
|
<element name="localityStack">
|
519
|
+
<optional>
|
520
|
+
<attribute name="connective">
|
521
|
+
<choice>
|
522
|
+
<value>and</value>
|
523
|
+
<value>or</value>
|
524
|
+
<value>from</value>
|
525
|
+
<value>to</value>
|
526
|
+
<value/>
|
527
|
+
</choice>
|
528
|
+
</attribute>
|
529
|
+
</optional>
|
503
530
|
<zeroOrMore>
|
504
531
|
<ref name="locality"/>
|
505
532
|
</zeroOrMore>
|
@@ -512,6 +539,17 @@
|
|
512
539
|
</define>
|
513
540
|
<define name="sourceLocalityStack">
|
514
541
|
<element name="sourceLocalityStack">
|
542
|
+
<optional>
|
543
|
+
<attribute name="connective">
|
544
|
+
<choice>
|
545
|
+
<value>and</value>
|
546
|
+
<value>or</value>
|
547
|
+
<value>from</value>
|
548
|
+
<value>to</value>
|
549
|
+
<value/>
|
550
|
+
</choice>
|
551
|
+
</attribute>
|
552
|
+
</optional>
|
515
553
|
<zeroOrMore>
|
516
554
|
<ref name="sourceLocality"/>
|
517
555
|
</zeroOrMore>
|
@@ -614,6 +652,9 @@
|
|
614
652
|
<ref name="BibItemType"/>
|
615
653
|
</attribute>
|
616
654
|
</optional>
|
655
|
+
<optional>
|
656
|
+
<attribute name="schema-version"/>
|
657
|
+
</optional>
|
617
658
|
<optional>
|
618
659
|
<ref name="fetched"/>
|
619
660
|
</optional>
|
@@ -650,6 +691,9 @@
|
|
650
691
|
<zeroOrMore>
|
651
692
|
<ref name="language"/>
|
652
693
|
</zeroOrMore>
|
694
|
+
<zeroOrMore>
|
695
|
+
<ref name="locale"/>
|
696
|
+
</zeroOrMore>
|
653
697
|
<zeroOrMore>
|
654
698
|
<ref name="script"/>
|
655
699
|
</zeroOrMore>
|
@@ -705,6 +749,9 @@
|
|
705
749
|
<ref name="BibItemType"/>
|
706
750
|
</attribute>
|
707
751
|
</optional>
|
752
|
+
<optional>
|
753
|
+
<attribute name="schema-version"/>
|
754
|
+
</optional>
|
708
755
|
<optional>
|
709
756
|
<ref name="fetched"/>
|
710
757
|
</optional>
|
@@ -741,6 +788,9 @@
|
|
741
788
|
<zeroOrMore>
|
742
789
|
<ref name="language"/>
|
743
790
|
</zeroOrMore>
|
791
|
+
<zeroOrMore>
|
792
|
+
<ref name="locale"/>
|
793
|
+
</zeroOrMore>
|
744
794
|
<zeroOrMore>
|
745
795
|
<ref name="script"/>
|
746
796
|
</zeroOrMore>
|
@@ -857,6 +907,9 @@
|
|
857
907
|
<optional>
|
858
908
|
<attribute name="language"/>
|
859
909
|
</optional>
|
910
|
+
<optional>
|
911
|
+
<attribute name="locale"/>
|
912
|
+
</optional>
|
860
913
|
<optional>
|
861
914
|
<attribute name="script"/>
|
862
915
|
</optional>
|
@@ -937,6 +990,9 @@
|
|
937
990
|
<optional>
|
938
991
|
<attribute name="language"/>
|
939
992
|
</optional>
|
993
|
+
<optional>
|
994
|
+
<attribute name="locale"/>
|
995
|
+
</optional>
|
940
996
|
<optional>
|
941
997
|
<attribute name="script"/>
|
942
998
|
</optional>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
{
|
2
|
+
"relaton-models": "v1.2.1",
|
3
|
+
"basicdoc-models": "v1.0.1",
|
4
|
+
"metanorma-requirements-models": "v1.0.0",
|
5
|
+
"relaton-model-ieee": "v1.0.0",
|
6
|
+
"relaton-model-iso": "v1.0.0",
|
7
|
+
"relaton-model-iec": "v1.0.0",
|
8
|
+
"relaton-model-bsi": "v1.0.0",
|
9
|
+
"relaton-model-gb": "v1.0.0",
|
10
|
+
"relaton-model-mpfa": "v1.0.0",
|
11
|
+
"relaton-model-bipm": "v1.0.0",
|
12
|
+
"relaton-model-w3c": "v1.0.0",
|
13
|
+
"relaton-model-3gpp": "v1.0.1",
|
14
|
+
"relaton-model-csa": "v1.0.0",
|
15
|
+
"relaton-model-cc": "v1.0.0",
|
16
|
+
"relaton-model-ietf": "v1.0.0",
|
17
|
+
"relaton-model-iho": "v1.0.0",
|
18
|
+
"relaton-model-itu": "v1.0.0",
|
19
|
+
"relaton-model-m3aawg": "v1.0.0",
|
20
|
+
"relaton-model-nist": "v1.0.0",
|
21
|
+
"relaton-model-ribose": "v1.0.0",
|
22
|
+
"relaton-model-ogc": "v1.0.1",
|
23
|
+
"relaton-model-un": "v1.0.0",
|
24
|
+
"relaton-model-cen": "v1.0.1",
|
25
|
+
"relaton-model-ecma": "v1.0.0",
|
26
|
+
"relaton-model-cie": "v1.0.0",
|
27
|
+
"relaton-model-iana": "v1.0.0",
|
28
|
+
"relaton-model-omg": "v1.0.0",
|
29
|
+
"relaton-model-oasis": "v1.0.0",
|
30
|
+
"date": "2022-12-01T15:03:50Z"
|
31
|
+
}
|
@@ -286,6 +286,24 @@ module RelatonBib
|
|
286
286
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
287
287
|
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
288
288
|
|
289
|
+
#
|
290
|
+
# Fetch schema version
|
291
|
+
#
|
292
|
+
# @return [String] schema version
|
293
|
+
#
|
294
|
+
def schema
|
295
|
+
@schema ||= schema_versions["relaton-models"]
|
296
|
+
end
|
297
|
+
|
298
|
+
#
|
299
|
+
# Read schema versions from file
|
300
|
+
#
|
301
|
+
# @return [Hash{String=>String}] schema versions
|
302
|
+
#
|
303
|
+
def schema_versions
|
304
|
+
JSON.parse File.read(File.join(__dir__, "../../grammars/versions.json"))
|
305
|
+
end
|
306
|
+
|
289
307
|
# @param hash [Hash]
|
290
308
|
# @return [RelatonBipm::BipmBibliographicItem]
|
291
309
|
def self.from_hash(hash)
|
@@ -303,19 +321,19 @@ module RelatonBib
|
|
303
321
|
end
|
304
322
|
end
|
305
323
|
|
306
|
-
# @param
|
307
|
-
# @param attribute [
|
324
|
+
# @param identifier [RelatonBib::DocumentIdentifier]
|
325
|
+
# @param attribute [Boolean, nil]
|
308
326
|
# @return [String]
|
309
|
-
def makeid(
|
327
|
+
def makeid(identifier, attribute)
|
310
328
|
return nil if attribute && !@id_attribute
|
311
329
|
|
312
|
-
|
313
|
-
return unless
|
330
|
+
identifier ||= @docidentifier.reject { |i| i.type == "DOI" }[0]
|
331
|
+
return unless identifier
|
314
332
|
|
315
333
|
# contribs = publishers.map { |p| p&.entity&.abbreviation }.join '/'
|
316
334
|
# idstr = "#{contribs}#{delim}#{id.project_number}"
|
317
335
|
# idstr = id.project_number.to_s
|
318
|
-
idstr =
|
336
|
+
idstr = identifier.id.gsub(/[:\/]/, "-").gsub(/\s/, "")
|
319
337
|
# if id.part_number&.size&.positive? then idstr += "-#{id.part_number}"
|
320
338
|
idstr.strip
|
321
339
|
end
|
@@ -370,8 +388,9 @@ module RelatonBib
|
|
370
388
|
end
|
371
389
|
|
372
390
|
# @return [Hash]
|
373
|
-
def to_hash # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
391
|
+
def to_hash(embedded: false) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
374
392
|
hash = {}
|
393
|
+
hash["schema-version"] = schema unless embedded
|
375
394
|
hash["id"] = id if id
|
376
395
|
hash["title"] = title.to_hash if title&.any?
|
377
396
|
hash["link"] = single_element_array(link) if link&.any?
|
@@ -417,6 +436,7 @@ module RelatonBib
|
|
417
436
|
if structuredidentifier&.presence?
|
418
437
|
hash["structuredidentifier"] = structuredidentifier.to_hash
|
419
438
|
end
|
439
|
+
hash["ext"] = { "schema-version" => ext_schema } if !embedded && respond_to?(:ext_schema)
|
420
440
|
hash
|
421
441
|
end
|
422
442
|
|
@@ -733,7 +753,7 @@ module RelatonBib
|
|
733
753
|
# @option opts [String] :lang language
|
734
754
|
def render_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
735
755
|
root = opts[:bibdata] ? :bibdata : :bibitem
|
736
|
-
xml = opts[:builder].send(root) do |builder|
|
756
|
+
xml = opts[:builder].send(root) do |builder| # rubocop:disable Metrics/BlockLength
|
737
757
|
builder.fetched fetched if fetched
|
738
758
|
title.to_xml(**opts)
|
739
759
|
formattedref&.to_xml builder
|
@@ -776,17 +796,19 @@ module RelatonBib
|
|
776
796
|
if block_given? then yield builder
|
777
797
|
elsif opts[:bibdata] && (doctype || editorialgroup || ics&.any? ||
|
778
798
|
structuredidentifier&.presence?)
|
779
|
-
builder.ext do |b|
|
799
|
+
ext = builder.ext do |b|
|
780
800
|
b.doctype doctype if doctype
|
781
801
|
b.subdoctype subdoctype if subdoctype
|
782
802
|
editorialgroup&.to_xml b
|
783
803
|
ics.each { |i| i.to_xml b }
|
784
804
|
structuredidentifier&.to_xml b
|
785
805
|
end
|
806
|
+
ext["schema-version"] = ext_schema if !opts[:embedded] && respond_to?(:ext_schema)
|
786
807
|
end
|
787
808
|
end
|
788
809
|
xml[:id] = id if id && !opts[:bibdata] && !opts[:embedded]
|
789
810
|
xml[:type] = type if type
|
811
|
+
xml["schema-version"] = schema unless opts[:embedded]
|
790
812
|
xml
|
791
813
|
end
|
792
814
|
|
@@ -72,7 +72,7 @@ module RelatonBib
|
|
72
72
|
|
73
73
|
# @return [Hash]
|
74
74
|
def to_hash # rubocop:disable Metrics/AbcSize
|
75
|
-
hash = { "type" => type, "bibitem" => bibitem.to_hash }
|
75
|
+
hash = { "type" => type, "bibitem" => bibitem.to_hash(embedded: true) }
|
76
76
|
hash["description"] = description.to_hash if description
|
77
77
|
hash["locality"] = single_element_array(locality) if locality&.any?
|
78
78
|
if source_locality&.any?
|
@@ -24,7 +24,11 @@ module RelatonBib
|
|
24
24
|
@fetched = false
|
25
25
|
end
|
26
26
|
|
27
|
-
#
|
27
|
+
#
|
28
|
+
# Fetches hits from the data source
|
29
|
+
#
|
30
|
+
# @return [self] self object
|
31
|
+
#
|
28
32
|
def fetch
|
29
33
|
workers = WorkersPool.new 4
|
30
34
|
workers.worker(&:fetch)
|
@@ -37,23 +41,35 @@ module RelatonBib
|
|
37
41
|
self
|
38
42
|
end
|
39
43
|
|
40
|
-
#
|
44
|
+
#
|
45
|
+
# Renders the collection as XML
|
46
|
+
#
|
47
|
+
# @param opts [Hash] options
|
41
48
|
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
42
|
-
# @option opts [Boolean] :bibdata
|
49
|
+
# @option opts [Boolean] :bibdata render bibdata if true
|
43
50
|
# @option opts [String, Symbol] :lang language
|
44
|
-
#
|
51
|
+
#
|
52
|
+
# @return [String] XML representation of the collection
|
53
|
+
#
|
45
54
|
def to_xml(**opts)
|
46
55
|
builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
|
47
56
|
xml.documents do
|
48
57
|
@array.each do |hit|
|
49
58
|
hit.fetch
|
50
|
-
hit.to_xml
|
59
|
+
hit.to_xml(**opts.merge(builder: xml))
|
51
60
|
end
|
52
61
|
end
|
53
62
|
end
|
54
63
|
builder.to_xml
|
55
64
|
end
|
56
65
|
|
66
|
+
#
|
67
|
+
# Selects matching hits and returns a new collection
|
68
|
+
#
|
69
|
+
# @param [Proc] &block proc to select hits
|
70
|
+
#
|
71
|
+
# @return [RelatonBib::HitCollection] new hit collection
|
72
|
+
#
|
57
73
|
def select(&block)
|
58
74
|
me = deep_dup
|
59
75
|
array_dup = instance_variable_get(:@array).deep_dup
|
@@ -67,11 +83,20 @@ module RelatonBib
|
|
67
83
|
self
|
68
84
|
end
|
69
85
|
|
86
|
+
#
|
87
|
+
# Returns String representation of the collection
|
88
|
+
#
|
89
|
+
# @return [String] String representation of the collection
|
90
|
+
#
|
70
91
|
def to_s
|
71
92
|
inspect
|
72
93
|
end
|
73
94
|
|
74
|
-
#
|
95
|
+
#
|
96
|
+
# Returns String representation of the collection
|
97
|
+
#
|
98
|
+
# @return [String] String representation of the collection
|
99
|
+
#
|
75
100
|
def inspect
|
76
101
|
"<#{self.class}:#{format('%#.14x', object_id << 1)} @ref=#{@text} @fetched=#{@fetched}>"
|
77
102
|
end
|
data/lib/relaton_bib/version.rb
CHANGED
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.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -229,9 +229,10 @@ files:
|
|
229
229
|
- bin/setup
|
230
230
|
- docs/hash.adoc
|
231
231
|
- grammars/basicdoc.rng
|
232
|
+
- grammars/biblio-compile.rng
|
233
|
+
- grammars/biblio-standoc.rng
|
232
234
|
- grammars/biblio.rng
|
233
|
-
- grammars/
|
234
|
-
- grammars/reqt.rng
|
235
|
+
- grammars/versions.json
|
235
236
|
- lib/relaton_bib.rb
|
236
237
|
- lib/relaton_bib/bib_item_locality.rb
|
237
238
|
- lib/relaton_bib/biblio_note.rb
|
@@ -280,7 +281,7 @@ homepage: https://github.com/relaton/relaton-bib
|
|
280
281
|
licenses:
|
281
282
|
- BSD-2-Clause
|
282
283
|
metadata: {}
|
283
|
-
post_install_message:
|
284
|
+
post_install_message:
|
284
285
|
rdoc_options: []
|
285
286
|
require_paths:
|
286
287
|
- lib
|
@@ -295,8 +296,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
295
296
|
- !ruby/object:Gem::Version
|
296
297
|
version: '0'
|
297
298
|
requirements: []
|
298
|
-
rubygems_version: 3.
|
299
|
-
signing_key:
|
299
|
+
rubygems_version: 3.1.6
|
300
|
+
signing_key:
|
300
301
|
specification_version: 4
|
301
302
|
summary: 'RelatonBib: Ruby XMLDOC impementation.'
|
302
303
|
test_files: []
|