relaton-bib 1.7.1 → 1.8.0
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 +4 -4
- data/.github/workflows/rake.yml +46 -0
- data/README.adoc +2 -8
- data/grammars/basicdoc.rng +165 -20
- data/grammars/biblio.rng +4 -6
- data/grammars/isodoc.rng +460 -6
- data/grammars/reqt.rng +31 -2
- data/lib/relaton_bib/bib_item_locality.rb +1 -1
- data/lib/relaton_bib/bibliographic_item.rb +12 -5
- data/lib/relaton_bib/bibtex_parser.rb +2 -2
- data/lib/relaton_bib/copyright_association.rb +1 -1
- data/lib/relaton_bib/document_relation.rb +1 -1
- data/lib/relaton_bib/document_relation_collection.rb +1 -1
- data/lib/relaton_bib/document_status.rb +2 -1
- data/lib/relaton_bib/formatted_string.rb +1 -1
- data/lib/relaton_bib/hash_converter.rb +14 -14
- data/lib/relaton_bib/ics.rb +12 -7
- data/lib/relaton_bib/organization.rb +7 -7
- data/lib/relaton_bib/person.rb +8 -4
- data/lib/relaton_bib/series.rb +4 -4
- data/lib/relaton_bib/typed_title_string.rb +3 -3
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +4 -4
- data/relaton-bib.gemspec +3 -3
- metadata +6 -36
- data/.github/workflows/macos.yml +0 -40
- data/.github/workflows/ubuntu.yml +0 -39
- data/.github/workflows/windows.yml +0 -41
data/grammars/reqt.rng
CHANGED
@@ -30,15 +30,34 @@
|
|
30
30
|
<data type="boolean"/>
|
31
31
|
</attribute>
|
32
32
|
</optional>
|
33
|
+
<optional>
|
34
|
+
<attribute name="number"/>
|
35
|
+
</optional>
|
33
36
|
<optional>
|
34
37
|
<attribute name="subsequence"/>
|
35
38
|
</optional>
|
39
|
+
<optional>
|
40
|
+
<attribute name="keep-with-next">
|
41
|
+
<data type="boolean"/>
|
42
|
+
</attribute>
|
43
|
+
</optional>
|
44
|
+
<optional>
|
45
|
+
<attribute name="keep-lines-together">
|
46
|
+
<data type="boolean"/>
|
47
|
+
</attribute>
|
48
|
+
</optional>
|
36
49
|
<attribute name="id">
|
37
50
|
<data type="ID"/>
|
38
51
|
</attribute>
|
39
52
|
<optional>
|
40
53
|
<attribute name="filename"/>
|
41
54
|
</optional>
|
55
|
+
<optional>
|
56
|
+
<attribute name="model"/>
|
57
|
+
</optional>
|
58
|
+
<optional>
|
59
|
+
<attribute name="type"/>
|
60
|
+
</optional>
|
42
61
|
<optional>
|
43
62
|
<ref name="reqtitle"/>
|
44
63
|
</optional>
|
@@ -48,9 +67,9 @@
|
|
48
67
|
<optional>
|
49
68
|
<ref name="subject"/>
|
50
69
|
</optional>
|
51
|
-
<
|
70
|
+
<zeroOrMore>
|
52
71
|
<ref name="reqinherit"/>
|
53
|
-
</
|
72
|
+
</zeroOrMore>
|
54
73
|
<zeroOrMore>
|
55
74
|
<ref name="classification"/>
|
56
75
|
</zeroOrMore>
|
@@ -135,6 +154,16 @@
|
|
135
154
|
<data type="boolean"/>
|
136
155
|
</attribute>
|
137
156
|
</optional>
|
157
|
+
<optional>
|
158
|
+
<attribute name="keep-with-next">
|
159
|
+
<data type="boolean"/>
|
160
|
+
</attribute>
|
161
|
+
</optional>
|
162
|
+
<optional>
|
163
|
+
<attribute name="keep-lines-together">
|
164
|
+
<data type="boolean"/>
|
165
|
+
</attribute>
|
166
|
+
</optional>
|
138
167
|
<oneOrMore>
|
139
168
|
<ref name="BasicBlock"/>
|
140
169
|
</oneOrMore>
|
@@ -44,7 +44,7 @@ module RelatonBib
|
|
44
44
|
# @param count [Integeg] number of localities
|
45
45
|
# @return [String]
|
46
46
|
def to_asciibib(prefix = "", count = 1)
|
47
|
-
pref = prefix.empty? ? prefix : prefix
|
47
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
48
48
|
out = count > 1 ? "#{prefix}::\n" : ""
|
49
49
|
out += "#{pref}type:: #{type}\n"
|
50
50
|
out += "#{pref}reference_from:: #{reference_from}\n"
|
@@ -197,23 +197,23 @@ module RelatonBib
|
|
197
197
|
@title = TypedTitleStringCollection.new(args[:title])
|
198
198
|
|
199
199
|
@date = (args[:date] || []).map do |d|
|
200
|
-
d.is_a?(Hash) ? BibliographicDate.new(d) : d
|
200
|
+
d.is_a?(Hash) ? BibliographicDate.new(**d) : d
|
201
201
|
end
|
202
202
|
|
203
203
|
@contributor = (args[:contributor] || []).map do |c|
|
204
204
|
if c.is_a? Hash
|
205
|
-
e = c[:entity].is_a?(Hash) ? Organization.new(c[:entity]) : c[:entity]
|
205
|
+
e = c[:entity].is_a?(Hash) ? Organization.new(**c[:entity]) : c[:entity]
|
206
206
|
ContributionInfo.new(entity: e, role: c[:role])
|
207
207
|
else c
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
211
211
|
@abstract = (args[:abstract] || []).map do |a|
|
212
|
-
a.is_a?(Hash) ? FormattedString.new(a) : a
|
212
|
+
a.is_a?(Hash) ? FormattedString.new(**a) : a
|
213
213
|
end
|
214
214
|
|
215
215
|
@copyright = args.fetch(:copyright, []).map do |c|
|
216
|
-
c.is_a?(Hash) ? CopyrightAssociation.new(c) : c
|
216
|
+
c.is_a?(Hash) ? CopyrightAssociation.new(**c) : c
|
217
217
|
end
|
218
218
|
|
219
219
|
@docidentifier = args[:docid] || []
|
@@ -229,7 +229,7 @@ module RelatonBib
|
|
229
229
|
@status = args[:docstatus]
|
230
230
|
@relation = DocRelationCollection.new(args[:relation] || [])
|
231
231
|
@link = args.fetch(:link, []).map do |s|
|
232
|
-
if s.is_a?(Hash) then TypedUri.new(s)
|
232
|
+
if s.is_a?(Hash) then TypedUri.new(**s)
|
233
233
|
elsif s.is_a?(String) then TypedUri.new(content: s)
|
234
234
|
else s
|
235
235
|
end
|
@@ -257,6 +257,13 @@ module RelatonBib
|
|
257
257
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
258
258
|
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
259
259
|
|
260
|
+
# @param hash [Hash]
|
261
|
+
# @return [RelatonBipm::BipmBibliographicItem]
|
262
|
+
def self.from_hash(hash)
|
263
|
+
item_hash = ::RelatonBib::HashConverter.hash_to_bib(hash)
|
264
|
+
new **item_hash
|
265
|
+
end
|
266
|
+
|
260
267
|
# @param lang [String] language code Iso639
|
261
268
|
# @return [RelatonBib::FormattedString, Array<RelatonBib::FormattedString>]
|
262
269
|
def abstract(lang: nil)
|
@@ -101,14 +101,14 @@ module RelatonBib
|
|
101
101
|
if bibtex["organization"]
|
102
102
|
contributor << {
|
103
103
|
entity: { name: bibtex.organization.to_s },
|
104
|
-
role: [{ type: "distributor", description: ["sponsor"] }]
|
104
|
+
role: [{ type: "distributor", description: ["sponsor"] }],
|
105
105
|
}
|
106
106
|
end
|
107
107
|
|
108
108
|
if bibtex["school"]
|
109
109
|
contributor << {
|
110
110
|
entity: { name: bibtex.school.to_s },
|
111
|
-
role: [{ type: "distributor", description: ["sponsor"] }]
|
111
|
+
role: [{ type: "distributor", description: ["sponsor"] }],
|
112
112
|
}
|
113
113
|
end
|
114
114
|
contributor
|
@@ -30,7 +30,7 @@ module RelatonBib
|
|
30
30
|
end
|
31
31
|
|
32
32
|
@owner = owner.map do |o|
|
33
|
-
o.is_a?(Hash) ? ContributionInfo.new(entity: Organization.new(o)) : o
|
33
|
+
o.is_a?(Hash) ? ContributionInfo.new(entity: Organization.new(**o)) : o
|
34
34
|
end
|
35
35
|
|
36
36
|
@from = Date.strptime(from.to_s, "%Y") if from.to_s.match? /\d{4}/
|
@@ -13,7 +13,7 @@ module RelatonBib
|
|
13
13
|
derives describes describedBy catalogues cataloguedBy hasSuccessor
|
14
14
|
successorOf adaptedFrom hasAdaptation adoptedFrom adoptedAs reviewOf
|
15
15
|
hasReview commentaryOf hasCommentary related complements complementOf
|
16
|
-
obsoletes obsoletedBy
|
16
|
+
obsoletes obsoletedBy cites isCitedIn
|
17
17
|
].freeze
|
18
18
|
|
19
19
|
# @return [String]
|
@@ -18,7 +18,7 @@ module RelatonBib
|
|
18
18
|
# RelatonBib::SourceLocalityStack>] :source_locality
|
19
19
|
# @option relation [RelatonBib::BibliographicItem, NillClass] :bibitem (nil)
|
20
20
|
def initialize(relation)
|
21
|
-
@array = relation.map { |r| r.is_a?(Hash) ? DocumentRelation.new(r) : r }
|
21
|
+
@array = relation.map { |r| r.is_a?(Hash) ? DocumentRelation.new(**r) : r }
|
22
22
|
end
|
23
23
|
|
24
24
|
# @todo We don't have replace type anymore. Suppose we should update this
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module RelatonBib
|
3
4
|
# Document status.
|
4
5
|
class DocumentStatus
|
@@ -54,7 +55,7 @@ module RelatonBib
|
|
54
55
|
# @return [RelatonBib::DocumentStatus::Stage]
|
55
56
|
def stage_new(stg)
|
56
57
|
if stg.is_a?(Stage) then stg
|
57
|
-
elsif stg.is_a?(Hash) then Stage.new(stg)
|
58
|
+
elsif stg.is_a?(Hash) then Stage.new(**stg)
|
58
59
|
elsif stg.is_a?(String) then Stage.new(value: stg)
|
59
60
|
end
|
60
61
|
end
|
@@ -7,7 +7,7 @@ module RelatonBib
|
|
7
7
|
class FormattedString < LocalizedString
|
8
8
|
FORMATS = %w[text/plain text/html application/docbook+xml
|
9
9
|
application/tei+xml text/x-asciidoc text/markdown
|
10
|
-
application/x-
|
10
|
+
application/x-metanorma+xml].freeze
|
11
11
|
|
12
12
|
# @return [String]
|
13
13
|
attr_reader :format
|
@@ -97,7 +97,7 @@ module RelatonBib
|
|
97
97
|
return unless ret[:place]
|
98
98
|
|
99
99
|
ret[:place] = array(ret[:place]).map do |pl|
|
100
|
-
pl.is_a?(String) ? Place.new(name: pl) : Place.new(pl)
|
100
|
+
pl.is_a?(String) ? Place.new(name: pl) : Place.new(**pl)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -146,7 +146,7 @@ module RelatonBib
|
|
146
146
|
ret[:biblionote] = array(ret[:biblionote])
|
147
147
|
.reduce(BiblioNoteCollection.new([])) do |mem, n|
|
148
148
|
mem << if n.is_a?(String) then BiblioNote.new content: n
|
149
|
-
else BiblioNote.new(n)
|
149
|
+
else BiblioNote.new(**n)
|
150
150
|
end
|
151
151
|
end
|
152
152
|
end
|
@@ -247,10 +247,10 @@ module RelatonBib
|
|
247
247
|
script: d[:script], format: d[:format] }
|
248
248
|
else { content: d }
|
249
249
|
end
|
250
|
-
FormattedString.new cnt
|
250
|
+
FormattedString.new **cnt
|
251
251
|
end
|
252
252
|
Affiliation.new(
|
253
|
-
organization: Organization.new(org_hash_to_bib(a[:organization])),
|
253
|
+
organization: Organization.new(**org_hash_to_bib(a[:organization])),
|
254
254
|
description: a[:description]
|
255
255
|
)
|
256
256
|
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 r[:description]
|
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 item_hash
|
312
|
+
BibliographicItem.new **item_hash
|
313
313
|
end
|
314
314
|
|
315
315
|
# @param rel [Hash] relation
|
@@ -356,26 +356,26 @@ module RelatonBib
|
|
356
356
|
end
|
357
357
|
s[:abbreviation] &&
|
358
358
|
s[:abbreviation] = localizedstring(s[:abbreviation])
|
359
|
-
Series.new(s)
|
359
|
+
Series.new(**s)
|
360
360
|
end
|
361
361
|
end
|
362
362
|
|
363
363
|
# @param title [Hash]
|
364
364
|
# @return [RelatonBib::TypedTitleString]
|
365
365
|
def typed_title_strig(title)
|
366
|
-
TypedTitleString.new title
|
366
|
+
TypedTitleString.new **title
|
367
367
|
end
|
368
368
|
|
369
369
|
# @param ret [Hash]
|
370
370
|
def medium_hash_to_bib(ret)
|
371
|
-
ret[:medium] = Medium.new(ret[:medium]) if ret[:medium]
|
371
|
+
ret[:medium] = Medium.new(**ret[:medium]) if ret[:medium]
|
372
372
|
end
|
373
373
|
|
374
374
|
# @param ret [Hash]
|
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 cls
|
378
|
+
Classification.new **cls
|
379
379
|
end
|
380
380
|
end
|
381
381
|
end
|
@@ -409,7 +409,7 @@ module RelatonBib
|
|
409
409
|
return unless ret[:editorialgroup]
|
410
410
|
|
411
411
|
technical_committee = array(ret[:editorialgroup]).map do |wg|
|
412
|
-
TechnicalCommittee.new WorkGroup.new(wg)
|
412
|
+
TechnicalCommittee.new WorkGroup.new(**wg)
|
413
413
|
end
|
414
414
|
ret[:editorialgroup] = EditorialGroup.new technical_committee
|
415
415
|
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 ics }
|
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 si
|
430
|
+
StructuredIdentifier.new **si
|
431
431
|
end
|
432
432
|
ret[:structuredidentifier] = StructuredIdentifierCollection.new sids
|
433
433
|
end
|
@@ -485,7 +485,7 @@ module RelatonBib
|
|
485
485
|
# @return [RelatonBib::FormattedRef]
|
486
486
|
def formattedref(frf)
|
487
487
|
if frf.is_a?(Hash)
|
488
|
-
RelatonBib::FormattedRef.new(frf)
|
488
|
+
RelatonBib::FormattedRef.new(**frf)
|
489
489
|
else
|
490
490
|
RelatonBib::FormattedRef.new(content: frf)
|
491
491
|
end
|
data/lib/relaton_bib/ics.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
module RelatonBib
|
2
2
|
class ICS
|
3
3
|
# @return [String]
|
4
|
-
attr_reader :code
|
4
|
+
attr_reader :code
|
5
|
+
|
6
|
+
# @return [String, nil]
|
7
|
+
attr_reader :text
|
5
8
|
|
6
9
|
# @param code [String]
|
7
|
-
# @param text [String]
|
8
|
-
def initialize(code:, text:)
|
10
|
+
# @param text [String, nil]
|
11
|
+
def initialize(code:, text: nil)
|
9
12
|
@code = code
|
10
13
|
@text = text
|
11
14
|
end
|
@@ -14,23 +17,25 @@ module RelatonBib
|
|
14
17
|
def to_xml(builder)
|
15
18
|
builder.ics do |b|
|
16
19
|
b.code code
|
17
|
-
b.text_ text
|
20
|
+
b.text_ text if text
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
21
24
|
# @return [Hash]
|
22
25
|
def to_hash
|
23
|
-
{ "code" => code
|
26
|
+
hash = { "code" => code }
|
27
|
+
hash["text"] = text if text
|
28
|
+
hash
|
24
29
|
end
|
25
30
|
|
26
31
|
# @param prefix [String]
|
27
32
|
# @param count [Integer] number of ics
|
28
33
|
# @return [String]
|
29
34
|
def to_asciibib(prefix = "", count = 1)
|
30
|
-
pref = prefix.empty? ? "ics" : prefix
|
35
|
+
pref = prefix.empty? ? "ics" : "#{prefix}.ics"
|
31
36
|
out = count > 1 ? "#{pref}::\n" : ""
|
32
37
|
out += "#{pref}.code:: #{code}\n"
|
33
|
-
out += "#{pref}.text:: #{text}\n"
|
38
|
+
out += "#{pref}.text:: #{text}\n" if text
|
34
39
|
out
|
35
40
|
end
|
36
41
|
end
|
@@ -5,8 +5,8 @@ require "relaton_bib/contributor"
|
|
5
5
|
module RelatonBib
|
6
6
|
# Organization identifier.
|
7
7
|
class OrgIdentifier
|
8
|
-
ORCID = "orcid"
|
9
|
-
URI = "uri"
|
8
|
+
# ORCID = "orcid"
|
9
|
+
# URI = "uri"
|
10
10
|
|
11
11
|
# @return [String]
|
12
12
|
attr_reader :type
|
@@ -14,12 +14,12 @@ module RelatonBib
|
|
14
14
|
# @return [String]
|
15
15
|
attr_reader :value
|
16
16
|
|
17
|
-
# @param type [String]
|
17
|
+
# @param type [String]
|
18
18
|
# @param value [String]
|
19
19
|
def initialize(type, value)
|
20
|
-
unless [ORCID, URI].include? type
|
21
|
-
|
22
|
-
end
|
20
|
+
# unless [ORCID, URI].include? type
|
21
|
+
# raise ArgumentError, 'Invalid type. It should be "orsid" or "uri".'
|
22
|
+
# end
|
23
23
|
|
24
24
|
@type = type
|
25
25
|
@value = value
|
@@ -82,7 +82,7 @@ module RelatonBib
|
|
82
82
|
@subdivision = (args[:subdivision] || []).map do |sd|
|
83
83
|
localized_string sd
|
84
84
|
end
|
85
|
-
@identifier
|
85
|
+
@identifier = args.fetch(:identifier, [])
|
86
86
|
end
|
87
87
|
|
88
88
|
# @param opts [Hash]
|
data/lib/relaton_bib/person.rb
CHANGED
@@ -102,15 +102,17 @@ module RelatonBib
|
|
102
102
|
|
103
103
|
# Person identifier type.
|
104
104
|
module PersonIdentifierType
|
105
|
-
ISNI
|
106
|
-
|
105
|
+
ISNI = "isni"
|
106
|
+
ORCID = "orcid"
|
107
|
+
URI = "uri"
|
107
108
|
|
108
109
|
# Checks type.
|
109
110
|
# @param type [String]
|
110
111
|
# @raise [ArgumentError] if type isn't "isni" or "uri"
|
111
112
|
def self.check(type)
|
112
|
-
unless [ISNI, URI].include? type
|
113
|
-
raise ArgumentError, 'Invalid type. It should be "isni"
|
113
|
+
unless [ISNI, ORCID, URI].include? type
|
114
|
+
raise ArgumentError, 'Invalid type. It should be "isni", "orcid", "\
|
115
|
+
"or "uri".'
|
114
116
|
end
|
115
117
|
end
|
116
118
|
end
|
@@ -118,6 +120,7 @@ module RelatonBib
|
|
118
120
|
# Person identifier.
|
119
121
|
class PersonIdentifier
|
120
122
|
# @return [RelatonBib::PersonIdentifierType::ISNI,
|
123
|
+
# RelatonBib::PersonIdentifierType::ORCID,
|
121
124
|
# RelatonBib::PersonIdentifierType::URI]
|
122
125
|
attr_accessor :type
|
123
126
|
|
@@ -125,6 +128,7 @@ module RelatonBib
|
|
125
128
|
attr_accessor :value
|
126
129
|
|
127
130
|
# @param type [RelatonBib::PersonIdentifierType::ISNI,
|
131
|
+
# RelatonBib::PersonIdentifierType::ORCID,
|
128
132
|
# RelatonBib::PersonIdentifierType::URI]
|
129
133
|
# @param value [String]
|
130
134
|
def initialize(type, value)
|
data/lib/relaton_bib/series.rb
CHANGED
@@ -5,7 +5,7 @@ module RelatonBib
|
|
5
5
|
# Series class.
|
6
6
|
#
|
7
7
|
class Series
|
8
|
-
TYPES = %w[main alt].freeze
|
8
|
+
# TYPES = %w[main alt].freeze
|
9
9
|
|
10
10
|
# @return [String, NilClass] allowed values: "main" or "alt"
|
11
11
|
attr_reader :type
|
@@ -56,9 +56,9 @@ module RelatonBib
|
|
56
56
|
raise ArgumentError, "argument `title` or `formattedref` should present"
|
57
57
|
end
|
58
58
|
|
59
|
-
if args[:type] && !TYPES.include?(args[:type])
|
60
|
-
|
61
|
-
end
|
59
|
+
# if args[:type] && !TYPES.include?(args[:type])
|
60
|
+
# warn "[relaton-bib] Series type is invalid: #{args[:type]}"
|
61
|
+
# end
|
62
62
|
|
63
63
|
@type = args[:type] # if %w[main alt].include? args[:type]
|
64
64
|
@title = args[:title]
|