relaton-ietf 1.12.3 → 1.12.6

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: d11fb2dfa0df019e33ac1b60faf21a8823473d965fdc67815bb788fd2898471c
4
- data.tar.gz: 4c3446caa2b71be202528aae5ab9b0c1c79f0b85ca422930986347bd51312265
3
+ metadata.gz: '029ac486811190a8734f2b620b92a99b5270e8f100a793901d96052c71f6dbed'
4
+ data.tar.gz: 2cb2fc3ef85479025d220878b3796587de1ce3622c1372f21faeaa37d581775d
5
5
  SHA512:
6
- metadata.gz: 78caccd01344b810325d661c921aec1b908cbe363b39aa48534b84f3f0726231c90cc70adf82585ed3fa42c466ab2b8b409d54e73c0d02bbea58064969449169
7
- data.tar.gz: 1484d8c01e99a419faef0c50be081a62b4ea1ed630dda2a5f115c23ae3a56488813ab7cadd3beeefbdbf6eeff95e2b97bf67788e497319d883381757b9996077
6
+ metadata.gz: 2da2657783478b1fa88cf1669fb5d5e1f556baed0d43e4efbbf8728309dc10c27a6ffd073653f80e97b3eb9619776fac8ee78264868ce2bcfb0ef8dad38f1298
7
+ data.tar.gz: 5828a4b7d87cc7c258c213c5a3bb6d0cd7ed11f7c60d5eaaf8ede3ed8d65213a1d7fefe7254705ce9f1355e4450e7903bfb0859067ad4d205c43f31c6fd1d9cf
@@ -67,7 +67,7 @@ module RelatonIetf
67
67
  versions = Dir["bibxml-ids/*.xml"].each_with_object([]) do |path, vers|
68
68
  file = File.basename path, ".xml"
69
69
  if file.include?("D.draft-")
70
- vers << file.sub(/^reference\.I-D\./, "")
70
+ vers << file.sub(/^reference\.I-D\./, "").downcase
71
71
  /(?<ver>\d+)$/ =~ file
72
72
  end
73
73
  bib = BibXMLParser.parse(File.read(path, encoding: "UTF-8"))
@@ -92,7 +92,7 @@ module RelatonIetf
92
92
  match = /(?<series>draft-.+)-(?<ver>\d{2})\.#{@ext}$/.match file
93
93
  if match
94
94
  if series != match[:series]
95
- bib_versions = versions.select { |ref| ref.include? match[:series] }
95
+ bib_versions = versions.grep(/^#{Regexp.quote match[:series]}-\d{2}/)
96
96
  create_series match[:series], bib_versions
97
97
  series = match[:series]
98
98
  end
@@ -114,16 +114,15 @@ module RelatonIetf
114
114
  # @param [String] ref reference
115
115
  # @param [Array<String>] versions list of versions
116
116
  #
117
- def create_series(ref, versions) # rubocop:disable Metrics/AbcSize
118
- return if versions.size < 2
119
-
117
+ def create_series(ref, versions) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
120
118
  vs = versions.sort_by { |v| v.match(/\d+$/).to_s.to_i }
121
119
  fref = RelatonBib::FormattedRef.new content: ref
122
120
  docid = RelatonBib::DocumentIdentifier.new type: "Internet-Draft", id: ref, primary: true
123
121
  rel = vs.map { |v| version_relation v, "includes" }
124
122
  last_v = HashConverter.hash_to_bib YAML.load_file("#{@output}/#{vs.last}.#{@ext}")
125
123
  bib = IetfBibliographicItem.new(
126
- title: last_v[:title], abstract: last_v[:abstract], formattedref: fref, docid: [docid], relation: rel,
124
+ title: last_v[:title], abstract: last_v[:abstract], formattedref: fref,
125
+ fetched: Date.today.to_s, docid: [docid], relation: rel
127
126
  )
128
127
  save_doc bib
129
128
  end
@@ -151,8 +151,8 @@ module RelatonIetf
151
151
  # @return [Array<RelatonBib::ContributionInfo>] document contributors
152
152
  #
153
153
  def parse_contributor # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
154
- @doc.xpath("./xmlns:author").map do |contributor| # rubocop:disable Metrics/BlockLength
155
- n = contributor.at("./xmlns:name").text
154
+ @doc.xpath("./xmlns:author").map do |contrib| # rubocop:disable Metrics/BlockLength
155
+ n = contrib.at("./xmlns:name").text
156
156
  case n
157
157
  when "ISO"
158
158
  entity = RelatonBib::Organization.new(abbrev: n, name: "International Organization for Standardization")
@@ -186,17 +186,28 @@ module RelatonIetf
186
186
  when "International Telegraph and Telephone Consultative Committee of the International Telecommunication Union"
187
187
  entity = RelatonBib::Organization.new(abbrev: "CCITT", name: n)
188
188
  else
189
- # int, snm = n.split
190
189
  /^(?:(?<int>(?:\p{Lu}+(?:-\w|\(\w\))?\.{0,2}[-\s]?)+)\s)?(?<snm>[[:alnum:]\s'-.]+)$/ =~ n
191
190
  surname = RelatonBib::LocalizedString.new(snm, "en", "Latn")
192
191
  name = RelatonBib::LocalizedString.new(n, "en", "Latn")
193
192
  fname = RelatonBib::FullName.new(completename: name, initial: initials(int), surname: surname)
194
193
  entity = RelatonBib::Person.new(name: fname)
195
194
  end
196
- RelatonBib::ContributionInfo.new(entity: entity, role: [{ type: "author" }])
195
+ RelatonBib::ContributionInfo.new(entity: entity, role: parse_role(contrib))
197
196
  end
198
197
  end
199
198
 
199
+ #
200
+ # Parse contributors role
201
+ #
202
+ # @param [Nokogiri::XML::Node] contrib <description>
203
+ #
204
+ # @return [Array<Hash>] contributors role
205
+ #
206
+ def parse_role(contrib)
207
+ type = contrib.at("./xmlns:title")&.text&.downcase || "author"
208
+ [{ type: type }]
209
+ end
210
+
200
211
  #
201
212
  # Ctreat initials
202
213
  #
@@ -1,3 +1,3 @@
1
1
  module RelatonIetf
2
- VERSION = "1.12.3".freeze
2
+ VERSION = "1.12.6".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-ietf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.3
4
+ version: 1.12.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-30 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml