relaton-bib 1.9.11 → 1.9.12

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: a3f1dc44ef7d2716e9dab35fdb81005962960fb608d388b2d556073758f3cf25
4
- data.tar.gz: e31e80c8a248a626bf83bc85e0f3d781544e5461c65e805d1a8ff45025808caa
3
+ metadata.gz: 791772f93f6ec77db4778d4b983bd5b8238342ce83e3b1ebc7ab57f249a13d20
4
+ data.tar.gz: fffd96ca42623382338182a6cb6532fde99c18ebddfd516808f49eb493d31cd6
5
5
  SHA512:
6
- metadata.gz: 90256a1674ec5311fd7fedb5d0822a5cb10bb9ecaf6c7f5865d74b9a28e6b4feaa969fae327610726720524010db1f1d290dbad48902a3b6e4a86e468542179f
7
- data.tar.gz: 29cfeccc2388db9096b094274653800499a4a40a52b7102e9283e64030e921edd37a93ea8c70f92cd2056ac654a2e8b9a4184ca08a05863365f12fa6c15e6305
6
+ metadata.gz: b5440de1b9a0555946b6be63f5c557d9f91b54c247d5876e5f8aaf4e74bfefa1f91d526a1453c99a401e2d82e03ed07af66e2f950a4e0f51d844e9ba0738c427
7
+ data.tar.gz: 8addf5e0b704189efdb1a6f871553c79ef23d1c38c324e728d9e72151a9c7317029340f3b0f4ad25b394a6acfcee679532c3f323a37aab0b0946bb33ce88461a
@@ -766,7 +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 == "src" } || link.detect { |l| l.type == "doi" }
769
+ target = link.detect { |l| l.type == "src" } ||
770
+ link.detect { |l| l.type == "doi" }
770
771
  bxml = if docnumber&.match(/^BCP/) || docidentifier[0].id.include?("BCP")
771
772
  render_bibxml_refgroup(builder)
772
773
  else
@@ -781,7 +782,7 @@ module RelatonBib
781
782
  # @param [Nokogiri::XML::Builder] builder
782
783
  #
783
784
  def render_bibxml_refgroup(builder)
784
- builder.referencegroup(anchor: anchor) do |b|
785
+ builder.referencegroup(**ref_attrs) do |b|
785
786
  relation.each do |r|
786
787
  r.bibitem.to_bibxml(b) if r.type == "includes"
787
788
  end
@@ -794,7 +795,7 @@ module RelatonBib
794
795
  # @param [Nokogiri::XML::Builder] builder
795
796
  #
796
797
  def render_bibxml_ref(builder)
797
- builder.reference(anchor: anchor) do |xml|
798
+ builder.reference(**ref_attrs) do |xml|
798
799
  xml.front do
799
800
  xml.title title[0].title.content if title.any?
800
801
  render_seriesinfo xml
@@ -807,18 +808,27 @@ module RelatonBib
807
808
  end
808
809
  end
809
810
 
810
- def anchor
811
- did = docidentifier.detect { |di| di.type == "rfc-anchor" }
812
- return did.id if did
811
+ def ref_attrs
812
+ discopes = %w[anchor docName number]
813
+ attrs = docidentifier.each_with_object({}) do |di, h|
814
+ next unless discopes.include?(di.scope)
813
815
 
814
- type = docidentifier[0].type
815
- "#{type}.#{docnumber}"
816
+ h[di.scope.to_sym] = di.id
817
+ end
818
+ # did = docidentifier.detect { |di| di.type == "rfc-anchor" }
819
+ return attrs if attrs.any?
820
+
821
+ docidentifier.first&.tap do |di|
822
+ return { anchor: di.id }
823
+ end
816
824
  end
817
825
 
826
+ # def id_to_ref_attr(id)
827
+ # id.sub(/^(RFC|BCP)\s/, '\1').sub(/^(\d?[A-Z]+)\s/, '\1.')
828
+ # end
829
+
818
830
  def render_keyword(builder)
819
- keyword.each do |kw|
820
- builder.keyword kw.content
821
- end
831
+ keyword.each { |kw| builder.keyword kw.content }
822
832
  end
823
833
 
824
834
  def render_workgroup(builder)
@@ -45,7 +45,7 @@ module RelatonBib
45
45
  end
46
46
 
47
47
  # @param attrs [Hash]
48
- # @return [RelatonBib::IetfBibliographicItem]
48
+ # @return [RelatonBib::BibliographicItem]
49
49
  def bib_item(**attrs)
50
50
  # attrs[:place] = ["Fremont, CA"]
51
51
  BibliographicItem.new(**attrs)
@@ -70,13 +70,21 @@ module RelatonBib
70
70
  sfid = reference.at("./seriesInfo[@name='#{self::FLAVOR}']",
71
71
  "./front/seriesInfo[@name='#{self::FLAVOR}']")
72
72
  if sfid
73
- ret << DocumentIdentifier.new(type: sfid[:name], id: sfid[:value])
74
- elsif self::FLAVOR && (id = (reference[:anchor] || reference[:docName] || reference[:number]))
75
- ret << DocumentIdentifier.new(type: self::FLAVOR, id: id.sub(/^(RFC)/, "\\1 "))
76
- end
77
- if (id = reference[:anchor])
78
- ret << DocumentIdentifier.new(type: "rfc-anchor", id: id)
73
+ type = sfid[:name]
74
+ id = sfid[:value]
75
+ scope = "series"
76
+ else # if self::FLAVOR
77
+ id, scope = if reference[:anchor] then [reference[:anchor], "anchor"]
78
+ elsif reference[:docName] then [reference[:docName], "docName"]
79
+ elsif reference[:number] then [reference[:number], "number"]
80
+ end
81
+ id&.match(/^(3GPP|W3C|[A-Z]{2,})(?:\.(?=[A-Z])|(?=\d))/)
82
+ type = self::FLAVOR || ($~ && $~[1])
79
83
  end
84
+ ret << DocumentIdentifier.new(type: type, id: id, scope: scope) if id
85
+ # if (id = reference[:anchor])
86
+ # ret << DocumentIdentifier.new(type: "rfc-anchor", id: id)
87
+ # end
80
88
  ret + reference.xpath("./seriesInfo", "./front/seriesInfo").map do |si|
81
89
  next unless SERIESINFONAMES.include? si[:name]
82
90
 
@@ -139,7 +147,8 @@ module RelatonBib
139
147
  # @return [Array<RelatonBib::FormattedString>]
140
148
  def abstracts(ref)
141
149
  ref.xpath("./front/abstract").map do |a|
142
- c = a.children.to_s.gsub(/\s*(<\/?)t(>)\s*/, '\1p\2').gsub(/\n/, "").squeeze " "
150
+ c = a.children.to_s.gsub(/\s*(<\/?)t(>)\s*/, '\1p\2')
151
+ .gsub(/[\t\n]/, " ").squeeze " "
143
152
  FormattedString.new(content: c, language: language(ref), script: "Latn",
144
153
  format: "text/html")
145
154
  end
@@ -244,7 +253,7 @@ module RelatonBib
244
253
  # @rerurn [RelatonBib::Address]
245
254
  def address(postal) # rubocop:disable Metrics/CyclomaticComplexity
246
255
  street = [
247
- (postal.at("./postalLine") || postal.at("./street"))&.text
256
+ (postal.at("./postalLine") || postal.at("./street"))&.text,
248
257
  ].compact
249
258
  Address.new(
250
259
  street: street,
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.9.11".freeze
2
+ VERSION = "1.9.12".freeze
3
3
  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.9.11
4
+ version: 1.9.12
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-12-24 00:00:00.000000000 Z
11
+ date: 2021-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug