relaton-bib 1.13.1 → 1.13.3
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 -1
- data/.github/workflows/release.yml +22 -0
- data/docs/hash.adoc +69 -52
- data/lib/relaton_bib/bibliographic_item.rb +19 -27
- data/lib/relaton_bib/hash_converter.rb +7 -4
- data/lib/relaton_bib/hit.rb +6 -6
- data/lib/relaton_bib/localized_string.rb +33 -29
- data/lib/relaton_bib/typed_title_string.rb +6 -2
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca70214e52f3a00a9388de24a1e07fa6464e0cb23831fd14775ce0e29c929fdf
|
4
|
+
data.tar.gz: 33cafac4c23e9dc57f102982bffbea20c25420f89471f164a0f875e4e6a74e26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5eb2c4f5b7c13337a0e1f560d69ad140f91ea49405c3a4d876110bcdab32e532043a65187ca5fa6973c6cb0cf0240c285430a58d32338d186da882632194b2d
|
7
|
+
data.tar.gz: 3fd3d4b199c1c190c4920c7daba0e73979a6e82ee24648a84ab3057e2cee08345db9cc929ba324773a55d0e1fe4160ca5af2320a2e297c52dfcbace78bbcd282
|
data/.github/workflows/rake.yml
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: release
|
4
|
+
|
5
|
+
on:
|
6
|
+
workflow_dispatch:
|
7
|
+
inputs:
|
8
|
+
next_version:
|
9
|
+
description: |
|
10
|
+
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
|
11
|
+
required: true
|
12
|
+
default: 'skip'
|
13
|
+
push:
|
14
|
+
tags: [ v* ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
release:
|
18
|
+
uses: relaton/support/.github/workflows/release.yml@master
|
19
|
+
with:
|
20
|
+
next_version: ${{ github.event.inputs.next_version }}
|
21
|
+
secrets:
|
22
|
+
rubygems-api-key: ${{ secrets.RELATON_CI_RUBYGEMS_API_KEY }}
|
data/docs/hash.adoc
CHANGED
@@ -49,7 +49,7 @@ The structure below is given in YAML format:
|
|
49
49
|
# bibliographic item anchor, used to crossreference within document
|
50
50
|
id: ISO/TC211
|
51
51
|
# date record was created
|
52
|
-
fetched: 2019-06-30
|
52
|
+
fetched: '2019-06-30'
|
53
53
|
# titles are an array, with a mandatory type and content, and optional format, language and script
|
54
54
|
title:
|
55
55
|
- type: main
|
@@ -66,9 +66,9 @@ docid:
|
|
66
66
|
type: ISO
|
67
67
|
id: TC211
|
68
68
|
# document number
|
69
|
-
docnumber: 211
|
69
|
+
docnumber: '211'
|
70
70
|
# edition
|
71
|
-
edition: 1
|
71
|
+
edition: '1'
|
72
72
|
# language is an array
|
73
73
|
language:
|
74
74
|
- en
|
@@ -78,7 +78,7 @@ script:
|
|
78
78
|
Latn
|
79
79
|
# version contains revision date and draft (as array)
|
80
80
|
version:
|
81
|
-
revision_date: 2019-04-01
|
81
|
+
revision_date: '2019-04-01'
|
82
82
|
draft: draft
|
83
83
|
# note is an array of type and content
|
84
84
|
biblionote:
|
@@ -94,12 +94,12 @@ docstatus:
|
|
94
94
|
# date is an array, with mandatory type, and either an "on" value or a "from" and optional "to" value
|
95
95
|
date:
|
96
96
|
- type: issued
|
97
|
-
value: 2014
|
97
|
+
value: '2014'
|
98
98
|
- type: published
|
99
|
-
from: 2014-04
|
100
|
-
to: 2014-05
|
99
|
+
from: '2014-04'
|
100
|
+
to: '2014-05'
|
101
101
|
- type: accessed
|
102
|
-
value: 2015-05-20
|
102
|
+
value: '2015-05-20'
|
103
103
|
# abstract is an array, with content, and optional language, script, format
|
104
104
|
abstract:
|
105
105
|
- content: >
|
@@ -114,7 +114,8 @@ abstract:
|
|
114
114
|
# as the type.
|
115
115
|
# Organisations have attributes name, url, abbreviation, subdivision, contacts, identifiers
|
116
116
|
# Persons have attributes name, affiliation, contacts
|
117
|
-
# Person names have attributes
|
117
|
+
# Person names have attributes, given, surname, additions, prefixes or completename.
|
118
|
+
# Given has formatted_initials or forename.
|
118
119
|
# Initials, forename, additions, prefixes are arrays.
|
119
120
|
# Name field values are either strings, or hashes, with content and language and script attributes.
|
120
121
|
# The language and script attribute can also be given on the name.
|
@@ -126,9 +127,11 @@ abstract:
|
|
126
127
|
# The affiliation description can be a single string, or a hash of content, language, script, and format.
|
127
128
|
contributor:
|
128
129
|
- organization:
|
129
|
-
name:
|
130
|
+
name:
|
131
|
+
content: International Organization for Standardization
|
130
132
|
url: www.iso.org
|
131
|
-
abbreviation:
|
133
|
+
abbreviation:
|
134
|
+
content: ISO
|
132
135
|
subdivision: division
|
133
136
|
role:
|
134
137
|
type: publisher
|
@@ -140,25 +143,29 @@ contributor:
|
|
140
143
|
language: en
|
141
144
|
affiliation:
|
142
145
|
- organization:
|
143
|
-
name:
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
146
|
+
name:
|
147
|
+
content: IETF
|
148
|
+
abbreviation:
|
149
|
+
content: IETF
|
150
|
+
identifier:
|
151
|
+
- type: uri
|
152
|
+
id: www.ietf.org
|
148
153
|
description: Affiliation description
|
149
154
|
contact:
|
150
|
-
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
155
|
+
- address:
|
156
|
+
street:
|
157
|
+
- 8 Street St
|
158
|
+
city: City
|
159
|
+
postcode: '123456'
|
160
|
+
country: Country
|
161
|
+
state: State
|
162
|
+
- phone: '223322'
|
158
163
|
role: author
|
159
|
-
-
|
160
|
-
name:
|
161
|
-
|
164
|
+
- organization:
|
165
|
+
name:
|
166
|
+
content: Internet Engineering Task Force
|
167
|
+
abbreviation:
|
168
|
+
content: IETF
|
162
169
|
identifier:
|
163
170
|
- type: uri
|
164
171
|
id: www.ietf.org
|
@@ -166,18 +173,24 @@ contributor:
|
|
166
173
|
publisher
|
167
174
|
- person:
|
168
175
|
name:
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
176
|
+
given:
|
177
|
+
forename:
|
178
|
+
initial: A
|
179
|
+
language: en
|
180
|
+
formatted_initials:
|
181
|
+
content: A.
|
182
|
+
surname:
|
183
|
+
content: Bierman
|
173
184
|
affiliation:
|
174
|
-
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
185
|
+
- organization:
|
186
|
+
name:
|
187
|
+
content: IETF
|
188
|
+
abbreviation:
|
189
|
+
content: IETF
|
190
|
+
description:
|
191
|
+
content: Affiliation description
|
192
|
+
language: en
|
193
|
+
script: Latn
|
181
194
|
identifier:
|
182
195
|
- type: uri
|
183
196
|
id: www.person.com
|
@@ -187,11 +200,13 @@ contributor:
|
|
187
200
|
# a "from" date, and an optional "to" date
|
188
201
|
copyright:
|
189
202
|
owner:
|
190
|
-
name:
|
191
|
-
|
203
|
+
name:
|
204
|
+
content: International Organization for Standardization
|
205
|
+
abbreviation:
|
206
|
+
content: ISO
|
192
207
|
url: www.iso.org
|
193
|
-
from: 2014
|
194
|
-
to: 2020
|
208
|
+
from: '2014'
|
209
|
+
to: '2020'
|
195
210
|
# link is an array of URIs, with a type and content
|
196
211
|
link:
|
197
212
|
- type: src
|
@@ -206,15 +221,17 @@ link:
|
|
206
221
|
relation:
|
207
222
|
- type: updates
|
208
223
|
bibitem:
|
209
|
-
formattedref:
|
224
|
+
formattedref:
|
225
|
+
content: ISO 19115:2003
|
210
226
|
bib_locality:
|
211
227
|
type: page
|
212
|
-
reference_from: 7
|
213
|
-
reference_to: 10
|
228
|
+
reference_from: '7'
|
229
|
+
reference_to: '10'
|
214
230
|
- type: updates
|
215
231
|
bibitem:
|
216
232
|
type: standard
|
217
|
-
formattedref:
|
233
|
+
formattedref:
|
234
|
+
content: ISO 19115:2003/Cor 1:2006
|
218
235
|
# series are an array, containing a type, and either a formattedref, or:
|
219
236
|
# a title, a place, an organization (string),
|
220
237
|
# an abbreviation, a from, a to, a number, and a partnumber.
|
@@ -236,8 +253,8 @@ series:
|
|
236
253
|
content: ABVR
|
237
254
|
language: en
|
238
255
|
script: Latn
|
239
|
-
from: 2009-02-01
|
240
|
-
to: 2010-12-20
|
256
|
+
from: '2009-02-01'
|
257
|
+
to: '2010-12-20'
|
241
258
|
number: serie1234
|
242
259
|
partnumber: part5678
|
243
260
|
- type: alt
|
@@ -255,7 +272,7 @@ place: bib place
|
|
255
272
|
# extent is an array, containing type, a reference_from, and an optional reference_to
|
256
273
|
extent:
|
257
274
|
type: section
|
258
|
-
reference_from: 7
|
275
|
+
reference_from: '7'
|
259
276
|
# accesslocation is an array of strings
|
260
277
|
accesslocation:
|
261
278
|
- accesslocation1
|
@@ -266,9 +283,9 @@ classification:
|
|
266
283
|
value: value
|
267
284
|
# validity contains a begins date, an ends date, and a revision date
|
268
285
|
validity:
|
269
|
-
begins: 2010-10-10 12:21
|
270
|
-
ends: 2011-02-03 18:30
|
271
|
-
revision: 2011-03-04 09:00
|
286
|
+
begins: '2010-10-10 12:21'
|
287
|
+
ends: '2011-02-03 18:30'
|
288
|
+
revision: '2011-03-04 09:00'
|
272
289
|
----
|
273
290
|
|
274
291
|
== Metanorma structure (AsciiBib): nested definition list
|
@@ -115,7 +115,7 @@ module RelatonBib
|
|
115
115
|
attr_reader :validity
|
116
116
|
|
117
117
|
# @return [Date]
|
118
|
-
|
118
|
+
attr_accessor :fetched
|
119
119
|
|
120
120
|
# @return [Array<RelatonBib::LocalizedString>]
|
121
121
|
attr_reader :keyword
|
@@ -207,7 +207,11 @@ module RelatonBib
|
|
207
207
|
warn %{[relaton-bib] document type "#{args[:type]}" is invalid.}
|
208
208
|
end
|
209
209
|
|
210
|
-
@title =
|
210
|
+
@title = if args[:title].is_a?(TypedTitleStringCollection)
|
211
|
+
args[:title]
|
212
|
+
else
|
213
|
+
TypedTitleStringCollection.new(args[:title])
|
214
|
+
end
|
211
215
|
|
212
216
|
@date = (args[:date] || []).map do |d|
|
213
217
|
d.is_a?(Hash) ? BibliographicDate.new(**d) : d
|
@@ -368,7 +372,7 @@ module RelatonBib
|
|
368
372
|
def to_hash # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
369
373
|
hash = {}
|
370
374
|
hash["id"] = id if id
|
371
|
-
hash["title"] =
|
375
|
+
hash["title"] = title.to_hash if title&.any?
|
372
376
|
hash["link"] = single_element_array(link) if link&.any?
|
373
377
|
hash["type"] = type if type
|
374
378
|
hash["docid"] = single_element_array(docidentifier) if docidentifier&.any?
|
@@ -604,10 +608,8 @@ module RelatonBib
|
|
604
608
|
end
|
605
609
|
end
|
606
610
|
|
607
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
608
|
-
|
609
611
|
# @param [BibTeX::Entry]
|
610
|
-
def bibtex_author(item) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
612
|
+
def bibtex_author(item) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/AbcSize
|
611
613
|
authors = contributor.select do |c|
|
612
614
|
c.entity.is_a?(Person) && c.role.map(&:type).include?("author")
|
613
615
|
end.map &:entity
|
@@ -624,7 +626,7 @@ module RelatonBib
|
|
624
626
|
end
|
625
627
|
|
626
628
|
# @param [BibTeX::Entry]
|
627
|
-
def bibtex_contributor(item) # rubocop:disable Metrics/CyclomaticComplexity
|
629
|
+
def bibtex_contributor(item) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
|
628
630
|
contributor.each do |c|
|
629
631
|
rls = c.role.map(&:type)
|
630
632
|
if rls.include?("publisher") then item.publisher = c.entity.name
|
@@ -638,7 +640,6 @@ module RelatonBib
|
|
638
640
|
end
|
639
641
|
end
|
640
642
|
end
|
641
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
642
643
|
|
643
644
|
# @param [BibTeX::Entry]
|
644
645
|
def bibtex_note(item) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/AbcSize
|
@@ -724,16 +725,12 @@ module RelatonBib
|
|
724
725
|
end
|
725
726
|
end
|
726
727
|
|
727
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
728
|
-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
729
|
-
# rubocop:disable Style/NestedParenthesizedCalls, Metrics/BlockLength
|
730
|
-
|
731
728
|
# @param opts [Hash]
|
732
729
|
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
733
730
|
# @option opts [Boolean] bibdata
|
734
731
|
# @option opts [Symbol, nil] :date_format (:short), :full
|
735
732
|
# @option opts [String] :lang language
|
736
|
-
def render_xml(**opts)
|
733
|
+
def render_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
737
734
|
root = opts[:bibdata] ? :bibdata : :bibitem
|
738
735
|
xml = opts[:builder].send(root) do |builder|
|
739
736
|
builder.fetched fetched if fetched
|
@@ -791,7 +788,6 @@ module RelatonBib
|
|
791
788
|
xml[:type] = type if type
|
792
789
|
xml
|
793
790
|
end
|
794
|
-
# rubocop:enable Style/NestedParenthesizedCalls, Metrics/BlockLength
|
795
791
|
|
796
792
|
#
|
797
793
|
# Render BibXML (RFC, BCP)
|
@@ -799,7 +795,7 @@ module RelatonBib
|
|
799
795
|
# @param [Nokogiri::XML::Builder] builder
|
800
796
|
# @param [Boolean] include_bibdata
|
801
797
|
#
|
802
|
-
def render_bibxml(builder, include_keywords)
|
798
|
+
def render_bibxml(builder, include_keywords) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
803
799
|
target = link.detect { |l| l.type.casecmp("src").zero? } ||
|
804
800
|
link.detect { |l| l.type.casecmp("doi").zero? }
|
805
801
|
bxml = if docnumber&.match(/^BCP/) || (docidentifier.detect(&:primary)&.id ||
|
@@ -831,7 +827,7 @@ module RelatonBib
|
|
831
827
|
# @param [Nokogiri::XML::Builder] builder
|
832
828
|
# @param [Boolean] include_keywords
|
833
829
|
#
|
834
|
-
def render_bibxml_ref(builder, include_keywords)
|
830
|
+
def render_bibxml_ref(builder, include_keywords) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
835
831
|
builder.reference(**ref_attrs) do |xml|
|
836
832
|
if title.any? || contributor.any? || date.any? || abstract.any? ||
|
837
833
|
editorialgroup&.technical_committee&.any? ||
|
@@ -861,7 +857,7 @@ module RelatonBib
|
|
861
857
|
#
|
862
858
|
# @return [Hash<Symbol=>String>] attributes
|
863
859
|
#
|
864
|
-
def ref_attrs
|
860
|
+
def ref_attrs # rubocop:disable Metrics/AbcSize
|
865
861
|
discopes = %w[anchor docName number]
|
866
862
|
attrs = docidentifier.each_with_object({}) do |di, h|
|
867
863
|
next unless discopes.include?(di.scope)
|
@@ -912,7 +908,7 @@ module RelatonBib
|
|
912
908
|
#
|
913
909
|
# @param [Nokogiri::XML::Builder] builder xml builder
|
914
910
|
#
|
915
|
-
def render_date(builder)
|
911
|
+
def render_date(builder) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
916
912
|
dt = date.detect { |d| d.type == "published" }
|
917
913
|
return unless dt
|
918
914
|
|
@@ -933,7 +929,7 @@ module RelatonBib
|
|
933
929
|
#
|
934
930
|
# @param [Nokogiri::XML::Builder] builder xml builder
|
935
931
|
#
|
936
|
-
def render_seriesinfo(builder)
|
932
|
+
def render_seriesinfo(builder) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
937
933
|
docidentifier.each do |di|
|
938
934
|
if BibXMLParser::SERIESINFONAMES.include? di.type
|
939
935
|
builder.seriesInfo(name: di.type, value: di.id)
|
@@ -954,7 +950,7 @@ module RelatonBib
|
|
954
950
|
#
|
955
951
|
# @param [Nokogiri::XML::Builder] builder xml builder
|
956
952
|
#
|
957
|
-
def render_authors(builder)
|
953
|
+
def render_authors(builder) # rubocop:disable Metrics/AbcSize
|
958
954
|
contributor.each do |c|
|
959
955
|
builder.author do |xml|
|
960
956
|
xml.parent[:role] = "editor" if c.role.detect { |r| r.type == "editor" }
|
@@ -972,7 +968,7 @@ module RelatonBib
|
|
972
968
|
# @param [Nokogiri::XML::Builder] builder xml builder
|
973
969
|
# @param [RelatonBib::ContributionInfo] contrib contributor
|
974
970
|
#
|
975
|
-
def render_address(builder, contrib)
|
971
|
+
def render_address(builder, contrib) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
976
972
|
# addr = contrib.entity.contact.reject do |cn|
|
977
973
|
# cn.is_a?(Address) && cn.postcode.nil?
|
978
974
|
# end
|
@@ -1012,7 +1008,7 @@ module RelatonBib
|
|
1012
1008
|
# @param [Nokogiri::XML::Builder] builder xml builder
|
1013
1009
|
# @param [RelatonBib::Person] person person
|
1014
1010
|
#
|
1015
|
-
def render_person(builder, person)
|
1011
|
+
def render_person(builder, person) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
1016
1012
|
render_organization builder, person.affiliation.first&.organization
|
1017
1013
|
if person.name.completename
|
1018
1014
|
builder.parent[:fullname] = person.name.completename.content
|
@@ -1042,9 +1038,7 @@ module RelatonBib
|
|
1042
1038
|
# @param [Nokogiri::XML::Builder] builder xml builder
|
1043
1039
|
# @param [RelatonBib::Organization] org organization
|
1044
1040
|
#
|
1045
|
-
def render_organization(builder, org)
|
1046
|
-
# return unless org
|
1047
|
-
|
1041
|
+
def render_organization(builder, org) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
1048
1042
|
ab = org&.abbreviation&.content
|
1049
1043
|
on = org&.name&.first&.content
|
1050
1044
|
orgname = if BibXMLParser::ORGNAMES.key?(ab) then ab
|
@@ -1053,7 +1047,5 @@ module RelatonBib
|
|
1053
1047
|
o = builder.organization orgname
|
1054
1048
|
o[:abbrev] = ab if ab
|
1055
1049
|
end
|
1056
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
1057
|
-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
1058
1050
|
end
|
1059
1051
|
end
|
@@ -83,7 +83,7 @@ module RelatonBib
|
|
83
83
|
|
84
84
|
ret[:title] = RelatonBib.array(ret[:title])
|
85
85
|
.reduce(TypedTitleStringCollection.new) do |m, t|
|
86
|
-
if t.is_a?(Hash) then m << t
|
86
|
+
if t.is_a?(Hash) then m << TypedTitleString.new(**t)
|
87
87
|
else
|
88
88
|
m + TypedTitleString.from_string(t)
|
89
89
|
end
|
@@ -146,13 +146,16 @@ module RelatonBib
|
|
146
146
|
def docid_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize
|
147
147
|
return unless ret[:docid]
|
148
148
|
|
149
|
-
ret[:docid] = RelatonBib.array(ret[:docid])
|
150
|
-
ret[:docid]&.each_with_index do |id, i|
|
149
|
+
ret[:docid] = RelatonBib.array(ret[:docid]).map do |id|
|
151
150
|
id[:type] ||= id[:id].match(/^\w+(?=\s)/)&.to_s
|
152
|
-
|
151
|
+
create_docid(**id)
|
153
152
|
end
|
154
153
|
end
|
155
154
|
|
155
|
+
def create_docid(**args)
|
156
|
+
DocumentIdentifier.new(**args)
|
157
|
+
end
|
158
|
+
|
156
159
|
def version_hash_to_bib(ret)
|
157
160
|
return unless ret[:version]
|
158
161
|
|
data/lib/relaton_bib/hit.rb
CHANGED
@@ -7,7 +7,7 @@ module RelatonBib
|
|
7
7
|
attr_reader :hit
|
8
8
|
|
9
9
|
# @param hit [Hash]
|
10
|
-
# @param hit_collection [
|
10
|
+
# @param hit_collection [RelatonBib::HitCollection]
|
11
11
|
def initialize(hit, hit_collection = nil)
|
12
12
|
@hit = hit
|
13
13
|
@hit_collection = hit_collection
|
@@ -20,11 +20,11 @@ module RelatonBib
|
|
20
20
|
|
21
21
|
# @return [String]
|
22
22
|
def inspect
|
23
|
-
"<#{self.class}:#{format('%<id>#.14x', id: object_id << 1)} "\
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
"<#{self.class}:#{format('%<id>#.14x', id: object_id << 1)} " \
|
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
|
@@ -78,18 +78,13 @@ module RelatonBib
|
|
78
78
|
def encode(cnt) # rubocop:disable Metrics/MethodLength
|
79
79
|
return unless cnt
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
out = scan_xml parts
|
89
|
-
"#{escp(prf)}#{out}#{encode(rest)}"
|
90
|
-
else
|
91
|
-
escp cnt
|
92
|
-
end
|
81
|
+
parts = cnt.scan(%r{
|
82
|
+
<(?<tago>\w+)(?<attrs>[^>]*)> | # tag open
|
83
|
+
</(?<tagc>\w+)> | # tag close
|
84
|
+
(?<cmt><!--.*?-->) | # comment
|
85
|
+
(?<cnt>.+?)(?=<|$) # content
|
86
|
+
}x)
|
87
|
+
scan_xml parts
|
93
88
|
end
|
94
89
|
|
95
90
|
#
|
@@ -100,23 +95,32 @@ module RelatonBib
|
|
100
95
|
# @return [String] output string
|
101
96
|
#
|
102
97
|
def scan_xml(parts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
103
|
-
return "" unless parts.any?
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
_, _, _,
|
108
|
-
"
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
98
|
+
return "" unless parts.any?
|
99
|
+
|
100
|
+
out = ""
|
101
|
+
while parts.any? && (parts.first[3] || parts.first[4])
|
102
|
+
_, _, _, cmt, cnt = parts.shift
|
103
|
+
out += "#{cmt}#{escp(cnt)}"
|
104
|
+
end
|
105
|
+
unless out.empty?
|
106
|
+
out += scan_xml(parts) if parts.any? && parts.first[0]
|
107
|
+
return out
|
108
|
+
end
|
109
|
+
|
110
|
+
tago, attrs, tagc, = parts.shift
|
111
|
+
out = if tago && attrs && attrs[-1] == "/"
|
112
|
+
"<#{tago}#{attrs}>"
|
113
|
+
elsif tago
|
114
|
+
inr = scan_xml parts
|
115
|
+
_, _, tagc, = parts.shift
|
116
|
+
if tago == tagc
|
117
|
+
"<#{tago}#{attrs}>#{inr}</#{tagc}>"
|
118
|
+
else
|
119
|
+
"#{escp("<#{tago}#{attrs}>")}#{inr}#{escp("</#{tagc}>")}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
out += scan_xml(parts) if parts.any? && (parts.first[0] || parts.first[3] || parts.first[4])
|
123
|
+
out
|
120
124
|
end
|
121
125
|
|
122
126
|
#
|
@@ -26,8 +26,8 @@ module RelatonBib
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# @return [RelatonBib::TypedTitleStringCollection]
|
29
|
-
def select
|
30
|
-
TypedTitleStringCollection.new
|
29
|
+
def select(&block)
|
30
|
+
TypedTitleStringCollection.new titles.select(&block)
|
31
31
|
end
|
32
32
|
|
33
33
|
# @param init [Array, Hash]
|
@@ -62,6 +62,10 @@ module RelatonBib
|
|
62
62
|
tl.each { |t| opts[:builder].title { t.to_xml opts[:builder] } }
|
63
63
|
end
|
64
64
|
|
65
|
+
def to_hash
|
66
|
+
@array.map(&:to_hash)
|
67
|
+
end
|
68
|
+
|
65
69
|
#
|
66
70
|
# Add main title ot bibtex entry
|
67
71
|
#
|
data/lib/relaton_bib/version.rb
CHANGED
@@ -376,7 +376,7 @@ module RelatonBib
|
|
376
376
|
# @return [Array<RelatonBib::FormattedString>]
|
377
377
|
def fetch_abstract(item)
|
378
378
|
item.xpath("./abstract").map do |a|
|
379
|
-
c = a.
|
379
|
+
c = a.children.to_xml(encoding: "utf-8").strip
|
380
380
|
FormattedString.new(content: c, language: a[:language],
|
381
381
|
script: a[:script], format: a[:format])
|
382
382
|
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.13.
|
4
|
+
version: 1.13.3
|
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-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -214,6 +214,7 @@ extensions: []
|
|
214
214
|
extra_rdoc_files: []
|
215
215
|
files:
|
216
216
|
- ".github/workflows/rake.yml"
|
217
|
+
- ".github/workflows/release.yml"
|
217
218
|
- ".gitignore"
|
218
219
|
- ".gitmodules"
|
219
220
|
- ".hound.yml"
|
@@ -279,7 +280,7 @@ homepage: https://github.com/relaton/relaton-bib
|
|
279
280
|
licenses:
|
280
281
|
- BSD-2-Clause
|
281
282
|
metadata: {}
|
282
|
-
post_install_message:
|
283
|
+
post_install_message:
|
283
284
|
rdoc_options: []
|
284
285
|
require_paths:
|
285
286
|
- lib
|
@@ -294,8 +295,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
294
295
|
- !ruby/object:Gem::Version
|
295
296
|
version: '0'
|
296
297
|
requirements: []
|
297
|
-
rubygems_version: 3.
|
298
|
-
signing_key:
|
298
|
+
rubygems_version: 3.1.6
|
299
|
+
signing_key:
|
299
300
|
specification_version: 4
|
300
301
|
summary: 'RelatonBib: Ruby XMLDOC impementation.'
|
301
302
|
test_files: []
|