relaton-ietf 1.7.4 → 1.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +15 -4
- data/lib/relaton_ietf/hash_converter.rb +1 -1
- data/lib/relaton_ietf/ietf_bibliography.rb +5 -1
- data/lib/relaton_ietf/scrapper.rb +27 -20
- data/lib/relaton_ietf/version.rb +1 -1
- data/relaton_ietf.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7026502f569da127c8de60c69942d7c30959b942edf9b60e26145672f5f3e362
|
4
|
+
data.tar.gz: f8873f10d5cdf54fba4c5a097988eccfdc5607dfcc754b739bcc8380c70719e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93e3c02df7e66931b857c8578cc80ed91f02ddb72fb2779413611789f0768bcff3a76fd8e1d11b625390ae14f0a115584ccba7d4afc31144e76168ca0aa929b7
|
7
|
+
data.tar.gz: 6c827a3ea89d38f28e6ec5b0b2c3bbe490ec1ea88f400821d14ff21c548dfda0527ba741b743505fe06dfa2661821caf428689cbc474535a77b5f6baac38b33f
|
data/README.adoc
CHANGED
@@ -33,19 +33,30 @@ Or install it yourself as:
|
|
33
33
|
|
34
34
|
== Usage
|
35
35
|
|
36
|
-
===
|
36
|
+
=== Fetching documents
|
37
37
|
|
38
38
|
[source,ruby]
|
39
39
|
----
|
40
40
|
require 'relaton_ietf'
|
41
41
|
|
42
|
-
|
42
|
+
# Fetch RFC document
|
43
|
+
item = RelatonIetf::IetfBibliography.get 'IETF RFC 8341'
|
44
|
+
[relaton-ietf] ("IETF RFC 8341") fetching...
|
45
|
+
[relaton-ietf] ("IETF RFC 8341") found RFC 8341
|
43
46
|
=> #<RelatonIetf::IetfBibliographicItem:0x007fd1875e7f58
|
44
47
|
...
|
45
48
|
|
49
|
+
# Fetch Internet-Draft document
|
50
|
+
RelatonIetf::IetfBibliography.get 'IETF I-D.abarth-cake-02'
|
51
|
+
[relaton-ietf] ("IETF I-D.abarth-cake-02") fetching...
|
52
|
+
[relaton-ietf] ("IETF I-D.abarth-cake-02") found I-D.abarth-cake
|
53
|
+
=> #<RelatonIetf::IetfBibliographicItem:0x00007fa7c81688f8
|
54
|
+
...
|
55
|
+
|
46
56
|
# Return nil if document doesn't exist.
|
47
|
-
RelatonIetf::IetfBibliography.
|
48
|
-
|
57
|
+
RelatonIetf::IetfBibliography.get 'IETF 1111'
|
58
|
+
[relaton-ietf] ("IETF 1111") fetching...
|
59
|
+
[relaton-ietf] ("IETF 1111") not found
|
49
60
|
=> nil
|
50
61
|
----
|
51
62
|
|
@@ -20,7 +20,11 @@ module RelatonIetf
|
|
20
20
|
def get(code, _year = nil, _opts = {})
|
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}"
|
25
|
+
else
|
26
|
+
warn "[relaton-ietf] (\"#{code}\") not found"
|
27
|
+
end
|
24
28
|
result
|
25
29
|
end
|
26
30
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "net/http"
|
4
|
-
require "nokogiri"
|
5
4
|
require "relaton_bib"
|
6
5
|
require "relaton_ietf/ietf_bibliographic_item"
|
7
6
|
|
@@ -17,16 +16,16 @@ module RelatonIetf
|
|
17
16
|
# @param text [String]
|
18
17
|
# @param is_relation [TrueClass, FalseClass]
|
19
18
|
# @return [RelatonIetf::IetfBibliographicItem]
|
20
|
-
def scrape_page(text, is_relation
|
19
|
+
def scrape_page(text, is_relation: false)
|
21
20
|
# Remove initial "IETF " string if specified
|
22
21
|
ref = text.gsub(/^IETF /, "")
|
23
|
-
/^(RFC|BCP|FYI|STD)\s(?<num>\d+)/ =~ ref
|
22
|
+
/^(?:RFC|BCP|FYI|STD)\s(?<num>\d+)/ =~ ref
|
24
23
|
ref.sub! /(?<=^(?:RFC|BCP|FYI|STD)\s)(\d+)/, num.rjust(4, "0") if num
|
25
24
|
rfc_item ref, is_relation
|
26
25
|
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
27
26
|
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
28
27
|
Net::ProtocolError, SocketError
|
29
|
-
raise RelatonBib::RequestError, "No document found for #{ref} reference
|
28
|
+
raise RelatonBib::RequestError, "No document found for #{ref} reference"
|
30
29
|
end
|
31
30
|
|
32
31
|
# @param reference [Nokogiri::XML::Element, nil]
|
@@ -34,7 +33,7 @@ module RelatonIetf
|
|
34
33
|
# @param url [String, NilClass]
|
35
34
|
# @param ver [String, NilClass] Internet Draft version
|
36
35
|
# @return [RelatonIetf::IetfBibliographicItem]
|
37
|
-
def fetch_rfc(reference, is_relation
|
36
|
+
def fetch_rfc(reference, is_relation: false, url: nil, ver: nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
38
37
|
return unless reference
|
39
38
|
|
40
39
|
ietf_item(
|
@@ -54,7 +53,7 @@ module RelatonIetf
|
|
54
53
|
series: series(reference),
|
55
54
|
place: ["Fremont, CA"],
|
56
55
|
keyword: reference.xpath("front/keyword").map(&:text),
|
57
|
-
doctype: doctype(reference[:anchor])
|
56
|
+
doctype: doctype(reference[:anchor]),
|
58
57
|
)
|
59
58
|
end
|
60
59
|
|
@@ -92,6 +91,7 @@ module RelatonIetf
|
|
92
91
|
end
|
93
92
|
|
94
93
|
# @param ref [String]
|
94
|
+
# @param is_relation [Boolen, nil]
|
95
95
|
# @return [RelatonIetf::IetfBibliographicItem]
|
96
96
|
def rfc_item(ref, is_relation)
|
97
97
|
/(?<=-)(?<ver>\d{2})$/ =~ ref
|
@@ -102,14 +102,15 @@ module RelatonIetf
|
|
102
102
|
|
103
103
|
uri = "#{GH_URL}#{ref.sub(/\s|\u00a0/, '.')}.xml"
|
104
104
|
doc = Nokogiri::XML get_page(uri)
|
105
|
-
|
105
|
+
r = doc.at("/referencegroup", "/reference")
|
106
|
+
fetch_rfc r, is_relation: is_relation, url: uri, ver: ver
|
106
107
|
end
|
107
108
|
|
108
109
|
# @param reference [Nokogiri::XML::Element]
|
109
110
|
# @return [Hash]
|
110
111
|
def relations(reference)
|
111
112
|
reference.xpath("reference").map do |ref|
|
112
|
-
{ type: "includes", bibitem: fetch_rfc(ref, true) }
|
113
|
+
{ type: "includes", bibitem: fetch_rfc(ref, is_relation: true) }
|
113
114
|
end
|
114
115
|
end
|
115
116
|
|
@@ -117,9 +118,10 @@ module RelatonIetf
|
|
117
118
|
# @return [String] HTTP response body
|
118
119
|
def get_page(uri)
|
119
120
|
res = Net::HTTP.get_response(URI(uri))
|
120
|
-
|
121
|
-
|
122
|
-
|
121
|
+
return unless res.code == "200"
|
122
|
+
|
123
|
+
# raise RelatonBib::RequestError, "No document found at #{uri}"
|
124
|
+
# end
|
123
125
|
|
124
126
|
res.body
|
125
127
|
end
|
@@ -144,7 +146,11 @@ module RelatonIetf
|
|
144
146
|
return if reference.at "./fornt/title"
|
145
147
|
|
146
148
|
cont = (reference[:anchor] || reference[:docName] || reference[:number])
|
147
|
-
|
149
|
+
if cont
|
150
|
+
RelatonBib::FormattedRef.new(
|
151
|
+
content: cont, language: language(reference), script: "Latn",
|
152
|
+
)
|
153
|
+
end
|
148
154
|
end
|
149
155
|
|
150
156
|
# @param reference [Nokogiri::XML::Element]
|
@@ -172,14 +178,15 @@ module RelatonIetf
|
|
172
178
|
entity = RelatonBib::Person.new(
|
173
179
|
name: full_name(author, reference),
|
174
180
|
affiliation: [affiliation(author)],
|
175
|
-
contact: contacts(author.at("./address"))
|
181
|
+
contact: contacts(author.at("./address")),
|
176
182
|
)
|
177
183
|
{ entity: entity, role: [contributor_role(author)] }
|
178
184
|
end
|
179
185
|
end
|
180
186
|
|
181
187
|
# @param reference [Nokogiri::XML::Element]
|
182
|
-
# @return [Array<Hash{Symbol=>RelatonBib::Organization,
|
188
|
+
# @return [Array<Hash{Symbol=>RelatonBib::Organization,
|
189
|
+
# Symbol=>Array<String>}>]
|
183
190
|
def organizations(reference)
|
184
191
|
publisher = { entity: new_org, role: [type: "publisher"] }
|
185
192
|
orgs = reference.xpath("./seriesinfo").reduce([publisher]) do |mem, si|
|
@@ -188,7 +195,7 @@ module RelatonIetf
|
|
188
195
|
mem << { entity: new_org(si[:stream], nil), role: [type: "author"] }
|
189
196
|
end
|
190
197
|
orgs + reference.xpath(
|
191
|
-
"front/author[not(@surname)][not(@fullname)]/organization"
|
198
|
+
"front/author[not(@surname)][not(@fullname)]/organization",
|
192
199
|
).map do |org|
|
193
200
|
{ entity: new_org(org.text, nil), role: [type: "author"] }
|
194
201
|
end
|
@@ -202,7 +209,7 @@ module RelatonIetf
|
|
202
209
|
RelatonBib::FullName.new(
|
203
210
|
completename: localized_string(author[:fullname], lang),
|
204
211
|
initial: [localized_string(author[:initials], lang)].compact,
|
205
|
-
surname: localized_string(author[:surname], lang)
|
212
|
+
surname: localized_string(author[:surname], lang),
|
206
213
|
)
|
207
214
|
end
|
208
215
|
|
@@ -237,7 +244,7 @@ module RelatonIetf
|
|
237
244
|
city: postal.at("./city")&.text,
|
238
245
|
postcode: postal.at("./code")&.text,
|
239
246
|
country: postal.at("./country")&.text,
|
240
|
-
state: postal.at("./region")&.text
|
247
|
+
state: postal.at("./region")&.text,
|
241
248
|
)
|
242
249
|
end
|
243
250
|
|
@@ -309,7 +316,7 @@ module RelatonIetf
|
|
309
316
|
ret = []
|
310
317
|
if id
|
311
318
|
ret << RelatonBib::DocumentIdentifier.new(
|
312
|
-
type: "IETF", id: id.sub(/^(RFC)/, "\\1 ")
|
319
|
+
type: "IETF", id: id.sub(/^(RFC)/, "\\1 "),
|
313
320
|
)
|
314
321
|
end
|
315
322
|
if (id = reference[:anchor])
|
@@ -336,10 +343,10 @@ module RelatonIetf
|
|
336
343
|
|
337
344
|
RelatonBib::Series.new(
|
338
345
|
title: RelatonBib::TypedTitleString.new(
|
339
|
-
content: si[:name], language: language(reference), script: "Latn"
|
346
|
+
content: si[:name], language: language(reference), script: "Latn",
|
340
347
|
),
|
341
348
|
number: si[:value],
|
342
|
-
type: "main"
|
349
|
+
type: "main",
|
343
350
|
)
|
344
351
|
end.compact
|
345
352
|
end
|
data/lib/relaton_ietf/version.rb
CHANGED
data/relaton_ietf.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
# spec.add_development_dependency "debase"
|
33
33
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
34
34
|
spec.add_development_dependency "pry-byebug"
|
35
|
-
spec.add_development_dependency "rake", "~>
|
35
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
36
36
|
spec.add_development_dependency "rspec", "~> 3.0"
|
37
37
|
# spec.add_development_dependency "ruby-debug-ide"
|
38
38
|
spec.add_development_dependency "ruby-jing"
|
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.7.
|
4
|
+
version: 1.7.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: 2021-
|
11
|
+
date: 2021-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
190
|
- !ruby/object:Gem::Version
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
193
|
+
rubygems_version: 3.2.3
|
194
194
|
signing_key:
|
195
195
|
specification_version: 4
|
196
196
|
summary: 'RelatonIetf: retrieve IETF Standards for bibliographic use using the BibliographicItem
|