relaton-ietf 1.8.0 → 1.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -11
- data/.rubocop.yml +3 -1
- data/README.adoc +50 -0
- data/grammars/biblio.rng +1 -0
- data/grammars/ietf.rng +3 -0
- data/grammars/isodoc.rng +72 -10
- data/lib/relaton_ietf/committee.rb +8 -0
- data/lib/relaton_ietf/data_fetcher.rb +130 -0
- data/lib/relaton_ietf/ietf_bibliographic_item.rb +2 -2
- data/lib/relaton_ietf/processor.rb +14 -1
- data/lib/relaton_ietf/rfc_entry.rb +186 -0
- data/lib/relaton_ietf/rfc_index_entry.rb +60 -0
- data/lib/relaton_ietf/scrapper.rb +354 -346
- data/lib/relaton_ietf/version.rb +1 -1
- data/lib/relaton_ietf/xml_parser.rb +1 -1
- data/lib/relaton_ietf.rb +2 -0
- data/relaton_ietf.gemspec +3 -4
- metadata +23 -5
@@ -0,0 +1,60 @@
|
|
1
|
+
module RelatonIetf
|
2
|
+
class RfcIndexEntry
|
3
|
+
#
|
4
|
+
# Document parser initalization
|
5
|
+
#
|
6
|
+
# @param [String] doc_id document id
|
7
|
+
# @param [Array<String>] is_also also document ids
|
8
|
+
#
|
9
|
+
def initialize(name, doc_id, is_also)
|
10
|
+
@name = name
|
11
|
+
@shortnum = doc_id[-4..-1].sub(/^0+/, "")
|
12
|
+
@doc_id = doc_id
|
13
|
+
@is_also = is_also
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Document id
|
18
|
+
#
|
19
|
+
# @return [Strinng] document id
|
20
|
+
#
|
21
|
+
def docnumber
|
22
|
+
@doc_id
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Initialize document parser and run it
|
27
|
+
#
|
28
|
+
# @param [Nokogiri::XML::Element] doc document
|
29
|
+
#
|
30
|
+
# @return [RelatonIetf:RfcIndexEntry, nil]
|
31
|
+
#
|
32
|
+
def self.parse(doc)
|
33
|
+
doc_id = doc.at("./xmlns:doc-id")
|
34
|
+
is_also = doc.xpath("./xmlns:is-also/xmlns:doc-id").map &:text
|
35
|
+
return unless doc_id && is_also.any?
|
36
|
+
|
37
|
+
name = doc.name.split("-").first
|
38
|
+
new(name, doc_id.text, is_also)
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Render document as XML
|
43
|
+
#
|
44
|
+
# @return [String] XML
|
45
|
+
#
|
46
|
+
def to_xml # rubocop:disable Metrics/MethodLength
|
47
|
+
Nokogiri::XML::Builder.new do |xml|
|
48
|
+
anchor = "#{@name.upcase}#{@shortnum}"
|
49
|
+
url = "https://www.rfc-editor.org/info/#{@name}#{@shortnum}"
|
50
|
+
xml.referencegroup("xmlns:xi" => "http://www.w3.org/2001/XInclude",
|
51
|
+
anchor: anchor, target: url) do
|
52
|
+
@is_also.each do |did|
|
53
|
+
num = did[-4..-1]
|
54
|
+
xml["xi"].send("include", href: "https://www.rfc-editor.org/refs/bibxml/reference.RFC.#{num}.xml")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end.doc.root.to_xml
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|