relaton-ietf 1.6.0 → 1.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +46 -0
- data/README.adoc +1 -5
- data/grammars/isodoc.rng +14 -43
- data/lib/relaton_ietf.rb +1 -6
- data/lib/relaton_ietf/hash_converter.rb +8 -17
- data/lib/relaton_ietf/ietf_bibliographic_item.rb +7 -0
- data/lib/relaton_ietf/processor.rb +1 -2
- data/lib/relaton_ietf/scrapper.rb +65 -96
- data/lib/relaton_ietf/version.rb +1 -1
- data/lib/relaton_ietf/xml_parser.rb +1 -1
- data/relaton_ietf.gemspec +3 -3
- metadata +5 -35
- data/.github/workflows/macos.yml +0 -34
- data/.github/workflows/ubuntu.yml +0 -33
- data/.github/workflows/windows.yml +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7b4e48f7bfedc080ef41fa038f678b702a45a500637e71be5444b87b74d460b
|
4
|
+
data.tar.gz: c8ccfe769f17ef85df427835b4f1116f125453b99b2f20ea29f97f74b9d39654
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab65e6e326efce9ebdff092f34814e774f73388aef294ab1b96e2286ffcaca74a7bd69d4c0701bf85beba62b6a3e5c9a3eacddf854566649f8e224634e07e303
|
7
|
+
data.tar.gz: e8624b553831ccbcefbbb4385127c75f9535b4f2d3d786af5ab040ec1d75a3509813fb6cdc269df26a24b91f223f166edb015682507ae61d30df89c672a2d4c4
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: rake
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master, main ]
|
8
|
+
tags: [ v* ]
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
rake:
|
13
|
+
name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
|
14
|
+
runs-on: ${{ matrix.os }}
|
15
|
+
continue-on-error: ${{ matrix.experimental }}
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
ruby: [ '2.7', '2.6', '2.5', '2.4' ]
|
20
|
+
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
|
+
experimental: [ false ]
|
22
|
+
include:
|
23
|
+
- ruby: '3.0'
|
24
|
+
os: 'ubuntu-latest'
|
25
|
+
experimental: true
|
26
|
+
- ruby: '3.0'
|
27
|
+
os: 'windows-latest'
|
28
|
+
experimental: true
|
29
|
+
- ruby: '3.0'
|
30
|
+
os: 'macos-latest'
|
31
|
+
experimental: true
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v2
|
34
|
+
with:
|
35
|
+
submodules: true
|
36
|
+
|
37
|
+
# https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
|
38
|
+
- if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
|
39
|
+
run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
|
40
|
+
|
41
|
+
- uses: ruby/setup-ruby@v1
|
42
|
+
with:
|
43
|
+
ruby-version: ${{ matrix.ruby }}
|
44
|
+
bundler-cache: true
|
45
|
+
|
46
|
+
- run: bundle exec rake
|
data/README.adoc
CHANGED
@@ -102,11 +102,7 @@ hash = YAML.load_file 'spec/examples/ietf_bib_item.yml'
|
|
102
102
|
=> {"id"=>"RFC 8341",
|
103
103
|
...
|
104
104
|
|
105
|
-
|
106
|
-
=> {:id=>"RFC 8341",
|
107
|
-
...
|
108
|
-
|
109
|
-
RelatonIetf::IetfBibliographicItem.new bib_hash
|
105
|
+
RelatonIetf::IetfBibliographicItem.from_hash hash
|
110
106
|
=> #<RelatonIetf::IetfBibliographicItem:0x007f9a929dde40
|
111
107
|
...
|
112
108
|
----
|
data/grammars/isodoc.rng
CHANGED
@@ -24,6 +24,14 @@
|
|
24
24
|
<start>
|
25
25
|
<ref name="standard-document"/>
|
26
26
|
</start>
|
27
|
+
<define name="doctype">
|
28
|
+
<element name="doctype">
|
29
|
+
<optional>
|
30
|
+
<attribute name="abbreviation"/>
|
31
|
+
</optional>
|
32
|
+
<ref name="DocumentType"/>
|
33
|
+
</element>
|
34
|
+
</define>
|
27
35
|
<define name="hyperlink">
|
28
36
|
<element name="link">
|
29
37
|
<attribute name="target">
|
@@ -141,6 +149,11 @@
|
|
141
149
|
<data type="boolean"/>
|
142
150
|
</attribute>
|
143
151
|
</optional>
|
152
|
+
<optional>
|
153
|
+
<attribute name="key">
|
154
|
+
<data type="boolean"/>
|
155
|
+
</attribute>
|
156
|
+
</optional>
|
144
157
|
<oneOrMore>
|
145
158
|
<ref name="dt"/>
|
146
159
|
<ref name="dd"/>
|
@@ -1164,49 +1177,7 @@
|
|
1164
1177
|
</define>
|
1165
1178
|
<define name="annex">
|
1166
1179
|
<element name="annex">
|
1167
|
-
<
|
1168
|
-
<attribute name="id">
|
1169
|
-
<data type="ID"/>
|
1170
|
-
</attribute>
|
1171
|
-
</optional>
|
1172
|
-
<optional>
|
1173
|
-
<attribute name="language"/>
|
1174
|
-
</optional>
|
1175
|
-
<optional>
|
1176
|
-
<attribute name="script"/>
|
1177
|
-
</optional>
|
1178
|
-
<optional>
|
1179
|
-
<attribute name="inline-header">
|
1180
|
-
<data type="boolean"/>
|
1181
|
-
</attribute>
|
1182
|
-
</optional>
|
1183
|
-
<attribute name="obligation">
|
1184
|
-
<choice>
|
1185
|
-
<value>normative</value>
|
1186
|
-
<value>informative</value>
|
1187
|
-
</choice>
|
1188
|
-
</attribute>
|
1189
|
-
<optional>
|
1190
|
-
<ref name="section-title"/>
|
1191
|
-
</optional>
|
1192
|
-
<group>
|
1193
|
-
<group>
|
1194
|
-
<zeroOrMore>
|
1195
|
-
<ref name="BasicBlock"/>
|
1196
|
-
</zeroOrMore>
|
1197
|
-
<zeroOrMore>
|
1198
|
-
<ref name="note"/>
|
1199
|
-
</zeroOrMore>
|
1200
|
-
</group>
|
1201
|
-
<zeroOrMore>
|
1202
|
-
<choice>
|
1203
|
-
<ref name="annex-subsection"/>
|
1204
|
-
<ref name="terms"/>
|
1205
|
-
<ref name="definitions"/>
|
1206
|
-
<ref name="references"/>
|
1207
|
-
</choice>
|
1208
|
-
</zeroOrMore>
|
1209
|
-
</group>
|
1180
|
+
<ref name="Annex-Section"/>
|
1210
1181
|
</element>
|
1211
1182
|
</define>
|
1212
1183
|
<define name="terms">
|
data/lib/relaton_ietf.rb
CHANGED
@@ -6,11 +6,6 @@ require "relaton_ietf/ietf_bibliographic_item"
|
|
6
6
|
require "relaton_ietf/xml_parser"
|
7
7
|
require "relaton_ietf/hash_converter"
|
8
8
|
|
9
|
-
# if defined? Relaton
|
10
|
-
# require_relative "relaton_ietf/processor"
|
11
|
-
# Relaton::Registry.instance.register(RelatonIetf::Processor)
|
12
|
-
# end
|
13
|
-
|
14
9
|
require "relaton/provider_ietf"
|
15
10
|
|
16
11
|
module RelatonIetf
|
@@ -22,4 +17,4 @@ module RelatonIetf
|
|
22
17
|
grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
23
18
|
Digest::MD5.hexdigest grammars
|
24
19
|
end
|
25
|
-
end
|
20
|
+
end
|
@@ -1,23 +1,14 @@
|
|
1
1
|
module RelatonIetf
|
2
2
|
class HashConverter < RelatonBib::HashConverter
|
3
3
|
class << self
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# doctype_hash_to_bib(ret)
|
13
|
-
# ret
|
14
|
-
# end
|
15
|
-
|
16
|
-
# private
|
17
|
-
|
18
|
-
# def doctype_hash_to_bib(ret)
|
19
|
-
# ret
|
20
|
-
# end
|
4
|
+
#
|
5
|
+
# Ovverides superclass's method
|
6
|
+
#
|
7
|
+
# @param item [Hash]
|
8
|
+
# @retirn [RelatonIec::IecBibliographicItem]
|
9
|
+
def bib_item(item)
|
10
|
+
IetfBibliographicItem.new(**item)
|
11
|
+
end
|
21
12
|
end
|
22
13
|
end
|
23
14
|
end
|
@@ -17,6 +17,13 @@ module RelatonIetf
|
|
17
17
|
super
|
18
18
|
end
|
19
19
|
|
20
|
+
# @param hash [Hash]
|
21
|
+
# @return [RelatonIetf::IetfBibliographicItem]
|
22
|
+
def self.from_hash(hash)
|
23
|
+
item_hash = ::RelatonIetf::HashConverter.hash_to_bib(hash)
|
24
|
+
new **item_hash
|
25
|
+
end
|
26
|
+
|
20
27
|
# @param opts [Hash]
|
21
28
|
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
22
29
|
# @option opts [Boolean] :bibdata
|
@@ -27,8 +27,7 @@ module RelatonIetf
|
|
27
27
|
# @param hash [Hash]
|
28
28
|
# @return [RelatonIetf::IetfBibliographicItem]
|
29
29
|
def hash_to_bib(hash)
|
30
|
-
|
31
|
-
::RelatonIetf::IetfBibliographicItem.new item_hash
|
30
|
+
::RelatonIetf::IetfBibliographicItem.from_hash hash
|
32
31
|
end
|
33
32
|
|
34
33
|
# Returns hash of XML grammar
|
@@ -10,44 +10,31 @@ module RelatonIetf
|
|
10
10
|
|
11
11
|
# Scrapper module
|
12
12
|
module Scrapper
|
13
|
-
|
14
|
-
# ID_URI_PATTERN = "https://xml2rfc.tools.ietf.org/public/rfc/bibxml-ids/reference.CODE"
|
13
|
+
GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ietf/master/data/reference."
|
15
14
|
BCP_URI_PATTERN = "https://www.rfc-editor.org/info/CODE"
|
16
15
|
|
17
16
|
class << self
|
18
|
-
# rubocop:disable Metrics/MethodLength
|
19
|
-
|
20
17
|
# @param text [String]
|
21
18
|
# @param is_relation [TrueClass, FalseClass]
|
22
19
|
# @return [RelatonIetf::IetfBibliographicItem]
|
23
20
|
def scrape_page(text, is_relation = false)
|
24
21
|
# Remove initial "IETF " string if specified
|
25
22
|
ref = text.gsub(/^IETF /, "")
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
35
|
-
when /^BCP/ then bcp_item BCP_URI_PATTERN.dup, ref
|
36
|
-
else
|
37
|
-
raise RelatonBib::RequestError, "#{ref}: not recognised for RFC"
|
38
|
-
end
|
23
|
+
/^(RFC|BCP|FYI|STD)\s(?<num>\d+)/ =~ ref
|
24
|
+
ref.sub! /(?<=^(?:RFC|BCP|FYI|STD)\s)(\d+)/, num.rjust(4, "0") if num
|
25
|
+
rfc_item ref, is_relation
|
39
26
|
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
40
27
|
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
41
28
|
Net::ProtocolError, SocketError
|
42
29
|
raise RelatonBib::RequestError, "No document found for #{ref} reference."
|
43
30
|
end
|
44
31
|
|
45
|
-
# @param reference [
|
32
|
+
# @param reference [Nokogiri::XML::Element, nil]
|
46
33
|
# @param is_relation [TrueClass, FalseClass]
|
47
34
|
# @param url [String, NilClass]
|
48
35
|
# @param ver [String, NilClass] Internet Draft version
|
49
36
|
# @return [RelatonIetf::IetfBibliographicItem]
|
50
|
-
def fetch_rfc(reference, is_relation = false, url = nil, ver = nil)
|
37
|
+
def fetch_rfc(reference, is_relation = false, url = nil, ver = nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
51
38
|
return unless reference
|
52
39
|
|
53
40
|
ietf_item(
|
@@ -59,23 +46,24 @@ module RelatonIetf
|
|
59
46
|
language: [language(reference)],
|
60
47
|
link: link(reference, url, ver),
|
61
48
|
title: titles(reference),
|
49
|
+
formattedref: formattedref(reference),
|
62
50
|
abstract: abstracts(reference),
|
63
51
|
contributor: contributors(reference),
|
52
|
+
relation: relations(reference),
|
64
53
|
date: dates(reference),
|
65
54
|
series: series(reference),
|
66
55
|
place: ["Fremont, CA"],
|
67
56
|
keyword: reference.xpath("front/keyword").map(&:text),
|
68
|
-
doctype: doctype(reference[:anchor])
|
57
|
+
doctype: doctype(reference[:anchor])
|
69
58
|
)
|
70
59
|
end
|
71
|
-
# rubocop:enable Metrics/MethodLength
|
72
60
|
|
73
61
|
private
|
74
62
|
|
75
63
|
# @param anchor [String]
|
76
64
|
# @return [String]
|
77
65
|
def doctype(anchor)
|
78
|
-
anchor
|
66
|
+
anchor&.include?("I-D") ? "internet-draft" : "rfc"
|
79
67
|
end
|
80
68
|
|
81
69
|
# @param reference [Nokogiri::XML::Element]
|
@@ -86,7 +74,7 @@ module RelatonIetf
|
|
86
74
|
l = []
|
87
75
|
l << { type: "xml", content: url } if url
|
88
76
|
l << { type: "src", content: reference[:target] } if reference[:target]
|
89
|
-
if reference[:anchor]
|
77
|
+
if /^I-D/.match? reference[:anchor]
|
90
78
|
reference.xpath("format").each do |f|
|
91
79
|
c = ver ? f[:target].sub(/(?<=-)\d{2}(?=\.)/, ver) : f[:target]
|
92
80
|
l << { type: f[:type], content: c }
|
@@ -103,57 +91,30 @@ module RelatonIetf
|
|
103
91
|
RelatonIetf::IetfBibliographicItem.new **attrs
|
104
92
|
end
|
105
93
|
|
106
|
-
# @param uri_nums [Array<String>]
|
107
94
|
# @param ref [String]
|
108
95
|
# @return [RelatonIetf::IetfBibliographicItem]
|
109
|
-
def rfc_item(
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
/(
|
114
|
-
if n == "3"
|
115
|
-
ref.sub! /-\d{2}/, "" if ver
|
116
|
-
ref.sub! /(?<=I-D\.)draft-/, ""
|
117
|
-
end
|
118
|
-
|
119
|
-
uri = "#{RFC_URI_PATTERN}#{n}/reference.#{ref.sub(/\s|\u00a0/, ".")}.xml"
|
120
|
-
begin
|
121
|
-
doc = Nokogiri::XML get_page(uri)
|
122
|
-
resp = fetch_rfc doc.at("//reference"), is_relation, uri, ver
|
123
|
-
return resp if resp
|
124
|
-
rescue RelatonBib::RequestError => e
|
125
|
-
error = e
|
126
|
-
end
|
96
|
+
def rfc_item(ref, is_relation)
|
97
|
+
/(?<=-)(?<ver>\d{2})$/ =~ ref
|
98
|
+
if /^I-D/.match? ref
|
99
|
+
ref.sub! /-\d{2}/, "" if ver
|
100
|
+
ref.sub! /(?<=I-D\.)draft-/, ""
|
127
101
|
end
|
128
|
-
raise error
|
129
|
-
end
|
130
102
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
def bcp_item(uri_template, reference)
|
135
|
-
uri = uri_template.sub "CODE", reference.sub(" ", "").downcase
|
136
|
-
doc = Nokogiri::HTML get_page(uri)
|
137
|
-
ietf_item(
|
138
|
-
id: reference,
|
139
|
-
title: [content: ""],
|
140
|
-
docid: [RelatonBib::DocumentIdentifier.new(type: "IETF", id: reference)],
|
141
|
-
language: ["en"],
|
142
|
-
link: [{ type: "src", content: uri }],
|
143
|
-
relation: fetch_relations(doc),
|
144
|
-
doctype: "rfc",
|
145
|
-
)
|
103
|
+
uri = "#{GH_URL}#{ref.sub(/\s|\u00a0/, '.')}.xml"
|
104
|
+
doc = Nokogiri::XML get_page(uri)
|
105
|
+
fetch_rfc doc.at("/referencegroup", "/reference"), is_relation, uri, ver
|
146
106
|
end
|
147
107
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
)
|
108
|
+
# @param reference [Nokogiri::XML::Element]
|
109
|
+
# @return [Hash]
|
110
|
+
def relations(reference)
|
111
|
+
reference.xpath("reference").map do |ref|
|
112
|
+
{ type: "includes", bibitem: fetch_rfc(ref, true) }
|
154
113
|
end
|
155
114
|
end
|
156
115
|
|
116
|
+
# @param uri [String]
|
117
|
+
# @return [String] HTTP response body
|
157
118
|
def get_page(uri)
|
158
119
|
res = Net::HTTP.get_response(URI(uri))
|
159
120
|
if res.code != "200"
|
@@ -163,21 +124,30 @@ module RelatonIetf
|
|
163
124
|
res.body
|
164
125
|
end
|
165
126
|
|
166
|
-
#
|
167
|
-
# uri_template.gsub("CODE", reference)
|
168
|
-
# end
|
169
|
-
|
127
|
+
# @param reference [Nokogiri::XML::Element]
|
170
128
|
# @return [String]
|
171
129
|
def language(reference)
|
172
130
|
reference[:lang] || "en"
|
173
131
|
end
|
174
132
|
|
133
|
+
# @param reference [Nokogiri::XML::Element]
|
175
134
|
# @return [Array<Hash>]
|
176
135
|
def titles(reference)
|
177
|
-
|
178
|
-
|
136
|
+
reference.xpath("./front/title").map do |title|
|
137
|
+
{ content: title.text, language: language(reference), script: "Latn" }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# @param reference [Nokogiri::XML::Element]
|
142
|
+
# @return [RelatonBib::FormattedRef, nil]
|
143
|
+
def formattedref(reference)
|
144
|
+
return if reference.at "./fornt/title"
|
145
|
+
|
146
|
+
cont = (reference[:anchor] || reference[:docName] || reference[:number])
|
147
|
+
RelatonBib::FormattedRef.new content: cont, language: language(reference), script: "Latn" if cont
|
179
148
|
end
|
180
149
|
|
150
|
+
# @param reference [Nokogiri::XML::Element]
|
181
151
|
# @return [Array<RelatonBib::FormattedString>]
|
182
152
|
def abstracts(ref)
|
183
153
|
ref.xpath("./front/abstract").map do |a|
|
@@ -188,24 +158,27 @@ module RelatonIetf
|
|
188
158
|
end
|
189
159
|
end
|
190
160
|
|
161
|
+
# @param reference [Nokogiri::XML::Element]
|
191
162
|
# @return [Array<Hash>]
|
192
163
|
def contributors(reference)
|
193
164
|
persons(reference) + organizations(reference)
|
194
165
|
end
|
195
166
|
|
167
|
+
# @param reference [Nokogiri::XML::Element]
|
196
168
|
# @return [Array<Hash{Symbol=>RelatonBib::Person,Symbol=>Array<String>}>]
|
197
169
|
def persons(reference)
|
198
|
-
reference.xpath("./front/author[@surname]|./front/author[@fullname]")
|
199
|
-
map do |author|
|
170
|
+
reference.xpath("./front/author[@surname]|./front/author[@fullname]")
|
171
|
+
.map do |author|
|
200
172
|
entity = RelatonBib::Person.new(
|
201
173
|
name: full_name(author, reference),
|
202
174
|
affiliation: [affiliation(author)],
|
203
|
-
contact: contacts(author.at("./address"))
|
175
|
+
contact: contacts(author.at("./address"))
|
204
176
|
)
|
205
177
|
{ entity: entity, role: [contributor_role(author)] }
|
206
178
|
end
|
207
179
|
end
|
208
180
|
|
181
|
+
# @param reference [Nokogiri::XML::Element]
|
209
182
|
# @return [Array<Hash{Symbol=>RelatonBib::Organization,Symbol=>Array<String>}>]
|
210
183
|
def organizations(reference)
|
211
184
|
publisher = { entity: new_org, role: [type: "publisher"] }
|
@@ -215,21 +188,21 @@ module RelatonIetf
|
|
215
188
|
mem << { entity: new_org(si[:stream], nil), role: [type: "author"] }
|
216
189
|
end
|
217
190
|
orgs + reference.xpath(
|
218
|
-
"front/author[not(@surname)][not(@fullname)]/organization"
|
191
|
+
"front/author[not(@surname)][not(@fullname)]/organization"
|
219
192
|
).map do |org|
|
220
193
|
{ entity: new_org(org.text, nil), role: [type: "author"] }
|
221
194
|
end
|
222
195
|
end
|
223
196
|
|
224
|
-
# @param author [Nokogiri::XML::
|
225
|
-
# @param ref [Nokogiri::XML::
|
197
|
+
# @param author [Nokogiri::XML::Element]
|
198
|
+
# @param ref [Nokogiri::XML::Element]
|
226
199
|
# @return [RelatonBib::FullName]
|
227
200
|
def full_name(author, ref)
|
228
201
|
lang = language ref
|
229
202
|
RelatonBib::FullName.new(
|
230
203
|
completename: localized_string(author[:fullname], lang),
|
231
204
|
initial: [localized_string(author[:initials], lang)].compact,
|
232
|
-
surname: localized_string(author[:surname], lang)
|
205
|
+
surname: localized_string(author[:surname], lang)
|
233
206
|
)
|
234
207
|
end
|
235
208
|
|
@@ -242,7 +215,7 @@ module RelatonIetf
|
|
242
215
|
RelatonBib::LocalizedString.new(content, lang)
|
243
216
|
end
|
244
217
|
|
245
|
-
# @param postal [Nokogiri::XML::
|
218
|
+
# @param postal [Nokogiri::XML::Element]
|
246
219
|
# @return [Array<RelatonBib::Address, RelatonBib::Phone>]
|
247
220
|
def contacts(addr)
|
248
221
|
contacts = []
|
@@ -256,15 +229,15 @@ module RelatonIetf
|
|
256
229
|
contacts
|
257
230
|
end
|
258
231
|
|
259
|
-
# @param postal [Nokogiri::XML::
|
232
|
+
# @param postal [Nokogiri::XML::Element]
|
260
233
|
# @rerurn [RelatonBib::Address]
|
261
|
-
def address(postal)
|
234
|
+
def address(postal) # rubocop:disable Metrics/CyclomaticComplexity
|
262
235
|
RelatonBib::Address.new(
|
263
236
|
street: [(postal.at("./postalLine") || postal.at("./street"))&.text],
|
264
237
|
city: postal.at("./city")&.text,
|
265
238
|
postcode: postal.at("./code")&.text,
|
266
239
|
country: postal.at("./country")&.text,
|
267
|
-
state: postal.at("./region")&.text
|
240
|
+
state: postal.at("./region")&.text
|
268
241
|
)
|
269
242
|
end
|
270
243
|
|
@@ -276,7 +249,7 @@ module RelatonIetf
|
|
276
249
|
contacts << RelatonBib::Contact.new(type: type, value: value.text)
|
277
250
|
end
|
278
251
|
|
279
|
-
# @param author [Nokogiri::XML::
|
252
|
+
# @param author [Nokogiri::XML::Element]
|
280
253
|
# @return [RelatonBib::Affiliation]
|
281
254
|
def affiliation(author)
|
282
255
|
organization = author.at("./organization")
|
@@ -303,7 +276,7 @@ module RelatonIetf
|
|
303
276
|
|
304
277
|
def month(mon)
|
305
278
|
return 1 if !mon || mon.empty?
|
306
|
-
return mon if /^\d
|
279
|
+
return mon if /^\d+$/.match? mon
|
307
280
|
|
308
281
|
Date::MONTHNAMES.index(mon)
|
309
282
|
end
|
@@ -311,6 +284,7 @@ module RelatonIetf
|
|
311
284
|
#
|
312
285
|
# Extract date from reference.
|
313
286
|
#
|
287
|
+
# @param reference [Nokogiri::XML::Element]
|
314
288
|
# @return [Array<RelatonBib::BibliographicDate>] published data.
|
315
289
|
#
|
316
290
|
def dates(reference)
|
@@ -322,8 +296,6 @@ module RelatonIetf
|
|
322
296
|
[RelatonBib::BibliographicDate.new(type: "published", on: date)]
|
323
297
|
end
|
324
298
|
|
325
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
326
|
-
|
327
299
|
#
|
328
300
|
# Extract document identifiers from reference
|
329
301
|
#
|
@@ -332,12 +304,12 @@ module RelatonIetf
|
|
332
304
|
#
|
333
305
|
# @return [Array<RelatonBib::DocumentIdentifier>]
|
334
306
|
#
|
335
|
-
def docids(reference, ver)
|
307
|
+
def docids(reference, ver) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
|
336
308
|
id = (reference[:anchor] || reference[:docName] || reference[:number])
|
337
309
|
ret = []
|
338
310
|
if id
|
339
311
|
ret << RelatonBib::DocumentIdentifier.new(
|
340
|
-
type: "IETF", id: id.sub(/^(RFC)/, "\\1 ")
|
312
|
+
type: "IETF", id: id.sub(/^(RFC)/, "\\1 ")
|
341
313
|
)
|
342
314
|
end
|
343
315
|
if (id = reference[:anchor])
|
@@ -351,11 +323,10 @@ module RelatonIetf
|
|
351
323
|
RelatonBib::DocumentIdentifier.new(id: id, type: si[:name])
|
352
324
|
end.compact
|
353
325
|
end
|
354
|
-
# enable Metrics/MethodLength, Metrics/AbcSize
|
355
326
|
|
356
327
|
#
|
357
328
|
# Extract series form reference
|
358
|
-
# @param reference [Nokogiri::XML::
|
329
|
+
# @param reference [Nokogiri::XML::Element]
|
359
330
|
#
|
360
331
|
# @return [Array<RelatonBib::Series>]
|
361
332
|
#
|
@@ -365,17 +336,17 @@ module RelatonIetf
|
|
365
336
|
|
366
337
|
RelatonBib::Series.new(
|
367
338
|
title: RelatonBib::TypedTitleString.new(
|
368
|
-
content: si[:name], language: language(reference), script: "Latn"
|
339
|
+
content: si[:name], language: language(reference), script: "Latn"
|
369
340
|
),
|
370
341
|
number: si[:value],
|
371
|
-
type: "main"
|
342
|
+
type: "main"
|
372
343
|
)
|
373
344
|
end.compact
|
374
345
|
end
|
375
346
|
|
376
347
|
#
|
377
348
|
# extract status
|
378
|
-
# @param reference [Nokogiri::XML::
|
349
|
+
# @param reference [Nokogiri::XML::Element]
|
379
350
|
#
|
380
351
|
# @return [RelatonBib::DocumentStatus]
|
381
352
|
#
|
@@ -383,9 +354,7 @@ module RelatonIetf
|
|
383
354
|
st = reference.at("./seriesinfo[@status]")
|
384
355
|
return unless st
|
385
356
|
|
386
|
-
RelatonBib::DocumentStatus.new(
|
387
|
-
stage: st[:status],
|
388
|
-
)
|
357
|
+
RelatonBib::DocumentStatus.new(stage: st[:status])
|
389
358
|
end
|
390
359
|
end
|
391
360
|
end
|
data/lib/relaton_ietf/version.rb
CHANGED
data/relaton_ietf.gemspec
CHANGED
@@ -29,16 +29,16 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
31
31
|
|
32
|
-
spec.add_development_dependency "debase"
|
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
35
|
spec.add_development_dependency "rake", "~> 10.0"
|
36
36
|
spec.add_development_dependency "rspec", "~> 3.0"
|
37
|
-
spec.add_development_dependency "ruby-debug-ide"
|
37
|
+
# spec.add_development_dependency "ruby-debug-ide"
|
38
38
|
spec.add_development_dependency "ruby-jing"
|
39
39
|
spec.add_development_dependency "simplecov"
|
40
40
|
spec.add_development_dependency "vcr"
|
41
41
|
spec.add_development_dependency "webmock"
|
42
42
|
|
43
|
-
spec.add_dependency "relaton-bib", "~> 1.
|
43
|
+
spec.add_dependency "relaton-bib", "~> 1.7.0"
|
44
44
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-ietf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: debase
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: equivalent-xml
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +66,6 @@ dependencies:
|
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '3.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: ruby-debug-ide
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: ruby-jing
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +128,14 @@ dependencies:
|
|
156
128
|
requirements:
|
157
129
|
- - "~>"
|
158
130
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.
|
131
|
+
version: 1.7.0
|
160
132
|
type: :runtime
|
161
133
|
prerelease: false
|
162
134
|
version_requirements: !ruby/object:Gem::Requirement
|
163
135
|
requirements:
|
164
136
|
- - "~>"
|
165
137
|
- !ruby/object:Gem::Version
|
166
|
-
version: 1.
|
138
|
+
version: 1.7.0
|
167
139
|
description: "RelatonIetf: retrieve IETF Standards for bibliographic use \nusing the
|
168
140
|
BibliographicItem model.\n\nFormerly known as rfcbib.\n"
|
169
141
|
email:
|
@@ -172,9 +144,7 @@ executables: []
|
|
172
144
|
extensions: []
|
173
145
|
extra_rdoc_files: []
|
174
146
|
files:
|
175
|
-
- ".github/workflows/
|
176
|
-
- ".github/workflows/ubuntu.yml"
|
177
|
-
- ".github/workflows/windows.yml"
|
147
|
+
- ".github/workflows/rake.yml"
|
178
148
|
- ".gitignore"
|
179
149
|
- ".hound.yml"
|
180
150
|
- ".rspec"
|
data/.github/workflows/macos.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
-
# See https://github.com/metanorma/cimas
|
3
|
-
name: macos
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
branches: [ master ]
|
8
|
-
pull_request:
|
9
|
-
branches: [ '**' ]
|
10
|
-
|
11
|
-
jobs:
|
12
|
-
test-macos:
|
13
|
-
name: Test on Ruby ${{ matrix.ruby }} macOS
|
14
|
-
runs-on: macos-latest
|
15
|
-
strategy:
|
16
|
-
fail-fast: false
|
17
|
-
matrix:
|
18
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
19
|
-
steps:
|
20
|
-
- uses: actions/checkout@master
|
21
|
-
- name: Use Ruby
|
22
|
-
uses: actions/setup-ruby@v1
|
23
|
-
with:
|
24
|
-
ruby-version: ${{ matrix.ruby }}
|
25
|
-
architecture: 'x64'
|
26
|
-
- name: Update gems
|
27
|
-
run: |
|
28
|
-
sudo gem install bundler --force
|
29
|
-
ruby -v | grep 2.5 && bundle config set build.debase --with-cflags="-Wno-error=implicit-function-declaration"
|
30
|
-
ruby -v | grep 2.5 && bundle config set build.ruby-debug-ide --with-cflags="-Wno-error=implicit-function-declaration"
|
31
|
-
bundle install --jobs 4 --retry 3
|
32
|
-
- name: Run specs
|
33
|
-
run: |
|
34
|
-
bundle exec rake
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
-
# See https://github.com/metanorma/cimas
|
3
|
-
name: ubuntu
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
branches: [ master ]
|
8
|
-
pull_request:
|
9
|
-
branches: [ '**' ]
|
10
|
-
|
11
|
-
jobs:
|
12
|
-
test-linux:
|
13
|
-
name: Test on Ruby ${{ matrix.ruby }} Ubuntu
|
14
|
-
runs-on: ubuntu-latest
|
15
|
-
strategy:
|
16
|
-
fail-fast: false
|
17
|
-
matrix:
|
18
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
19
|
-
steps:
|
20
|
-
- uses: actions/checkout@master
|
21
|
-
- name: Use Ruby
|
22
|
-
uses: actions/setup-ruby@v1
|
23
|
-
with:
|
24
|
-
ruby-version: ${{ matrix.ruby }}
|
25
|
-
architecture: 'x64'
|
26
|
-
- name: Update gems
|
27
|
-
run: |
|
28
|
-
gem install bundler
|
29
|
-
bundle install --jobs 4 --retry 3
|
30
|
-
- name: Run specs
|
31
|
-
run: |
|
32
|
-
unset JAVA_TOOL_OPTIONS
|
33
|
-
bundle exec rake
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
-
# See https://github.com/metanorma/cimas
|
3
|
-
name: windows
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
branches: [ master ]
|
8
|
-
pull_request:
|
9
|
-
branches: [ '**' ]
|
10
|
-
|
11
|
-
jobs:
|
12
|
-
test-windows:
|
13
|
-
name: Test on Ruby ${{ matrix.ruby }} Windows
|
14
|
-
runs-on: windows-latest
|
15
|
-
strategy:
|
16
|
-
fail-fast: false
|
17
|
-
matrix:
|
18
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
19
|
-
steps:
|
20
|
-
- uses: actions/checkout@master
|
21
|
-
- name: Use Ruby
|
22
|
-
uses: actions/setup-ruby@v1
|
23
|
-
with:
|
24
|
-
ruby-version: ${{ matrix.ruby }}
|
25
|
-
architecture: 'x64'
|
26
|
-
- name: Update gems
|
27
|
-
shell: pwsh
|
28
|
-
run: |
|
29
|
-
gem install bundler
|
30
|
-
bundle config --local path vendor/bundle
|
31
|
-
bundle update
|
32
|
-
bundle install --jobs 4 --retry 3
|
33
|
-
- name: Run specs
|
34
|
-
run: |
|
35
|
-
bundle exec rake
|