relaton-ietf 1.9.3 → 1.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +0 -10
- data/lib/relaton/provider_ietf.rb +1 -1
- data/lib/relaton_ietf/bibxml_parser.rb +31 -0
- data/lib/relaton_ietf/data_fetcher.rb +5 -3
- data/lib/relaton_ietf/processor.rb +1 -1
- data/lib/relaton_ietf/rfc_entry.rb +1 -1
- data/lib/relaton_ietf/rfc_index_entry.rb +52 -25
- data/lib/relaton_ietf/scrapper.rb +3 -327
- data/lib/relaton_ietf/version.rb +1 -1
- data/lib/relaton_ietf.rb +3 -0
- data/relaton_ietf.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38c6632f8b954cf88746dac6e0560294cf8c546063e774f1b717dec2a4f0a9d8
|
4
|
+
data.tar.gz: dcf250a7d8c88a06ba9be27ba3d69bcbe3f5e50b3d41ee1616834011d6b2995c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55bb6cdf657772970caa7447097da8e38686aa7c0cc16a40e8f931963ecd26202ed1aed62a8c77269d8d0f49cf4e890002b8d4a2831235f566023dc3b13a06eb
|
7
|
+
data.tar.gz: cfb86b6c8f4a52a19ff52ecb93d0ca9211159f8499a782f2aa3904ae089d0f1f6ae7c9f96e00f532c7502cc4a718d0ebb9b6784e2d9f3d9ebc2b180489fc0b0a
|
data/README.adoc
CHANGED
@@ -149,16 +149,6 @@ Arguments:
|
|
149
149
|
- `output` - folder to save documents (default './data').
|
150
150
|
- `format` - format in which the documents are saved. Possimle formats are: `yaml`, `xml`, `bibxml` (default `yaml`).
|
151
151
|
|
152
|
-
For `ietf-rfcsubseries` dataset only special XML format is supported:
|
153
|
-
|
154
|
-
[sourse.xml]
|
155
|
-
----
|
156
|
-
<referencegroup anchor="BCP14" target="https://www.rfc-editor.org/info/bcp14">
|
157
|
-
<xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.2119.xml" />
|
158
|
-
<xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.8174.xml" />
|
159
|
-
</referencegroup>
|
160
|
-
----
|
161
|
-
|
162
152
|
[source,ruby]
|
163
153
|
----
|
164
154
|
RelatonIetf::DataFetcher.fetch "ietf-internet-drafts"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RelatonIetf
|
2
|
+
module BibXMLParser
|
3
|
+
include RelatonBib::BibXMLParser
|
4
|
+
extend BibXMLParser
|
5
|
+
|
6
|
+
FLAVOR = "IETF".freeze
|
7
|
+
|
8
|
+
# @param attrs [Hash]
|
9
|
+
# @return [RelatonIetf::IetfBibliographicItem]
|
10
|
+
def bib_item(**attrs)
|
11
|
+
unless attrs.delete(:is_relation)
|
12
|
+
attrs[:fetched] = Date.today.to_s
|
13
|
+
attrs[:place] = ["Fremont, CA"]
|
14
|
+
end
|
15
|
+
RelatonIetf::IetfBibliographicItem.new(**attrs)
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param [RelatonBib::WorkGroup]
|
19
|
+
# @return [RelatonIetf::Committee]
|
20
|
+
def committee(wgr)
|
21
|
+
Committee.new wgr
|
22
|
+
end
|
23
|
+
|
24
|
+
# @param reference [Nokogiri::XML::Element]
|
25
|
+
# @return [Array<Hash>]
|
26
|
+
def contributors(reference)
|
27
|
+
[{ entity: new_org("Internet Engineering Task Force", "IETF"), role: [type: "publisher"] }] + super
|
28
|
+
# persons(reference) + organizations(reference)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -17,7 +17,7 @@ module RelatonIetf
|
|
17
17
|
def initialize(source, output, format)
|
18
18
|
@source = source
|
19
19
|
@output = output
|
20
|
-
@format =
|
20
|
+
@format = format
|
21
21
|
@ext = @format.sub(/^bib|^rfc/, "")
|
22
22
|
@files = []
|
23
23
|
end
|
@@ -99,7 +99,6 @@ module RelatonIetf
|
|
99
99
|
c = case @format
|
100
100
|
when "xml" then entry.to_xml(bibdata: true)
|
101
101
|
when "yaml" then entry.to_hash.to_yaml
|
102
|
-
when "rfcxml" then entry.to_xml
|
103
102
|
else entry.send("to_#{@format}")
|
104
103
|
end
|
105
104
|
file = file_name entry
|
@@ -123,7 +122,10 @@ module RelatonIetf
|
|
123
122
|
entry.docidentifier.detect { |i| i.type == "Internet-Draft" }&.id
|
124
123
|
end
|
125
124
|
id ||= entry.docnumber
|
126
|
-
|
125
|
+
if @source == "ietf-internet-drafts" then id.downcase!
|
126
|
+
else id.upcase!
|
127
|
+
end
|
128
|
+
name = id.gsub(/[\s,:\/]/, "_").squeeze("_")
|
127
129
|
File.join @output, "#{name}.#{@ext}"
|
128
130
|
end
|
129
131
|
end
|
@@ -6,7 +6,7 @@ module RelatonIetf
|
|
6
6
|
def initialize # rubocop:disable Lint/MissingSuper
|
7
7
|
@short = :relaton_ietf
|
8
8
|
@prefix = "IETF"
|
9
|
-
@defaultprefix = /^RFC
|
9
|
+
@defaultprefix = /^(IETF|RFC|BCP)\s/
|
10
10
|
@idtype = "IETF"
|
11
11
|
@datasets = %w[ietf-rfcsubseries ietf-internet-drafts ietf-rfc-entries]
|
12
12
|
end
|
@@ -3,8 +3,9 @@ module RelatonIetf
|
|
3
3
|
#
|
4
4
|
# Document parser initalization
|
5
5
|
#
|
6
|
+
# @param [String] name document type name
|
6
7
|
# @param [String] doc_id document id
|
7
|
-
# @param [Array<String>] is_also
|
8
|
+
# @param [Array<String>] is_also included document ids
|
8
9
|
#
|
9
10
|
def initialize(name, doc_id, is_also)
|
10
11
|
@name = name
|
@@ -13,15 +14,6 @@ module RelatonIetf
|
|
13
14
|
@is_also = is_also
|
14
15
|
end
|
15
16
|
|
16
|
-
#
|
17
|
-
# Document id
|
18
|
-
#
|
19
|
-
# @return [Strinng] document id
|
20
|
-
#
|
21
|
-
def docnumber
|
22
|
-
@doc_id
|
23
|
-
end
|
24
|
-
|
25
17
|
#
|
26
18
|
# Initialize document parser and run it
|
27
19
|
#
|
@@ -35,26 +27,61 @@ module RelatonIetf
|
|
35
27
|
return unless doc_id && is_also.any?
|
36
28
|
|
37
29
|
name = doc.name.split("-").first
|
38
|
-
new(name, doc_id.text, is_also)
|
30
|
+
new(name, doc_id.text, is_also).parse
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse
|
34
|
+
IetfBibliographicItem.new(
|
35
|
+
docnumber: docnumber,
|
36
|
+
type: "standard",
|
37
|
+
docid: parse_docid,
|
38
|
+
language: ["en"],
|
39
|
+
script: ["Latn"],
|
40
|
+
link: parse_link,
|
41
|
+
formattedref: formattedref,
|
42
|
+
relation: parse_relation,
|
43
|
+
)
|
39
44
|
end
|
40
45
|
|
41
46
|
#
|
42
|
-
#
|
47
|
+
# Document id
|
43
48
|
#
|
44
|
-
# @return [
|
49
|
+
# @return [Strinng] document id
|
45
50
|
#
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
51
|
+
def docnumber
|
52
|
+
@doc_id
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse_docid
|
56
|
+
[
|
57
|
+
RelatonBib::DocumentIdentifier.new(type: "IETF", id: pub_id),
|
58
|
+
RelatonBib::DocumentIdentifier.new(type: "rfc-anchor", id: anchor),
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
def pub_id
|
63
|
+
"IETF #{@name.upcase} #{@shortnum}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def anchor
|
67
|
+
"#{@name.upcase}#{@shortnum}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def parse_link
|
71
|
+
[RelatonBib::TypedUri.new(type: "src", content: "https://www.rfc-editor.org/info/#{@name}#{@shortnum}")]
|
72
|
+
end
|
73
|
+
|
74
|
+
def formattedref
|
75
|
+
RelatonBib::FormattedRef.new(
|
76
|
+
content: anchor, language: "en", script: "Latn",
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
def parse_relation
|
81
|
+
@is_also.map do |ref|
|
82
|
+
bib = IetfBibliography.get ref.sub(/^(RFC)(\d+)/, '\1 \2')
|
83
|
+
{ type: "includes", bibitem: bib }
|
84
|
+
end
|
58
85
|
end
|
59
86
|
end
|
60
87
|
end
|
@@ -1,17 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "net/http"
|
4
|
-
require "relaton_bib"
|
5
|
-
require "relaton_ietf/ietf_bibliographic_item"
|
6
|
-
|
7
3
|
module RelatonIetf
|
8
4
|
# Scrapper module
|
9
5
|
module Scrapper
|
10
|
-
extend RelatonBib::BibXMLParser
|
11
6
|
extend Scrapper
|
12
7
|
|
13
|
-
FLAVOR = "IETF"
|
14
|
-
|
15
8
|
GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ietf/master/data/reference."
|
16
9
|
|
17
10
|
# @param text [String]
|
@@ -24,76 +17,13 @@ module RelatonIetf
|
|
24
17
|
ref.sub!(/(?<=^(?:RFC|BCP|FYI|STD)\s)(\d+)/, num.rjust(4, "0")) if num
|
25
18
|
rfc_item ref, is_relation
|
26
19
|
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
27
|
-
|
28
|
-
|
20
|
+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
21
|
+
Net::ProtocolError, SocketError
|
29
22
|
raise RelatonBib::RequestError, "No document found for #{ref} reference"
|
30
23
|
end
|
31
24
|
|
32
|
-
# @param reference [Nokogiri::XML::Element, nil]
|
33
|
-
# @param is_relation [Boolean] don't add fetched date for relation
|
34
|
-
# @param url [String, NilClass]
|
35
|
-
# @param ver [String, NilClass] Internet Draft version
|
36
|
-
# @return [RelatonBib::tfBibliographicItem]
|
37
|
-
# def fetch_rfc(reference, is_relation: false, url: nil, ver: nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
38
|
-
# return unless reference
|
39
|
-
|
40
|
-
# hash = {
|
41
|
-
# id: reference[:anchor],
|
42
|
-
# type: "standard",
|
43
|
-
# docid: docids(reference, ver),
|
44
|
-
# status: status(reference),
|
45
|
-
# language: [language(reference)],
|
46
|
-
# script: ["Latn"],
|
47
|
-
# link: link(reference, url, ver),
|
48
|
-
# title: titles(reference),
|
49
|
-
# formattedref: formattedref(reference),
|
50
|
-
# abstract: abstracts(reference),
|
51
|
-
# contributor: contributors(reference),
|
52
|
-
# relation: relations(reference),
|
53
|
-
# date: dates(reference),
|
54
|
-
# series: series(reference),
|
55
|
-
# keyword: reference.xpath("front/keyword").map(&:text),
|
56
|
-
# doctype: doctype(reference[:anchor]),
|
57
|
-
# }
|
58
|
-
# hash[:fetched] = Date.today.to_s unless is_relation
|
59
|
-
# bib_item(**hash)
|
60
|
-
# end
|
61
|
-
|
62
25
|
private
|
63
26
|
|
64
|
-
# @param anchor [String]
|
65
|
-
# @return [String]
|
66
|
-
# def doctype(anchor)
|
67
|
-
# anchor&.include?("I-D") ? "internet-draft" : "rfc"
|
68
|
-
# end
|
69
|
-
|
70
|
-
# @param reference [Nokogiri::XML::Element]
|
71
|
-
# @param url [String]
|
72
|
-
# @param ver [String, NilClass] Internet Draft version
|
73
|
-
# @return [Array<Hash>]
|
74
|
-
# def link(reference, url, ver)
|
75
|
-
# l = []
|
76
|
-
# l << { type: "xml", content: url } if url
|
77
|
-
# l << { type: "src", content: reference[:target] } if reference[:target]
|
78
|
-
# if /^I-D/.match? reference[:anchor]
|
79
|
-
# reference.xpath("format").each do |f|
|
80
|
-
# c = ver ? f[:target].sub(/(?<=-)\d{2}(?=\.)/, ver) : f[:target]
|
81
|
-
# l << { type: f[:type], content: c }
|
82
|
-
# end
|
83
|
-
# end
|
84
|
-
# l
|
85
|
-
# end
|
86
|
-
|
87
|
-
# @param attrs [Hash]
|
88
|
-
# @return [RelatonIetf::IetfBibliographicItem]
|
89
|
-
def bib_item(**attrs)
|
90
|
-
unless attrs.delete(:is_relation)
|
91
|
-
attrs[:fetched] = Date.today.to_s
|
92
|
-
attrs[:place] = ["Fremont, CA"]
|
93
|
-
end
|
94
|
-
RelatonIetf::IetfBibliographicItem.new(**attrs)
|
95
|
-
end
|
96
|
-
|
97
27
|
# @param ref [String]
|
98
28
|
# @param is_relation [Boolen, nil]
|
99
29
|
# @return [RelatonIetf::IetfBibliographicItem]
|
@@ -108,17 +38,9 @@ module RelatonIetf
|
|
108
38
|
# doc = Nokogiri::XML get_page(uri)
|
109
39
|
# r = doc.at("/referencegroup", "/reference")
|
110
40
|
# fetch_rfc r, is_relation: is_relation, url: uri, ver: ver
|
111
|
-
parse get_page(uri), url: uri, is_relation: is_relation, ver: ver
|
41
|
+
BibXMLParser.parse get_page(uri), url: uri, is_relation: is_relation, ver: ver
|
112
42
|
end
|
113
43
|
|
114
|
-
# @param reference [Nokogiri::XML::Element]
|
115
|
-
# @return [Hash]
|
116
|
-
# def relations(reference)
|
117
|
-
# reference.xpath("reference").map do |ref|
|
118
|
-
# { type: "includes", bibitem: fetch_rfc(ref, is_relation: true) }
|
119
|
-
# end
|
120
|
-
# end
|
121
|
-
|
122
44
|
# @param uri [String]
|
123
45
|
# @return [String] HTTP response body
|
124
46
|
def get_page(uri)
|
@@ -127,251 +49,5 @@ module RelatonIetf
|
|
127
49
|
|
128
50
|
res.body
|
129
51
|
end
|
130
|
-
|
131
|
-
# @param [RelatonBib::WorkGroup]
|
132
|
-
# @return [RelatonIetf::Committee]
|
133
|
-
def committee(wgr)
|
134
|
-
Committee.new wgr
|
135
|
-
end
|
136
|
-
|
137
|
-
# @param reference [Nokogiri::XML::Element]
|
138
|
-
# @return [String]
|
139
|
-
# def language(reference)
|
140
|
-
# reference[:lang] || "en"
|
141
|
-
# end
|
142
|
-
|
143
|
-
# @param reference [Nokogiri::XML::Element]
|
144
|
-
# @return [Array<Hash>]
|
145
|
-
# def titles(reference)
|
146
|
-
# reference.xpath("./front/title").map do |title|
|
147
|
-
# { content: title.text, language: language(reference), script: "Latn" }
|
148
|
-
# end
|
149
|
-
# end
|
150
|
-
|
151
|
-
# @param reference [Nokogiri::XML::Element]
|
152
|
-
# @return [RelatonBib::FormattedRef, nil]
|
153
|
-
# def formattedref(reference)
|
154
|
-
# return if reference.at "./front/title"
|
155
|
-
|
156
|
-
# cont = (reference[:anchor] || reference[:docName] || reference[:number])
|
157
|
-
# if cont
|
158
|
-
# RelatonBib::FormattedRef.new(
|
159
|
-
# content: cont, language: language(reference), script: "Latn",
|
160
|
-
# )
|
161
|
-
# end
|
162
|
-
# end
|
163
|
-
|
164
|
-
# @param reference [Nokogiri::XML::Element]
|
165
|
-
# @return [Array<RelatonBib::FormattedString>]
|
166
|
-
# def abstracts(ref)
|
167
|
-
# ref.xpath("./front/abstract").map do |a|
|
168
|
-
# RelatonBib::FormattedString.new(
|
169
|
-
# content: a.text.gsub(/\\n\\t{2,4}/, " ").strip,
|
170
|
-
# language: language(ref), script: "Latn"
|
171
|
-
# )
|
172
|
-
# end
|
173
|
-
# end
|
174
|
-
|
175
|
-
# @param reference [Nokogiri::XML::Element]
|
176
|
-
# @return [Array<Hash>]
|
177
|
-
def contributors(reference)
|
178
|
-
[{ entity: new_org("Internet Engineering Task Force", "IETF"), role: [type: "publisher"] }] + super
|
179
|
-
# persons(reference) + organizations(reference)
|
180
|
-
end
|
181
|
-
|
182
|
-
# @param reference [Nokogiri::XML::Element]
|
183
|
-
# @return [Array<Hash{Symbol=>RelatonBib::Person,Symbol=>Array<String>}>]
|
184
|
-
# def persons(reference)
|
185
|
-
# reference.xpath("./front/author[@surname]|./front/author[@fullname]")
|
186
|
-
# .map do |author|
|
187
|
-
# entity = RelatonBib::Person.new(
|
188
|
-
# name: full_name(author, reference),
|
189
|
-
# affiliation: affiliation(author),
|
190
|
-
# contact: contacts(author.at("./address")),
|
191
|
-
# )
|
192
|
-
# { entity: entity, role: [contributor_role(author)] }
|
193
|
-
# end
|
194
|
-
# end
|
195
|
-
|
196
|
-
# @param reference [Nokogiri::XML::Element]
|
197
|
-
# @return [Array<Hash{Symbol=>RelatonBib::Organization,
|
198
|
-
# Symbol=>Array<String>}>]
|
199
|
-
# def organizations(reference)
|
200
|
-
# publisher = { entity: new_org, role: [type: "publisher"] }
|
201
|
-
# orgs = reference.xpath("./seriesinfo").reduce([publisher]) do |mem, si|
|
202
|
-
# next mem unless si[:stream]
|
203
|
-
|
204
|
-
# mem << { entity: new_org(si[:stream], nil), role: [type: "author"] }
|
205
|
-
# end
|
206
|
-
# orgs + reference.xpath(
|
207
|
-
# "front/author[not(@surname)][not(@fullname)]/organization",
|
208
|
-
# ).map do |org|
|
209
|
-
# { entity: new_org(org.text, nil), role: [type: "author"] }
|
210
|
-
# end
|
211
|
-
# end
|
212
|
-
|
213
|
-
# @param author [Nokogiri::XML::Element]
|
214
|
-
# @param ref [Nokogiri::XML::Element]
|
215
|
-
# @return [RelatonBib::FullName]
|
216
|
-
# def full_name(author, ref)
|
217
|
-
# lang = language ref
|
218
|
-
# RelatonBib::FullName.new(
|
219
|
-
# completename: localized_string(author[:fullname], lang),
|
220
|
-
# initial: [localized_string(author[:initials], lang)].compact,
|
221
|
-
# surname: localized_string(author[:surname], lang),
|
222
|
-
# )
|
223
|
-
# end
|
224
|
-
|
225
|
-
# @param content [String]
|
226
|
-
# @param lang [String]
|
227
|
-
# @return [RelatonBib::LocalizedString]
|
228
|
-
# def localized_string(content, lang)
|
229
|
-
# return unless content
|
230
|
-
|
231
|
-
# RelatonBib::LocalizedString.new(content, lang)
|
232
|
-
# end
|
233
|
-
|
234
|
-
# @param postal [Nokogiri::XML::Element]
|
235
|
-
# @return [Array<RelatonBib::Address, RelatonBib::Phone>]
|
236
|
-
# def contacts(addr)
|
237
|
-
# contacts = []
|
238
|
-
# return contacts unless addr
|
239
|
-
|
240
|
-
# postal = addr.at("./postal")
|
241
|
-
# contacts << address(postal) if postal
|
242
|
-
# add_contact(contacts, "phone", addr.at("./phone"))
|
243
|
-
# add_contact(contacts, "email", addr.at("./email"))
|
244
|
-
# add_contact(contacts, "uri", addr.at("./uri"))
|
245
|
-
# contacts
|
246
|
-
# end
|
247
|
-
|
248
|
-
# @param postal [Nokogiri::XML::Element]
|
249
|
-
# @rerurn [RelatonBib::Address]
|
250
|
-
# def address(postal) # rubocop:disable Metrics/CyclomaticComplexity
|
251
|
-
# RelatonBib::Address.new(
|
252
|
-
# street: [(postal.at("./postalLine") || postal.at("./street"))&.text],
|
253
|
-
# city: postal.at("./city")&.text,
|
254
|
-
# postcode: postal.at("./code")&.text,
|
255
|
-
# country: postal.at("./country")&.text,
|
256
|
-
# state: postal.at("./region")&.text,
|
257
|
-
# )
|
258
|
-
# end
|
259
|
-
|
260
|
-
# @param type [String] allowed "phone", "email" or "uri"
|
261
|
-
# @param value [String]
|
262
|
-
# def add_contact(contacts, type, value)
|
263
|
-
# return unless value
|
264
|
-
|
265
|
-
# contacts << RelatonBib::Contact.new(type: type, value: value.text)
|
266
|
-
# end
|
267
|
-
|
268
|
-
# @param author [Nokogiri::XML::Element]
|
269
|
-
# @return [RelatonBib::Affiliation]
|
270
|
-
# def affiliation(author)
|
271
|
-
# organization = author.at("./organization")
|
272
|
-
# org = if organization.nil? || organization&.text&.empty?
|
273
|
-
# new_org
|
274
|
-
# else
|
275
|
-
# new_org organization.text, organization[:abbrev]
|
276
|
-
# end
|
277
|
-
# RelatonBib::Affiliation.new organization: org
|
278
|
-
# end
|
279
|
-
|
280
|
-
# @param name [String]
|
281
|
-
# @param abbr [String]
|
282
|
-
# @return [RelatonBib::Organization]
|
283
|
-
# def new_org(name = "Internet Engineering Task Force", abbr = "IETF")
|
284
|
-
# RelatonBib::Organization.new name: name, abbreviation: abbr
|
285
|
-
# end
|
286
|
-
|
287
|
-
# @param author [Nokogiri::XML::Document]
|
288
|
-
# @return [Hash]
|
289
|
-
# def contributor_role(author)
|
290
|
-
# { type: author[:role] || "author" }
|
291
|
-
# end
|
292
|
-
|
293
|
-
# def month(mon)
|
294
|
-
# return 1 if !mon || mon.empty?
|
295
|
-
# return mon if /^\d+$/.match? mon
|
296
|
-
|
297
|
-
# Date::MONTHNAMES.index(mon)
|
298
|
-
# end
|
299
|
-
|
300
|
-
#
|
301
|
-
# Extract date from reference.
|
302
|
-
#
|
303
|
-
# @param reference [Nokogiri::XML::Element]
|
304
|
-
# @return [Array<RelatonBib::BibliographicDate>] published data.
|
305
|
-
#
|
306
|
-
# def dates(reference)
|
307
|
-
# return unless (date = reference.at "./front/date")
|
308
|
-
|
309
|
-
# d = [date[:year], month(date[:month]),
|
310
|
-
# (date[:day] || 1)].compact.join "-"
|
311
|
-
# date = Time.parse(d).strftime "%Y-%m-%d"
|
312
|
-
# [RelatonBib::BibliographicDate.new(type: "published", on: date)]
|
313
|
-
# end
|
314
|
-
|
315
|
-
#
|
316
|
-
# Extract document identifiers from reference
|
317
|
-
#
|
318
|
-
# @param reference [Nokogiri::XML::Element]
|
319
|
-
# @param ver [String, NilClass] Internet Draft version
|
320
|
-
#
|
321
|
-
# @return [Array<RelatonBib::DocumentIdentifier>]
|
322
|
-
#
|
323
|
-
# def docids(reference, ver) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
|
324
|
-
# id = (reference[:anchor] || reference[:docName] || reference[:number])
|
325
|
-
# ret = []
|
326
|
-
# if id
|
327
|
-
# ret << RelatonBib::DocumentIdentifier.new(
|
328
|
-
# type: "IETF", id: id.sub(/^(RFC)/, "\\1 "),
|
329
|
-
# )
|
330
|
-
# end
|
331
|
-
# if (id = reference[:anchor])
|
332
|
-
# ret << RelatonBib::DocumentIdentifier.new(type: "rfc-anchor", id: id)
|
333
|
-
# end
|
334
|
-
# names = ["DOI", "Internet-Draft"]
|
335
|
-
# ret + reference.xpath("./seriesInfo").map do |si|
|
336
|
-
# next unless names.include? si[:name]
|
337
|
-
|
338
|
-
# id = si[:value]
|
339
|
-
# id.sub!(/(?<=-)\d{2}$/, ver) if ver && si[:name] == "Internet-Draft"
|
340
|
-
# RelatonBib::DocumentIdentifier.new(id: id, type: si[:name])
|
341
|
-
# end.compact
|
342
|
-
# end
|
343
|
-
|
344
|
-
#
|
345
|
-
# Extract series form reference
|
346
|
-
# @param reference [Nokogiri::XML::Element]
|
347
|
-
#
|
348
|
-
# @return [Array<RelatonBib::Series>]
|
349
|
-
#
|
350
|
-
# def series(reference)
|
351
|
-
# reference.xpath("./seriesInfo").map do |si|
|
352
|
-
# next if si[:name] == "DOI" || si[:stream] || si[:status]
|
353
|
-
|
354
|
-
# RelatonBib::Series.new(
|
355
|
-
# title: RelatonBib::TypedTitleString.new(
|
356
|
-
# content: si[:name], language: language(reference), script: "Latn",
|
357
|
-
# ),
|
358
|
-
# number: si[:value],
|
359
|
-
# type: "main",
|
360
|
-
# )
|
361
|
-
# end.compact
|
362
|
-
# end
|
363
|
-
|
364
|
-
#
|
365
|
-
# extract status
|
366
|
-
# @param reference [Nokogiri::XML::Element]
|
367
|
-
#
|
368
|
-
# @return [RelatonBib::DocumentStatus]
|
369
|
-
#
|
370
|
-
# def status(reference)
|
371
|
-
# st = reference.at("./seriesinfo[@status]")
|
372
|
-
# return unless st
|
373
|
-
|
374
|
-
# RelatonBib::DocumentStatus.new(stage: st[:status])
|
375
|
-
# end
|
376
52
|
end
|
377
53
|
end
|
data/lib/relaton_ietf/version.rb
CHANGED
data/lib/relaton_ietf.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "net/http"
|
4
|
+
require "relaton_bib"
|
3
5
|
require "relaton_ietf/version"
|
6
|
+
require "relaton_ietf/bibxml_parser"
|
4
7
|
require "relaton_ietf/ietf_bibliography"
|
5
8
|
require "relaton_ietf/ietf_bibliographic_item"
|
6
9
|
require "relaton_ietf/xml_parser"
|
data/relaton_ietf.gemspec
CHANGED
@@ -38,6 +38,6 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_development_dependency "vcr"
|
39
39
|
spec.add_development_dependency "webmock"
|
40
40
|
|
41
|
-
spec.add_dependency "relaton-bib", ">= 1.9.
|
41
|
+
spec.add_dependency "relaton-bib", ">= 1.9.12"
|
42
42
|
spec.add_dependency "zlib", "~> 1.1.0"
|
43
43
|
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.9.
|
4
|
+
version: 1.9.7
|
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-12-
|
11
|
+
date: 2021-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.9.
|
131
|
+
version: 1.9.12
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.9.
|
138
|
+
version: 1.9.12
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: zlib
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- grammars/reqt.rng
|
178
178
|
- lib/relaton/provider_ietf.rb
|
179
179
|
- lib/relaton_ietf.rb
|
180
|
+
- lib/relaton_ietf/bibxml_parser.rb
|
180
181
|
- lib/relaton_ietf/committee.rb
|
181
182
|
- lib/relaton_ietf/data_fetcher.rb
|
182
183
|
- lib/relaton_ietf/hash_converter.rb
|