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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/relaton_ietf/scrapper.rb +26 -11
- data/lib/relaton_ietf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9de9d3ef1c6d59485dca8cfa75913897da8e19bf44ffe51e41679a48cf198770
|
4
|
+
data.tar.gz: 6bd02dd1323881880830c24ddcd56c7afa9b02c831188fce64d2bec753f074bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a1ada2025ca307a974a7ec20b0ff9c09b36dbe5c3e6a5c3839026b665350a7a79f9eaf9b9076ec5dd0a8dfce0234a045d33b2962be90f781626da279a872311
|
7
|
+
data.tar.gz: 7b3acb128dcd0470cffbeff4cd5aadc02a943268beab9c323b40b2626c04628d3d55aecbb4aa9ac3e2fcea7a323df435146c8bfcc358ba476659108495576039
|
data/Gemfile.lock
CHANGED
@@ -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
|
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
|
29
|
-
when /^I-D/ then rfc_item
|
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
|
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
|
87
|
+
# @param uri_nums [Array<String>]
|
83
88
|
# @param ref [String]
|
84
89
|
# @return [RelatonIetf::IetfBibliographicItem]
|
85
|
-
def rfc_item(
|
86
|
-
uri =
|
87
|
-
|
88
|
-
|
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)]
|
data/lib/relaton_ietf/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|