relaton-ietf 1.7.0 → 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/.github/workflows/rake.yml +46 -0
- data/README.adoc +16 -9
- 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/ietf_bibliography.rb +5 -1
- data/lib/relaton_ietf/processor.rb +1 -2
- data/lib/relaton_ietf/scrapper.rb +71 -95
- data/lib/relaton_ietf/version.rb +1 -1
- data/lib/relaton_ietf/xml_parser.rb +1 -1
- data/relaton_ietf.gemspec +3 -3
- metadata +6 -36
- 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: 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
|
@@ -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
@@ -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
|
|
@@ -102,11 +113,7 @@ hash = YAML.load_file 'spec/examples/ietf_bib_item.yml'
|
|
102
113
|
=> {"id"=>"RFC 8341",
|
103
114
|
...
|
104
115
|
|
105
|
-
|
106
|
-
=> {:id=>"RFC 8341",
|
107
|
-
...
|
108
|
-
|
109
|
-
RelatonIetf::IetfBibliographicItem.new bib_hash
|
116
|
+
RelatonIetf::IetfBibliographicItem.from_hash hash
|
110
117
|
=> #<RelatonIetf::IetfBibliographicItem:0x007f9a929dde40
|
111
118
|
...
|
112
119
|
----
|
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 [RelatonIetf::IetfBibliographicItem]
|
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
|
@@ -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
|
@@ -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
|
@@ -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
|
|
@@ -10,44 +9,31 @@ module RelatonIetf
|
|
10
9
|
|
11
10
|
# Scrapper module
|
12
11
|
module Scrapper
|
13
|
-
|
14
|
-
# ID_URI_PATTERN = "https://xml2rfc.tools.ietf.org/public/rfc/bibxml-ids/reference.CODE"
|
12
|
+
GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ietf/master/data/reference."
|
15
13
|
BCP_URI_PATTERN = "https://www.rfc-editor.org/info/CODE"
|
16
14
|
|
17
15
|
class << self
|
18
|
-
# rubocop:disable Metrics/MethodLength
|
19
|
-
|
20
16
|
# @param text [String]
|
21
17
|
# @param is_relation [TrueClass, FalseClass]
|
22
18
|
# @return [RelatonIetf::IetfBibliographicItem]
|
23
|
-
def scrape_page(text, is_relation
|
19
|
+
def scrape_page(text, is_relation: false)
|
24
20
|
# Remove initial "IETF " string if specified
|
25
21
|
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
|
22
|
+
/^(?:RFC|BCP|FYI|STD)\s(?<num>\d+)/ =~ ref
|
23
|
+
ref.sub! /(?<=^(?:RFC|BCP|FYI|STD)\s)(\d+)/, num.rjust(4, "0") if num
|
24
|
+
rfc_item ref, is_relation
|
39
25
|
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
40
26
|
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
41
27
|
Net::ProtocolError, SocketError
|
42
|
-
raise RelatonBib::RequestError, "No document found for #{ref} reference
|
28
|
+
raise RelatonBib::RequestError, "No document found for #{ref} reference"
|
43
29
|
end
|
44
30
|
|
45
|
-
# @param reference [
|
31
|
+
# @param reference [Nokogiri::XML::Element, nil]
|
46
32
|
# @param is_relation [TrueClass, FalseClass]
|
47
33
|
# @param url [String, NilClass]
|
48
34
|
# @param ver [String, NilClass] Internet Draft version
|
49
35
|
# @return [RelatonIetf::IetfBibliographicItem]
|
50
|
-
def fetch_rfc(reference, is_relation
|
36
|
+
def fetch_rfc(reference, is_relation: false, url: nil, ver: nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
51
37
|
return unless reference
|
52
38
|
|
53
39
|
ietf_item(
|
@@ -59,8 +45,10 @@ module RelatonIetf
|
|
59
45
|
language: [language(reference)],
|
60
46
|
link: link(reference, url, ver),
|
61
47
|
title: titles(reference),
|
48
|
+
formattedref: formattedref(reference),
|
62
49
|
abstract: abstracts(reference),
|
63
50
|
contributor: contributors(reference),
|
51
|
+
relation: relations(reference),
|
64
52
|
date: dates(reference),
|
65
53
|
series: series(reference),
|
66
54
|
place: ["Fremont, CA"],
|
@@ -68,14 +56,13 @@ module RelatonIetf
|
|
68
56
|
doctype: doctype(reference[:anchor]),
|
69
57
|
)
|
70
58
|
end
|
71
|
-
# rubocop:enable Metrics/MethodLength
|
72
59
|
|
73
60
|
private
|
74
61
|
|
75
62
|
# @param anchor [String]
|
76
63
|
# @return [String]
|
77
64
|
def doctype(anchor)
|
78
|
-
anchor
|
65
|
+
anchor&.include?("I-D") ? "internet-draft" : "rfc"
|
79
66
|
end
|
80
67
|
|
81
68
|
# @param reference [Nokogiri::XML::Element]
|
@@ -86,7 +73,7 @@ module RelatonIetf
|
|
86
73
|
l = []
|
87
74
|
l << { type: "xml", content: url } if url
|
88
75
|
l << { type: "src", content: reference[:target] } if reference[:target]
|
89
|
-
if reference[:anchor]
|
76
|
+
if /^I-D/.match? reference[:anchor]
|
90
77
|
reference.xpath("format").each do |f|
|
91
78
|
c = ver ? f[:target].sub(/(?<=-)\d{2}(?=\.)/, ver) : f[:target]
|
92
79
|
l << { type: f[:type], content: c }
|
@@ -103,81 +90,70 @@ module RelatonIetf
|
|
103
90
|
RelatonIetf::IetfBibliographicItem.new **attrs
|
104
91
|
end
|
105
92
|
|
106
|
-
# @param uri_nums [Array<String>]
|
107
93
|
# @param ref [String]
|
94
|
+
# @param is_relation [Boolen, nil]
|
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
|
-
|
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
|
+
r = doc.at("/referencegroup", "/reference")
|
106
|
+
fetch_rfc r, is_relation: is_relation, url: uri, ver: ver
|
146
107
|
end
|
147
108
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
)
|
109
|
+
# @param reference [Nokogiri::XML::Element]
|
110
|
+
# @return [Hash]
|
111
|
+
def relations(reference)
|
112
|
+
reference.xpath("reference").map do |ref|
|
113
|
+
{ type: "includes", bibitem: fetch_rfc(ref, is_relation: true) }
|
154
114
|
end
|
155
115
|
end
|
156
116
|
|
117
|
+
# @param uri [String]
|
118
|
+
# @return [String] HTTP response body
|
157
119
|
def get_page(uri)
|
158
120
|
res = Net::HTTP.get_response(URI(uri))
|
159
|
-
|
160
|
-
|
161
|
-
|
121
|
+
return unless res.code == "200"
|
122
|
+
|
123
|
+
# raise RelatonBib::RequestError, "No document found at #{uri}"
|
124
|
+
# end
|
162
125
|
|
163
126
|
res.body
|
164
127
|
end
|
165
128
|
|
166
|
-
#
|
167
|
-
# uri_template.gsub("CODE", reference)
|
168
|
-
# end
|
169
|
-
|
129
|
+
# @param reference [Nokogiri::XML::Element]
|
170
130
|
# @return [String]
|
171
131
|
def language(reference)
|
172
132
|
reference[:lang] || "en"
|
173
133
|
end
|
174
134
|
|
135
|
+
# @param reference [Nokogiri::XML::Element]
|
175
136
|
# @return [Array<Hash>]
|
176
137
|
def titles(reference)
|
177
|
-
|
178
|
-
|
138
|
+
reference.xpath("./front/title").map do |title|
|
139
|
+
{ content: title.text, language: language(reference), script: "Latn" }
|
140
|
+
end
|
179
141
|
end
|
180
142
|
|
143
|
+
# @param reference [Nokogiri::XML::Element]
|
144
|
+
# @return [RelatonBib::FormattedRef, nil]
|
145
|
+
def formattedref(reference)
|
146
|
+
return if reference.at "./fornt/title"
|
147
|
+
|
148
|
+
cont = (reference[:anchor] || reference[:docName] || reference[:number])
|
149
|
+
if cont
|
150
|
+
RelatonBib::FormattedRef.new(
|
151
|
+
content: cont, language: language(reference), script: "Latn",
|
152
|
+
)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# @param reference [Nokogiri::XML::Element]
|
181
157
|
# @return [Array<RelatonBib::FormattedString>]
|
182
158
|
def abstracts(ref)
|
183
159
|
ref.xpath("./front/abstract").map do |a|
|
@@ -188,15 +164,17 @@ module RelatonIetf
|
|
188
164
|
end
|
189
165
|
end
|
190
166
|
|
167
|
+
# @param reference [Nokogiri::XML::Element]
|
191
168
|
# @return [Array<Hash>]
|
192
169
|
def contributors(reference)
|
193
170
|
persons(reference) + organizations(reference)
|
194
171
|
end
|
195
172
|
|
173
|
+
# @param reference [Nokogiri::XML::Element]
|
196
174
|
# @return [Array<Hash{Symbol=>RelatonBib::Person,Symbol=>Array<String>}>]
|
197
175
|
def persons(reference)
|
198
|
-
reference.xpath("./front/author[@surname]|./front/author[@fullname]")
|
199
|
-
map do |author|
|
176
|
+
reference.xpath("./front/author[@surname]|./front/author[@fullname]")
|
177
|
+
.map do |author|
|
200
178
|
entity = RelatonBib::Person.new(
|
201
179
|
name: full_name(author, reference),
|
202
180
|
affiliation: [affiliation(author)],
|
@@ -206,7 +184,9 @@ module RelatonIetf
|
|
206
184
|
end
|
207
185
|
end
|
208
186
|
|
209
|
-
# @
|
187
|
+
# @param reference [Nokogiri::XML::Element]
|
188
|
+
# @return [Array<Hash{Symbol=>RelatonBib::Organization,
|
189
|
+
# Symbol=>Array<String>}>]
|
210
190
|
def organizations(reference)
|
211
191
|
publisher = { entity: new_org, role: [type: "publisher"] }
|
212
192
|
orgs = reference.xpath("./seriesinfo").reduce([publisher]) do |mem, si|
|
@@ -221,8 +201,8 @@ module RelatonIetf
|
|
221
201
|
end
|
222
202
|
end
|
223
203
|
|
224
|
-
# @param author [Nokogiri::XML::
|
225
|
-
# @param ref [Nokogiri::XML::
|
204
|
+
# @param author [Nokogiri::XML::Element]
|
205
|
+
# @param ref [Nokogiri::XML::Element]
|
226
206
|
# @return [RelatonBib::FullName]
|
227
207
|
def full_name(author, ref)
|
228
208
|
lang = language ref
|
@@ -242,7 +222,7 @@ module RelatonIetf
|
|
242
222
|
RelatonBib::LocalizedString.new(content, lang)
|
243
223
|
end
|
244
224
|
|
245
|
-
# @param postal [Nokogiri::XML::
|
225
|
+
# @param postal [Nokogiri::XML::Element]
|
246
226
|
# @return [Array<RelatonBib::Address, RelatonBib::Phone>]
|
247
227
|
def contacts(addr)
|
248
228
|
contacts = []
|
@@ -256,9 +236,9 @@ module RelatonIetf
|
|
256
236
|
contacts
|
257
237
|
end
|
258
238
|
|
259
|
-
# @param postal [Nokogiri::XML::
|
239
|
+
# @param postal [Nokogiri::XML::Element]
|
260
240
|
# @rerurn [RelatonBib::Address]
|
261
|
-
def address(postal)
|
241
|
+
def address(postal) # rubocop:disable Metrics/CyclomaticComplexity
|
262
242
|
RelatonBib::Address.new(
|
263
243
|
street: [(postal.at("./postalLine") || postal.at("./street"))&.text],
|
264
244
|
city: postal.at("./city")&.text,
|
@@ -276,7 +256,7 @@ module RelatonIetf
|
|
276
256
|
contacts << RelatonBib::Contact.new(type: type, value: value.text)
|
277
257
|
end
|
278
258
|
|
279
|
-
# @param author [Nokogiri::XML::
|
259
|
+
# @param author [Nokogiri::XML::Element]
|
280
260
|
# @return [RelatonBib::Affiliation]
|
281
261
|
def affiliation(author)
|
282
262
|
organization = author.at("./organization")
|
@@ -303,7 +283,7 @@ module RelatonIetf
|
|
303
283
|
|
304
284
|
def month(mon)
|
305
285
|
return 1 if !mon || mon.empty?
|
306
|
-
return mon if /^\d
|
286
|
+
return mon if /^\d+$/.match? mon
|
307
287
|
|
308
288
|
Date::MONTHNAMES.index(mon)
|
309
289
|
end
|
@@ -311,6 +291,7 @@ module RelatonIetf
|
|
311
291
|
#
|
312
292
|
# Extract date from reference.
|
313
293
|
#
|
294
|
+
# @param reference [Nokogiri::XML::Element]
|
314
295
|
# @return [Array<RelatonBib::BibliographicDate>] published data.
|
315
296
|
#
|
316
297
|
def dates(reference)
|
@@ -322,8 +303,6 @@ module RelatonIetf
|
|
322
303
|
[RelatonBib::BibliographicDate.new(type: "published", on: date)]
|
323
304
|
end
|
324
305
|
|
325
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
326
|
-
|
327
306
|
#
|
328
307
|
# Extract document identifiers from reference
|
329
308
|
#
|
@@ -332,7 +311,7 @@ module RelatonIetf
|
|
332
311
|
#
|
333
312
|
# @return [Array<RelatonBib::DocumentIdentifier>]
|
334
313
|
#
|
335
|
-
def docids(reference, ver)
|
314
|
+
def docids(reference, ver) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
|
336
315
|
id = (reference[:anchor] || reference[:docName] || reference[:number])
|
337
316
|
ret = []
|
338
317
|
if id
|
@@ -351,11 +330,10 @@ module RelatonIetf
|
|
351
330
|
RelatonBib::DocumentIdentifier.new(id: id, type: si[:name])
|
352
331
|
end.compact
|
353
332
|
end
|
354
|
-
# enable Metrics/MethodLength, Metrics/AbcSize
|
355
333
|
|
356
334
|
#
|
357
335
|
# Extract series form reference
|
358
|
-
# @param reference [Nokogiri::XML::
|
336
|
+
# @param reference [Nokogiri::XML::Element]
|
359
337
|
#
|
360
338
|
# @return [Array<RelatonBib::Series>]
|
361
339
|
#
|
@@ -375,7 +353,7 @@ module RelatonIetf
|
|
375
353
|
|
376
354
|
#
|
377
355
|
# extract status
|
378
|
-
# @param reference [Nokogiri::XML::
|
356
|
+
# @param reference [Nokogiri::XML::Element]
|
379
357
|
#
|
380
358
|
# @return [RelatonBib::DocumentStatus]
|
381
359
|
#
|
@@ -383,9 +361,7 @@ module RelatonIetf
|
|
383
361
|
st = reference.at("./seriesinfo[@status]")
|
384
362
|
return unless st
|
385
363
|
|
386
|
-
RelatonBib::DocumentStatus.new(
|
387
|
-
stage: st[:status],
|
388
|
-
)
|
364
|
+
RelatonBib::DocumentStatus.new(stage: st[:status])
|
389
365
|
end
|
390
366
|
end
|
391
367
|
end
|
data/lib/relaton_ietf/version.rb
CHANGED
data/relaton_ietf.gemspec
CHANGED
@@ -29,12 +29,12 @@ 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
|
-
spec.add_development_dependency "rake", "~>
|
35
|
+
spec.add_development_dependency "rake", "~> 13.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"
|
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.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:
|
11
|
+
date: 2021-05-06 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
|
@@ -58,14 +44,14 @@ dependencies:
|
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
47
|
+
version: '13.0'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
54
|
+
version: '13.0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rspec
|
71
57
|
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
|
@@ -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"
|
@@ -220,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
190
|
- !ruby/object:Gem::Version
|
221
191
|
version: '0'
|
222
192
|
requirements: []
|
223
|
-
rubygems_version: 3.
|
193
|
+
rubygems_version: 3.2.3
|
224
194
|
signing_key:
|
225
195
|
specification_version: 4
|
226
196
|
summary: 'RelatonIetf: retrieve IETF Standards for bibliographic use using the BibliographicItem
|
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
|