relaton-bib 1.9.7 → 1.9.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/lib/relaton_bib/bibliographic_item.rb +37 -10
- data/lib/relaton_bib/bibxml_parser.rb +8 -6
- data/lib/relaton_bib/contribution_info.rb +3 -1
- data/lib/relaton_bib/editorial_group.rb +1 -1
- data/lib/relaton_bib/person.rb +3 -3
- data/lib/relaton_bib/typed_uri.rb +2 -2
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3f1dc44ef7d2716e9dab35fdb81005962960fb608d388b2d556073758f3cf25
|
4
|
+
data.tar.gz: e31e80c8a248a626bf83bc85e0f3d781544e5461c65e805d1a8ff45025808caa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90256a1674ec5311fd7fedb5d0822a5cb10bb9ecaf6c7f5865d74b9a28e6b4feaa969fae327610726720524010db1f1d290dbad48902a3b6e4a86e468542179f
|
7
|
+
data.tar.gz: 29cfeccc2388db9096b094274653800499a4a40a52b7102e9283e64030e921edd37a93ea8c70f92cd2056ac654a2e8b9a4184ca08a05863365f12fa6c15e6305
|
data/.rubocop.yml
CHANGED
@@ -159,10 +159,11 @@ module RelatonBib
|
|
159
159
|
# @option copyright [String, NilClass] :to
|
160
160
|
# @option copyright [String, NilClass] :scope
|
161
161
|
#
|
162
|
-
# @param date [Array<Hash>]
|
162
|
+
# @param date [Array<Hash, RelatonBib::BibliographicDate>]
|
163
163
|
# @option date [String] :type
|
164
|
-
# @option date [String] :from
|
165
|
-
# @option date [String] :to
|
164
|
+
# @option date [String, nil] :from required if :on is nil
|
165
|
+
# @option date [String, nil] :to
|
166
|
+
# @option date [String, nil] :on required if :from is nil
|
166
167
|
#
|
167
168
|
# @param contributor [Array<Hash>]
|
168
169
|
# @option contributor [RealtonBib::Organization, RelatonBib::Person]
|
@@ -176,7 +177,7 @@ module RelatonBib
|
|
176
177
|
# @option abstract [String] :content
|
177
178
|
# @option abstract [String] :language
|
178
179
|
# @option abstract [String] :script
|
179
|
-
# @option abstract [String] :
|
180
|
+
# @option abstract [String] :format
|
180
181
|
#
|
181
182
|
# @param relation [Array<Hash>]
|
182
183
|
# @option relation [String] :type
|
@@ -330,7 +331,7 @@ module RelatonBib
|
|
330
331
|
#
|
331
332
|
# @param [Nokogiri::XML::Builder, nil] builder
|
332
333
|
#
|
333
|
-
# @return [String]
|
334
|
+
# @return [String, Nokogiri::XML::Builder::NodeBuilder] XML
|
334
335
|
#
|
335
336
|
def to_bibxml(builder = nil)
|
336
337
|
if builder
|
@@ -338,8 +339,8 @@ module RelatonBib
|
|
338
339
|
else
|
339
340
|
Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
|
340
341
|
render_bibxml xml
|
341
|
-
end
|
342
|
-
end
|
342
|
+
end.doc.root.to_xml
|
343
|
+
end
|
343
344
|
end
|
344
345
|
|
345
346
|
# @return [Hash]
|
@@ -760,13 +761,40 @@ module RelatonBib
|
|
760
761
|
# rubocop:enable Style/NestedParenthesizedCalls, Metrics/BlockLength
|
761
762
|
|
762
763
|
#
|
763
|
-
# Render BibXML (RFC)
|
764
|
+
# Render BibXML (RFC, BCP)
|
764
765
|
#
|
765
766
|
# @param [Nokogiri::XML::Builder] builder
|
766
767
|
#
|
767
768
|
def render_bibxml(builder)
|
768
769
|
target = link.detect { |l| l.type == "src" } || link.detect { |l| l.type == "doi" }
|
769
|
-
bxml =
|
770
|
+
bxml = if docnumber&.match(/^BCP/) || docidentifier[0].id.include?("BCP")
|
771
|
+
render_bibxml_refgroup(builder)
|
772
|
+
else
|
773
|
+
render_bibxml_ref(builder)
|
774
|
+
end
|
775
|
+
bxml[:target] = target.content.to_s if target
|
776
|
+
end
|
777
|
+
|
778
|
+
#
|
779
|
+
# Render BibXML (BCP)
|
780
|
+
#
|
781
|
+
# @param [Nokogiri::XML::Builder] builder
|
782
|
+
#
|
783
|
+
def render_bibxml_refgroup(builder)
|
784
|
+
builder.referencegroup(anchor: anchor) do |b|
|
785
|
+
relation.each do |r|
|
786
|
+
r.bibitem.to_bibxml(b) if r.type == "includes"
|
787
|
+
end
|
788
|
+
end
|
789
|
+
end
|
790
|
+
|
791
|
+
#
|
792
|
+
# Render BibXML (RFC)
|
793
|
+
#
|
794
|
+
# @param [Nokogiri::XML::Builder] builder
|
795
|
+
#
|
796
|
+
def render_bibxml_ref(builder)
|
797
|
+
builder.reference(anchor: anchor) do |xml|
|
770
798
|
xml.front do
|
771
799
|
xml.title title[0].title.content if title.any?
|
772
800
|
render_seriesinfo xml
|
@@ -777,7 +805,6 @@ module RelatonBib
|
|
777
805
|
render_abstract xml
|
778
806
|
end
|
779
807
|
end
|
780
|
-
bxml[:target] = target.content.to_s if target
|
781
808
|
end
|
782
809
|
|
783
810
|
def anchor
|
@@ -67,11 +67,12 @@ module RelatonBib
|
|
67
67
|
#
|
68
68
|
def docids(reference, ver) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
|
69
69
|
ret = []
|
70
|
-
sfid = reference.at("./seriesInfo[@name='#{self::FLAVOR}']",
|
70
|
+
sfid = reference.at("./seriesInfo[@name='#{self::FLAVOR}']",
|
71
|
+
"./front/seriesInfo[@name='#{self::FLAVOR}']")
|
71
72
|
if sfid
|
72
73
|
ret << DocumentIdentifier.new(type: sfid[:name], id: sfid[:value])
|
73
74
|
elsif self::FLAVOR && (id = (reference[:anchor] || reference[:docName] || reference[:number]))
|
74
|
-
ret << DocumentIdentifier.new(
|
75
|
+
ret << DocumentIdentifier.new(type: self::FLAVOR, id: id.sub(/^(RFC)/, "\\1 "))
|
75
76
|
end
|
76
77
|
if (id = reference[:anchor])
|
77
78
|
ret << DocumentIdentifier.new(type: "rfc-anchor", id: id)
|
@@ -138,10 +139,9 @@ module RelatonBib
|
|
138
139
|
# @return [Array<RelatonBib::FormattedString>]
|
139
140
|
def abstracts(ref)
|
140
141
|
ref.xpath("./front/abstract").map do |a|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
)
|
142
|
+
c = a.children.to_s.gsub(/\s*(<\/?)t(>)\s*/, '\1p\2').gsub(/\n/, "").squeeze " "
|
143
|
+
FormattedString.new(content: c, language: language(ref), script: "Latn",
|
144
|
+
format: "text/html")
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
@@ -288,6 +288,8 @@ module RelatonBib
|
|
288
288
|
d = [date[:year], month(date[:month]), (date[:day] || 1)].compact.join "-"
|
289
289
|
date = Time.parse(d).strftime "%Y-%m-%d"
|
290
290
|
[BibliographicDate.new(type: "published", on: date)]
|
291
|
+
rescue ArgumentError
|
292
|
+
[]
|
291
293
|
end
|
292
294
|
|
293
295
|
# @param reference [Nokogiri::XML::Element]
|
@@ -82,6 +82,8 @@ module RelatonBib
|
|
82
82
|
|
83
83
|
# @param entity [RelatonBib::Person, RelatonBib::Organization]
|
84
84
|
# @param role [Array<Hash>]
|
85
|
+
# @option role [String] :type
|
86
|
+
# @option role [Array<String>] :description
|
85
87
|
def initialize(entity:, role: [])
|
86
88
|
if role.empty?
|
87
89
|
role << { type: entity.is_a?(Person) ? "author" : "publisher" }
|
@@ -94,7 +96,7 @@ module RelatonBib
|
|
94
96
|
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
95
97
|
# @option opts [String, Symbol] :lang language
|
96
98
|
def to_xml(**opts)
|
97
|
-
entity.to_xml
|
99
|
+
entity.to_xml(**opts)
|
98
100
|
end
|
99
101
|
|
100
102
|
# @return [Hash]
|
data/lib/relaton_bib/person.rb
CHANGED
@@ -189,8 +189,8 @@ module RelatonBib
|
|
189
189
|
# @option opts [String, Symbol] :lang language
|
190
190
|
def to_xml(**opts)
|
191
191
|
opts[:builder].person do |builder|
|
192
|
-
name.to_xml
|
193
|
-
affiliation.each { |a| a.to_xml
|
192
|
+
name.to_xml(**opts)
|
193
|
+
affiliation.each { |a| a.to_xml(**opts) }
|
194
194
|
identifier.each { |id| id.to_xml builder }
|
195
195
|
contact.each { |contact| contact.to_xml builder }
|
196
196
|
end
|
@@ -210,7 +210,7 @@ module RelatonBib
|
|
210
210
|
# @count [Integer] number of persons
|
211
211
|
# @return [String]
|
212
212
|
def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/AbcSize
|
213
|
-
pref = prefix.sub
|
213
|
+
pref = prefix.sub(/\*$/, "person")
|
214
214
|
out = count > 1 ? "#{pref}::\n" : ""
|
215
215
|
out += name.to_asciibib pref
|
216
216
|
affiliation.each { |af| out += af.to_asciibib pref, affiliation.size }
|
@@ -5,7 +5,7 @@ module RelatonBib
|
|
5
5
|
class TypedUri
|
6
6
|
# @return [Symbol] :src/:obp/:rss
|
7
7
|
attr_reader :type
|
8
|
-
# @retutn [URI]
|
8
|
+
# @retutn [Addressable::URI]
|
9
9
|
attr_reader :content
|
10
10
|
|
11
11
|
# @param type [String, NilClass] src/obp/rss
|
@@ -37,7 +37,7 @@ module RelatonBib
|
|
37
37
|
# @param count [Integer] number of links
|
38
38
|
# @return [String]
|
39
39
|
def to_asciibib(prefix = "", count = 1)
|
40
|
-
pref = prefix.empty? ? "link" : prefix
|
40
|
+
pref = prefix.empty? ? "link" : "#{prefix}.link"
|
41
41
|
out = count > 1 ? "#{pref}::\n" : ""
|
42
42
|
out += "#{pref}.type:: #{type}\n" if type
|
43
43
|
out += "#{pref}.content:: #{content}\n"
|
data/lib/relaton_bib/version.rb
CHANGED
data/lib/relaton_bib.rb
CHANGED
@@ -14,9 +14,9 @@ module RelatonBib
|
|
14
14
|
class RequestError < StandardError; end
|
15
15
|
|
16
16
|
class << self
|
17
|
-
# @param date [String, Integer, Date]
|
18
|
-
# @param str [Boolean]
|
19
|
-
# @return [Date, nil]
|
17
|
+
# @param date [String, Integer, Date] date
|
18
|
+
# @param str [Boolean] return string or Date
|
19
|
+
# @return [Date, String, nil] date
|
20
20
|
def parse_date(date, str = true) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity,Metrics/AbcSize
|
21
21
|
return date if date.is_a?(Date)
|
22
22
|
|
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.11
|
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-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|