relaton-bib 1.9.16 → 1.9.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_bib/bibliographic_item.rb +20 -6
- data/lib/relaton_bib/bibxml_parser.rb +8 -3
- data/lib/relaton_bib/document_identifier.rb +1 -1
- data/lib/relaton_bib/document_relation.rb +1 -1
- data/lib/relaton_bib/document_status.rb +1 -1
- data/lib/relaton_bib/localized_string.rb +6 -2
- data/lib/relaton_bib/structured_identifier.rb +12 -11
- data/lib/relaton_bib/typed_uri.rb +1 -1
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +3 -2
- data/lib/relaton_bib.rb +5 -5
- data/relaton-bib.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b714ee74a9d4da85784bbcc2e7fb50c9548215c1399a799290646eb230529f2f
|
4
|
+
data.tar.gz: 75cf8abea4defed1d25cd241443ae6b8df03688a47e8cce4e907bab03315d978
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50dd80e6be598a65d4ded5f35e047b7b32a1c9cdcdacdd0539d13e149533501f093e95bbb176b1a58f566274c16ec88b461d50c295daa9bb46c52a9c683bf949
|
7
|
+
data.tar.gz: 58ac55543ac1f21477ca3c1125c8d50ccd88aee77c1ab74c4aa374839549d289083827d3b54795cb35901fa26bf46b3a7f4fff46c7b86e8ee23043f05c18ba04
|
@@ -766,8 +766,8 @@ module RelatonBib
|
|
766
766
|
# @param [Nokogiri::XML::Builder] builder
|
767
767
|
#
|
768
768
|
def render_bibxml(builder)
|
769
|
-
target = link.detect { |l| l.type
|
770
|
-
link.detect { |l| l.type
|
769
|
+
target = link.detect { |l| l.type.casecmp("src").zero? } ||
|
770
|
+
link.detect { |l| l.type.casecmp("doi").zero? }
|
771
771
|
bxml = if docnumber&.match(/^BCP/) || docidentifier[0].id.include?("BCP")
|
772
772
|
render_bibxml_refgroup(builder)
|
773
773
|
else
|
@@ -920,13 +920,22 @@ module RelatonBib
|
|
920
920
|
def render_person(builder, person)
|
921
921
|
render_organization builder, person.affiliation.first&.organization
|
922
922
|
if person.name.completename
|
923
|
-
builder.parent[:fullname] = person.name.completename
|
923
|
+
builder.parent[:fullname] = person.name.completename.content
|
924
|
+
elsif person.name.forename.any?
|
925
|
+
builder.parent[:fullname] = person.name.forename.map(&:content).join
|
924
926
|
end
|
925
927
|
if person.name.initial.any?
|
926
928
|
builder.parent[:initials] = person.name.initial.map(&:content).join
|
929
|
+
elsif person.name.forename.any?
|
930
|
+
builder.parent[:initials] = person.name.forename.map do |f|
|
931
|
+
"#{f.content[0]}."
|
932
|
+
end.join
|
927
933
|
end
|
928
934
|
if person.name.surname
|
929
|
-
|
935
|
+
if person.name.forename.any?
|
936
|
+
builder.parent[:fullname] += " #{person.name.surname}"
|
937
|
+
end
|
938
|
+
builder.parent[:surname] = person.name.surname.content
|
930
939
|
end
|
931
940
|
end
|
932
941
|
|
@@ -935,8 +944,13 @@ module RelatonBib
|
|
935
944
|
def render_organization(builder, org)
|
936
945
|
return unless org
|
937
946
|
|
938
|
-
|
939
|
-
|
947
|
+
ab = org.abbreviation&.content
|
948
|
+
on = org.name.first&.content
|
949
|
+
orgname = if BibXMLParser::ORGNAMES.key?(ab) then ab
|
950
|
+
else BibXMLParser::ORGNAMES.key(on) || on || ab
|
951
|
+
end
|
952
|
+
o = builder.organization orgname
|
953
|
+
o[:abbrev] = ab if ab
|
940
954
|
end
|
941
955
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
942
956
|
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
@@ -2,6 +2,10 @@ module RelatonBib
|
|
2
2
|
module BibXMLParser
|
3
3
|
SERIESINFONAMES = ["DOI", "Internet-Draft"].freeze
|
4
4
|
FLAVOR = nil
|
5
|
+
ORGNAMES = {
|
6
|
+
"IEEE" => "Istitute of Electrical and Electronics Engineers",
|
7
|
+
"W3C" => "World Wide Web Consortium",
|
8
|
+
}.freeze
|
5
9
|
|
6
10
|
def parse(bibxml, url: nil, is_relation: false, ver: nil)
|
7
11
|
doc = Nokogiri::XML bibxml
|
@@ -82,7 +86,7 @@ module RelatonBib
|
|
82
86
|
type_match = id&.match(/^(3GPP|W3C|[A-Z]{2,})(?:\.(?=[A-Z])|(?=\d))/)
|
83
87
|
type = self::FLAVOR || (type_match && type_match[1])
|
84
88
|
if id
|
85
|
-
/^(?<pref>I-D|3GPP|W3C|[A-Z]{2,})
|
89
|
+
/^(?<pref>I-D|3GPP|W3C|[A-Z]{2,})[._]?(?<num>.+)/ =~ id
|
86
90
|
num.sub!(/^-?0+/, "") if %w[RFC BCP FYI STD].include?(pref)
|
87
91
|
pid = pref ? "#{pref} #{num}" : id
|
88
92
|
ret << DocumentIdentifier.new(type: type, id: pid)
|
@@ -209,7 +213,8 @@ module RelatonBib
|
|
209
213
|
# "front/author[not(@surname)][not(@fullname)]/organization",
|
210
214
|
# ).map do |org|
|
211
215
|
org = contrib.at("./organization")
|
212
|
-
|
216
|
+
name = ORGNAMES[org.text] || org.text
|
217
|
+
{ entity: new_org(name, org[:abbrev]), role: [contributor_role(contrib)] }
|
213
218
|
# end
|
214
219
|
end
|
215
220
|
|
@@ -307,7 +312,7 @@ module RelatonBib
|
|
307
312
|
# @return [Array<RelatonBib::BibliographicDate>] published data.
|
308
313
|
#
|
309
314
|
def dates(reference)
|
310
|
-
return unless (date = reference.at "./front/date")
|
315
|
+
return [] unless (date = reference.at "./front/date")
|
311
316
|
|
312
317
|
d = [date[:year], month(date[:month]), (date[:day] || 1)].compact.join "-"
|
313
318
|
date = Time.parse(d).strftime "%Y-%m-%d"
|
@@ -36,7 +36,7 @@ module RelatonBib
|
|
36
36
|
attr_reader :source_locality
|
37
37
|
|
38
38
|
# @param type [String]
|
39
|
-
# @
|
39
|
+
# @param description [RelatonBib::FormattedString, NilClass]
|
40
40
|
# @param bibitem [RelatonBib::BibliographicItem,
|
41
41
|
# RelatonIso::IsoBibliographicItem]
|
42
42
|
# @param locality [Array<RelatonBib::Locality, RelatonBib::LocalityStack>]
|
@@ -56,10 +56,14 @@ module RelatonBib
|
|
56
56
|
else
|
57
57
|
builder.parent["language"] = language.join(",") if language&.any?
|
58
58
|
builder.parent["script"] = script.join(",") if script&.any?
|
59
|
-
builder.parent <<
|
59
|
+
builder.parent << escaped_content # .encode(xml: :text)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
def escaped_content
|
64
|
+
content.encode("UTF-8") # .gsub(/&/, "&").gsub(/"/, """).gsub(/'/, "'")
|
65
|
+
end
|
66
|
+
|
63
67
|
# @return [Hash]
|
64
68
|
def to_hash # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
65
69
|
if content.is_a? String
|
@@ -77,7 +81,7 @@ module RelatonBib
|
|
77
81
|
# @param count [Integer] number of elements
|
78
82
|
# @return [String]
|
79
83
|
def to_asciibib(prefix = "", count = 1, has_attrs = false) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
80
|
-
pref = prefix.empty? ? prefix : prefix
|
84
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
81
85
|
if content.is_a? String
|
82
86
|
unless language&.any? || script&.any? || has_attrs
|
83
87
|
return "#{prefix}:: #{content}\n"
|
@@ -70,17 +70,18 @@ module RelatonBib
|
|
70
70
|
|
71
71
|
# rubocop:disable Metrics/MethodLength
|
72
72
|
|
73
|
-
# @param
|
74
|
-
# @param
|
75
|
-
# @
|
76
|
-
# @
|
77
|
-
# @
|
78
|
-
# @
|
79
|
-
# @
|
80
|
-
# @
|
81
|
-
# @
|
82
|
-
# @
|
83
|
-
# @
|
73
|
+
# @param docnumber [String]
|
74
|
+
# @param args [Hash]
|
75
|
+
# @option args [String, nil] :type
|
76
|
+
# @option args [Array<String>] :agency
|
77
|
+
# @option args [Stirng, nil] :class
|
78
|
+
# @option args [String, nil] :partnumber
|
79
|
+
# @option args [String, nil] :edition
|
80
|
+
# @option args [String, nil] :version
|
81
|
+
# @option args [String, nil] :supplementtype
|
82
|
+
# @option args [String, nil] :supplementnumber
|
83
|
+
# @option args [String, nil] :language
|
84
|
+
# @option args [String, nil] :year
|
84
85
|
def initialize(docnumber:, **args)
|
85
86
|
@type = args[:type]
|
86
87
|
@agency = args[:agency]
|
data/lib/relaton_bib/version.rb
CHANGED
@@ -11,7 +11,7 @@ module RelatonBib
|
|
11
11
|
bib_item item_data(bibitem)
|
12
12
|
else
|
13
13
|
warn "[relaton-bib] WARNING: can't find bibitem or bibdata element "\
|
14
|
-
|
14
|
+
"in the XML"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -320,7 +320,8 @@ module RelatonBib
|
|
320
320
|
# @return [Array<RelatonBib::FormattedString>]
|
321
321
|
def fetch_abstract(item)
|
322
322
|
item.xpath("./abstract").map do |a|
|
323
|
-
|
323
|
+
c = a.children.to_s
|
324
|
+
FormattedString.new(content: c, language: a[:language],
|
324
325
|
script: a[:script], format: a[:format])
|
325
326
|
end
|
326
327
|
end
|
data/lib/relaton_bib.rb
CHANGED
@@ -42,10 +42,10 @@ module RelatonBib
|
|
42
42
|
# @param array [Array]
|
43
43
|
# @return [Array<String>, String]
|
44
44
|
def single_element_array(array)
|
45
|
-
if array.size > 1
|
46
|
-
|
47
|
-
else
|
48
|
-
|
49
|
-
end
|
45
|
+
# if array.size > 1
|
46
|
+
array.map { |e| e.is_a?(String) ? e : e.to_hash }
|
47
|
+
# else
|
48
|
+
# array.first.is_a?(String) ? array[0] : array.first&.to_hash
|
49
|
+
# end
|
50
50
|
end
|
51
51
|
end
|
data/relaton-bib.gemspec
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.9.
|
4
|
+
version: 1.9.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -182,16 +182,16 @@ dependencies:
|
|
182
182
|
name: nokogiri
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- - "
|
185
|
+
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
187
|
+
version: 1.12.5
|
188
188
|
type: :runtime
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- - "
|
192
|
+
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
194
|
+
version: 1.12.5
|
195
195
|
description: 'RelatonBib: Ruby XMLDOC impementation.'
|
196
196
|
email:
|
197
197
|
- open.source@ribose.com
|