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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfd2b1c32cf6112b7afbf78584182ca256e7f2404a60c74247da9c7aef1df7c0
4
- data.tar.gz: b39864d2a0b19aaec7bf6d59a2122ca3374bc6eb11030c4c78dd4ba3dbf73ce3
3
+ metadata.gz: a3f1dc44ef7d2716e9dab35fdb81005962960fb608d388b2d556073758f3cf25
4
+ data.tar.gz: e31e80c8a248a626bf83bc85e0f3d781544e5461c65e805d1a8ff45025808caa
5
5
  SHA512:
6
- metadata.gz: d392e4fb2558ccf8f3ac2d814061944cf7bb0bc94bb5afd17183146ec49082d54847bbb9ec9cefa0d98b1be0f487e46d6faed3989036930467645d424ef479fc
7
- data.tar.gz: 970106fad0a8c7799351529c61070ec7a451f6c610b8f78620f282f6b174c184dd759bc740938c3b3eb84217256399f7080dcd5ebc184343b95e928808c458e6
6
+ metadata.gz: 90256a1674ec5311fd7fedb5d0822a5cb10bb9ecaf6c7f5865d74b9a28e6b4feaa969fae327610726720524010db1f1d290dbad48902a3b6e4a86e468542179f
7
+ data.tar.gz: 29cfeccc2388db9096b094274653800499a4a40a52b7102e9283e64030e921edd37a93ea8c70f92cd2056ac654a2e8b9a4184ca08a05863365f12fa6c15e6305
data/.rubocop.yml CHANGED
@@ -2,6 +2,8 @@
2
2
  # https://github.com/riboseinc/oss-guides
3
3
  # All project-specific additions and overrides should be specified in this file.
4
4
 
5
+ require: rubocop-rails
6
+
5
7
  inherit_from:
6
8
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
7
9
  AllCops:
@@ -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] :type
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] <description>
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.doc.root.to_xml
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 = builder.reference(anchor: anchor) do |xml|
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}']", "./front/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( type: self::FLAVOR, id: id.sub(/^(RFC)/, "\\1 "))
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
- FormattedString.new(
142
- content: a.children.to_s.gsub(/(<\/?)t(>)/, '\1p\2'),
143
- language: language(ref), script: "Latn", format: "text/html"
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 **opts
99
+ entity.to_xml(**opts)
98
100
  end
99
101
 
100
102
  # @return [Hash]
@@ -35,7 +35,7 @@ module RelatonBib
35
35
 
36
36
  # @return [true]
37
37
  def presence?
38
- true
38
+ technical_committee.any?
39
39
  end
40
40
  end
41
41
  end
@@ -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 **opts
193
- affiliation.each { |a| a.to_xml **opts }
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 /\*$/, "person"
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 + ".link"
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"
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.9.7".freeze
2
+ VERSION = "1.9.11".freeze
3
3
  end
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.7
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-19 00:00:00.000000000 Z
11
+ date: 2021-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug