relaton-ietf 0.6.9 → 0.6.10

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: 434453b0dde2f07fcfb578e3ef63a7bdd1295ffd7ef69030e361920ccf97c60f
4
- data.tar.gz: 5eb7911905fc0ecd2edf822029580b0545b5a2a223cc914815ca6c5b28a6630b
3
+ metadata.gz: 9de9d3ef1c6d59485dca8cfa75913897da8e19bf44ffe51e41679a48cf198770
4
+ data.tar.gz: 6bd02dd1323881880830c24ddcd56c7afa9b02c831188fce64d2bec753f074bb
5
5
  SHA512:
6
- metadata.gz: a4c73b06add12b2d2db70da5d5fe0c45f9a93efba60465b9ed4ae397bf0338c02e93afdff83c926e08aed10793b7b5ae37fd49caa1abe653f45b98bbac221815
7
- data.tar.gz: 6f87bc69748909c8e93453de5c2a89cae15e7f35946f584158bcbcded4dbb0ae6bce999ac3c6122fd599617c2f77dea640fb200c46272479b48138a069c75908
6
+ metadata.gz: 5a1ada2025ca307a974a7ec20b0ff9c09b36dbe5c3e6a5c3839026b665350a7a79f9eaf9b9076ec5dd0a8dfce0234a045d33b2962be90f781626da279a872311
7
+ data.tar.gz: 7b3acb128dcd0470cffbeff4cd5aadc02a943268beab9c323b40b2626c04628d3d55aecbb4aa9ac3e2fcea7a323df435146c8bfcc358ba476659108495576039
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- relaton-ietf (0.6.9)
4
+ relaton-ietf (0.6.10)
5
5
  relaton-bib (~> 0.3.0)
6
6
 
7
7
  GEM
@@ -10,8 +10,8 @@ module RelatonIetf
10
10
 
11
11
  # Scrapper module
12
12
  module Scrapper
13
- RFC_URI_PATTERN = "https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.CODE"
14
- ID_URI_PATTERN = "https://xml2rfc.tools.ietf.org/public/rfc/bibxml-ids/reference.CODE"
13
+ RFC_URI_PATTERN = "https://xml2rfc.tools.ietf.org/public/rfc/bibxml"
14
+ # ID_URI_PATTERN = "https://xml2rfc.tools.ietf.org/public/rfc/bibxml-ids/reference.CODE"
15
15
  BCP_URI_PATTERN = "https://www.rfc-editor.org/info/CODE"
16
16
 
17
17
  class << self
@@ -25,15 +25,20 @@ module RelatonIetf
25
25
  ref = text.gsub(/^IETF /, "")
26
26
 
27
27
  case ref
28
- when /^RFC/ then rfc_item RFC_URI_PATTERN.dup, ref, is_relation
29
- when /^I-D/ then rfc_item ID_URI_PATTERN.dup, ref, is_relation
28
+ when /^RFC/ then rfc_item [""], ref, is_relation
29
+ when /^I-D/ then rfc_item ["3"], ref, is_relation
30
+ when /^W3C/ then rfc_item ["4", "2"], ref, is_relation
31
+ when /^(ANSI|CCITT|FIPS|IANA|ISO|ITU|NIST|OASIS|PKCS)/
32
+ rfc_item ["2"], ref, is_relation
33
+ when /^(3GPP|SDO-3GPP)/ then rfc_item ["5"], ref, is_relation
34
+ when /^IEEE/ then rfc_item ["6", "2"], ref, is_relation
30
35
  when /^BCP/ then bcp_item BCP_URI_PATTERN.dup, ref
31
36
  else
32
37
  raise RelatonBib::RequestError, "#{ref}: not recognised for RFC"
33
38
  end
34
39
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
35
40
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
36
- Net::ProtocolError, SocketError, OpenSSL::SSL::SSLError
41
+ Net::ProtocolError, SocketError
37
42
  raise RelatonBib::RequestError, "No document found for #{ref} reference."
38
43
  end
39
44
 
@@ -79,13 +84,23 @@ module RelatonIetf
79
84
  RelatonIetf::IetfBibliographicItem.new **attrs
80
85
  end
81
86
 
82
- # @param uri_template [String]
87
+ # @param uri_nums [Array<String>]
83
88
  # @param ref [String]
84
89
  # @return [RelatonIetf::IetfBibliographicItem]
85
- def rfc_item(uri_template, ref, is_relation)
86
- uri = uri_template.sub "CODE", ref.sub(/\s|\u00a0/, ".") + ".xml"
87
- doc = Nokogiri::XML get_page(uri)
88
- fetch_rfc doc.at("//reference"), is_relation, uri
90
+ def rfc_item(uri_nums, ref, is_relation)
91
+ uri = nil
92
+ error = nil
93
+ uri_nums.each do |n|
94
+ uri = "#{RFC_URI_PATTERN}#{n}/reference.#{ref.sub(/\s|\u00a0/, ".")}.xml"
95
+ begin
96
+ doc = Nokogiri::XML get_page(uri)
97
+ resp = fetch_rfc doc.at("//reference"), is_relation, uri
98
+ return resp if resp
99
+ rescue RelatonBib::RequestError => e
100
+ error = e
101
+ end
102
+ end
103
+ raise error
89
104
  end
90
105
 
91
106
  # @param uri_template [String]
@@ -255,7 +270,7 @@ module RelatonIetf
255
270
  def dates(reference)
256
271
  return unless (date = reference.at "./front/date")
257
272
 
258
- d = [date[:year], month(date[:month]),
273
+ d = [date[:year], month(date[:month]) || "01",
259
274
  (date[:day] || "01")].compact.join "-"
260
275
  date = Time.parse(d).strftime "%Y-%m-%d"
261
276
  [RelatonBib::BibliographicDate.new(type: "published", on: date)]
@@ -1,3 +1,3 @@
1
1
  module RelatonIetf
2
- VERSION = "0.6.9".freeze
2
+ VERSION = "0.6.10".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: 0.6.9
4
+ version: 0.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-07 00:00:00.000000000 Z
11
+ date: 2019-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler