relaton-ietf 1.12.2 → 1.12.5

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: 51a0a92632baaeef663f07d26c692121d027673a0ab55ac75be6d4b8d2ed7995
4
- data.tar.gz: 0f89bdc4e3c3540a07d13c8a358c067951c662af3aa2dd44d78b229c204c9c24
3
+ metadata.gz: 0eddad3431b1f0aade4e139456c33ae9cd067eaec9dd38b64257be00e285efd7
4
+ data.tar.gz: 156d9d50c7964ec4167526fc1f31460134c717fbd48c4dd41b7d4bc42450c094
5
5
  SHA512:
6
- metadata.gz: 7129d5d8825e51a9b4eb9340fe897bddd008e8017de20e6c358fe0d8cb6a1d753577f36bdbe9fcd8eb87b0f8438e84aa44c6e2426cacd176189e321a26d64bcc
7
- data.tar.gz: 2064f8d3f4838ec4f976f6a3e5dc257badf87db2eb0e5051e66b9256fc906f179fdc63452873052cf3720b00b28f530de9f3aef4e1fefae9a605f89dd89c9e6b
6
+ metadata.gz: ab78ea185c4bf6e7be09f78a7457f36ac3f1951b46bc0b2c3c33b6465fcdee9cdad00cb69f3fc606144bba3efe2e94e765a340933d129a67dfd29aa6c8dfa14f
7
+ data.tar.gz: 8e5e48e4257c89edcca19c85e54d5ef2dfc8a941ebed64cd3b826f63373774d25f2ef6b9c65ae2752e36fb7efa118874be489e5ee9f6faefceae674d9919e4dd
@@ -33,7 +33,7 @@ module RelatonIetf
33
33
  def self.fetch(source, output: "data", format: "yaml")
34
34
  t1 = Time.now
35
35
  puts "Started at: #{t1}"
36
- FileUtils.mkdir_p output unless Dir.exist? output
36
+ FileUtils.mkdir_p output # unless Dir.exist? output
37
37
  new(source, output, format).fetch
38
38
  t2 = Time.now
39
39
  puts "Stopped at: #{t2}"
@@ -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(/^#{match[:series]}-\d{2}/)
96
96
  create_series match[:series], bib_versions
97
97
  series = match[:series]
98
98
  end
@@ -114,7 +114,7 @@ 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
117
+ def create_series(ref, versions) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
118
118
  return if versions.size < 2
119
119
 
120
120
  vs = versions.sort_by { |v| v.match(/\d+$/).to_s.to_i }
@@ -123,7 +123,8 @@ module RelatonIetf
123
123
  rel = vs.map { |v| version_relation v, "includes" }
124
124
  last_v = HashConverter.hash_to_bib YAML.load_file("#{@output}/#{vs.last}.#{@ext}")
125
125
  bib = IetfBibliographicItem.new(
126
- title: last_v[:title], abstract: last_v[:abstract], formattedref: fref, docid: [docid], relation: rel,
126
+ title: last_v[:title], abstract: last_v[:abstract], formattedref: fref,
127
+ fetched: Date.today.to_s, docid: [docid], relation: rel
127
128
  )
128
129
  save_doc bib
129
130
  end
@@ -21,7 +21,8 @@ module RelatonIetf
21
21
  warn "[relaton-ietf] (\"#{code}\") fetching..."
22
22
  result = search code
23
23
  if result
24
- warn "[relaton-ietf] (\"#{code}\") found #{result.docidentifier.first.id}"
24
+ docid = result.docidentifier.detect(&:primary) || result.docidentifier.first
25
+ warn "[relaton-ietf] (\"#{code}\") found #{docid.id}"
25
26
  else
26
27
  warn "[relaton-ietf] (\"#{code}\") not found"
27
28
  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
  #
@@ -5,18 +5,17 @@ module RelatonIetf
5
5
  module Scrapper
6
6
  extend Scrapper
7
7
 
8
- IDS = "https://raw.githubusercontent.com/ietf-ribose/relaton-data-ids/main/data/"
9
- RFC = "https://raw.githubusercontent.com/ietf-ribose/relaton-data-rfcs/main/data/"
10
- RSS = "https://raw.githubusercontent.com/ietf-ribose/relaton-data-rfcsubseries/main/data/"
8
+ IDS = "https://raw.githubusercontent.com/relaton/relaton-data-ids/main/data/"
9
+ RFC = "https://raw.githubusercontent.com/relaton/relaton-data-rfcs/main/data/"
10
+ RSS = "https://raw.githubusercontent.com/relaton/relaton-data-rfcsubseries/main/data/"
11
11
 
12
12
  # @param text [String]
13
- # @param is_relation [TrueClass, FalseClass]
14
13
  # @return [RelatonIetf::IetfBibliographicItem]
15
- def scrape_page(text, is_relation: false)
14
+ def scrape_page(text)
16
15
  # Remove initial "IETF " string if specified
17
16
  ref = text.gsub(/^IETF /, "")
18
17
  ref.sub!(/(?<=^(?:RFC|BCP|FYI|STD))\s(\d+)/) { $1.rjust 4, "0" }
19
- rfc_item ref, is_relation
18
+ rfc_item ref
20
19
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
21
20
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
22
21
  Net::ProtocolError, SocketError
@@ -26,9 +25,8 @@ module RelatonIetf
26
25
  private
27
26
 
28
27
  # @param ref [String]
29
- # @param is_relation [Boolen, nil]
30
28
  # @return [RelatonIetf::IetfBibliographicItem]
31
- def rfc_item(ref, is_relation)
29
+ def rfc_item(ref) # rubocop:disable Metrics/MethodLength
32
30
  ghurl = case ref
33
31
  when /^RFC/ then RFC
34
32
  when /^(?:BCP|FYI|STD)/ then RSS
@@ -1,3 +1,3 @@
1
1
  module RelatonIetf
2
- VERSION = "1.12.2".freeze
2
+ VERSION = "1.12.5".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.2
4
+ version: 1.12.5
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-29 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