relaton-iana 1.14.1 → 1.14.3
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 +1 -0
- data/.github/workflows/release.yml +3 -2
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/Gemfile +6 -0
- data/README.adoc +1 -1
- data/grammars/basicdoc.rng +0 -1
- data/grammars/biblio.rng +12 -2
- data/lib/relaton_iana/data_fetcher.rb +15 -53
- data/lib/relaton_iana/iana_bibliography.rb +10 -3
- data/lib/relaton_iana/processor.rb +7 -0
- data/lib/relaton_iana/version.rb +1 -1
- data/lib/relaton_iana.rb +1 -1
- data/relaton_iana.gemspec +5 -11
- metadata +11 -109
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbfa9e6bb7c8bdc2772554010aaedc00425f0f43d757ac6d0a4b22688a9e52d7
|
4
|
+
data.tar.gz: 67b12ec014b790910297134c3a8b5fccc6ad14c9f0f085038942a26afd8b3bbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c5d6e87589523a0eda7d29f9cc99f70fb541f62b2be4e60ab286356fda69eaa1f7a3afc9de8359fbef33618a3d1573204632a845c305c802223cd6a6789733a
|
7
|
+
data.tar.gz: a0dab69a5515878c328fd837e048c6b9e47f44803d33ed3cf0e07bfea53f55223d7b8693bf1775b8f9fec7aa3651b13350fcdcf9dc2a07e4ed5a83f42f878c26
|
data/.github/workflows/rake.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/README.adoc
CHANGED
@@ -111,7 +111,7 @@ Done in: 155 sec.
|
|
111
111
|
|
112
112
|
This method uses GitHub search API to fetch the documents. The search API has a https://docs.github.com/en/rest/reference/search#rate-limit[rate limitaion] of 30 requests per minute for authenticated users and 10 requests per minute for unauthenticated users. Usually, the rate limit is not reached because the search API is used only for the file list fetching. But if you run the method multiple times in a short period, the rate limit may be reached. In this case, the method will wait until the rate limit is reset.
|
113
113
|
|
114
|
-
You can use a personal access token to increase the rate limit. To do this, add your
|
114
|
+
You can use a personal access token (PTA) to increase the rate limit. To do this, add your PTA to the `GITHUB_TOKEN` environment variable.
|
115
115
|
|
116
116
|
== Development
|
117
117
|
|
data/grammars/basicdoc.rng
CHANGED
data/grammars/biblio.rng
CHANGED
@@ -216,6 +216,9 @@
|
|
216
216
|
<optional>
|
217
217
|
<ref name="fullname"/>
|
218
218
|
</optional>
|
219
|
+
<zeroOrMore>
|
220
|
+
<ref name="credential"/>
|
221
|
+
</zeroOrMore>
|
219
222
|
<zeroOrMore>
|
220
223
|
<ref name="affiliation"/>
|
221
224
|
</zeroOrMore>
|
@@ -232,6 +235,11 @@
|
|
232
235
|
<ref name="FullNameType"/>
|
233
236
|
</element>
|
234
237
|
</define>
|
238
|
+
<define name="credential">
|
239
|
+
<element name="credential">
|
240
|
+
<text/>
|
241
|
+
</element>
|
242
|
+
</define>
|
235
243
|
<define name="FullNameType">
|
236
244
|
<choice>
|
237
245
|
<group>
|
@@ -305,7 +313,9 @@
|
|
305
313
|
<zeroOrMore>
|
306
314
|
<ref name="affiliationdescription"/>
|
307
315
|
</zeroOrMore>
|
308
|
-
<
|
316
|
+
<optional>
|
317
|
+
<ref name="organization"/>
|
318
|
+
</optional>
|
309
319
|
</element>
|
310
320
|
</define>
|
311
321
|
<define name="affiliationname">
|
@@ -1316,7 +1326,7 @@
|
|
1316
1326
|
<value>commentaryOf</value>
|
1317
1327
|
<value>hasCommentary</value>
|
1318
1328
|
<value>related</value>
|
1319
|
-
<value>
|
1329
|
+
<value>hasComplement</value>
|
1320
1330
|
<value>complementOf</value>
|
1321
1331
|
<value>obsoletes</value>
|
1322
1332
|
<value>obsoletedBy</value>
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module RelatonIana
|
2
2
|
class DataFetcher
|
3
|
-
SOURCE = "https://raw.githubusercontent.com/ietf-ribose/iana-registries/main/".freeze
|
4
|
-
|
5
3
|
#
|
6
4
|
# Data fetcher initializer
|
7
5
|
#
|
@@ -13,6 +11,7 @@ module RelatonIana
|
|
13
11
|
@format = format
|
14
12
|
@ext = format.sub(/^bib/, "")
|
15
13
|
@files = []
|
14
|
+
@index = Relaton::Index.find_or_create :IANA, file: "index-v1.yaml"
|
16
15
|
end
|
17
16
|
|
18
17
|
#
|
@@ -34,60 +33,22 @@ module RelatonIana
|
|
34
33
|
#
|
35
34
|
# Parse documents
|
36
35
|
#
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
}
|
44
|
-
if ENV["GITHUB_TOKEN"]
|
45
|
-
headers = { "Authorization" => "token #{ENV['GITHUB_TOKEN']}" }
|
46
|
-
end
|
47
|
-
attempt = 0
|
48
|
-
json = {}
|
49
|
-
resp = nil
|
50
|
-
until attempt > 3 || json["items"]
|
51
|
-
if attempt.positive?
|
52
|
-
t = resp.headers["x-ratelimit-reset"].to_i - Time.now.to_i
|
53
|
-
if t.positive?
|
54
|
-
t += 30
|
55
|
-
warn "Rate limit is reached. Retrying in #{t} sec."
|
56
|
-
sleep t
|
57
|
-
end
|
58
|
-
end
|
59
|
-
attempt += 1
|
60
|
-
resp = Faraday.get "https://api.github.com/search/code", params, headers
|
61
|
-
json = JSON.parse resp.body
|
62
|
-
end
|
63
|
-
raise StandardError, json["message"] if json["message"]
|
64
|
-
|
65
|
-
json["items"].each do |item|
|
66
|
-
fetch_doc URI.join(SOURCE, item["path"]).to_s
|
36
|
+
def fetch
|
37
|
+
Dir["iana-registries/**/*.xml"].each do |file|
|
38
|
+
content = File.read file, encoding: "UTF-8"
|
39
|
+
parse(content) if content.include? "<registry"
|
40
|
+
rescue StandardError => e
|
41
|
+
warn "Error: #{e.message}. File: #{file}"
|
67
42
|
end
|
68
|
-
|
43
|
+
@index.save
|
69
44
|
end
|
70
45
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
resp = Net::HTTP.get_response URI(url)
|
78
|
-
if resp.code == "200"
|
79
|
-
return unless resp.body.include? "<registry"
|
80
|
-
|
81
|
-
xml = Nokogiri::XML(resp.body)
|
82
|
-
registry = xml.at("/xmlns:registry")
|
83
|
-
doc = Parser.parse registry
|
84
|
-
save_doc doc
|
85
|
-
registry.xpath("./xmlns:registry").each do |r|
|
86
|
-
save_doc Parser.parse(r, doc)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
rescue StandardError => e
|
90
|
-
warn "Error: #{e.message}. URL: #{url}"
|
46
|
+
def parse(content)
|
47
|
+
xml = Nokogiri::XML(content)
|
48
|
+
registry = xml.at("/xmlns:registry")
|
49
|
+
doc = Parser.parse registry
|
50
|
+
save_doc doc
|
51
|
+
registry.xpath("./xmlns:registry").each { |r| save_doc Parser.parse(r, doc) }
|
91
52
|
end
|
92
53
|
|
93
54
|
#
|
@@ -109,6 +70,7 @@ module RelatonIana
|
|
109
70
|
else
|
110
71
|
@files << file
|
111
72
|
end
|
73
|
+
@index.add_or_update bib.docnumber, file
|
112
74
|
File.write file, c, encoding: "UTF-8"
|
113
75
|
end
|
114
76
|
|
@@ -3,13 +3,20 @@
|
|
3
3
|
module RelatonIana
|
4
4
|
# Methods for search IANA standards.
|
5
5
|
module IanaBibliography
|
6
|
-
SOURCE = "https://raw.githubusercontent.com/relaton/relaton-data-iana/main/
|
6
|
+
SOURCE = "https://raw.githubusercontent.com/relaton/relaton-data-iana/main/"
|
7
|
+
INDEX_FILE = "index-v1.yaml"
|
7
8
|
|
8
9
|
# @param text [String]
|
9
10
|
# @return [RelatonIana::IanaBibliographicItem]
|
10
11
|
def search(text) # rubocop:disable Metrics/MethodLength
|
11
|
-
file = text.sub(/^IANA\s/, "").gsub(/[\s,:\/]/, "_").downcase
|
12
|
-
url = "#{SOURCE}#{file}.yaml"
|
12
|
+
# file = text.sub(/^IANA\s/, "").gsub(/[\s,:\/]/, "_").downcase
|
13
|
+
# url = "#{SOURCE}#{file}.yaml"
|
14
|
+
index = Relaton::Index.find_or_create :IANA, url: "#{SOURCE}index-v1.zip", file: INDEX_FILE
|
15
|
+
id = text.sub(/^IANA\s/, "")
|
16
|
+
row = index.search(id).min_by { |i| i[:id] }
|
17
|
+
return unless row
|
18
|
+
|
19
|
+
url = "#{SOURCE}#{row[:file]}"
|
13
20
|
resp = Net::HTTP.get_response URI(url)
|
14
21
|
return unless resp.code == "200"
|
15
22
|
|
@@ -50,5 +50,12 @@ module RelatonIana
|
|
50
50
|
def grammar_hash
|
51
51
|
@grammar_hash ||= ::RelatonIana.grammar_hash
|
52
52
|
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Remove index file
|
56
|
+
#
|
57
|
+
def remove_index_file
|
58
|
+
Relaton::Index.find_or_create(:IANA, url: true, file: IanaBibliography::INDEX_FILE).remove_file
|
59
|
+
end
|
53
60
|
end
|
54
61
|
end
|
data/lib/relaton_iana/version.rb
CHANGED
data/lib/relaton_iana.rb
CHANGED
data/relaton_iana.gemspec
CHANGED
@@ -12,13 +12,14 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "RelatonIana: Ruby XMLDOC impementation."
|
13
13
|
spec.homepage = "https://github.com/relaton/relaton-iana"
|
14
14
|
spec.license = "BSD-2-Clause"
|
15
|
-
spec.required_ruby_version = ">= 2.
|
15
|
+
spec.required_ruby_version = ">= 2.7.0"
|
16
16
|
|
17
17
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'https://mygemserver.com'"
|
18
18
|
|
19
19
|
spec.metadata["homepage_uri"] = spec.homepage
|
20
20
|
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
21
21
|
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
22
|
+
# spec.metadata["rubygems_mfa_required"] = "true"
|
22
23
|
|
23
24
|
# Specify which files should be added to the gem when it is released.
|
24
25
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -30,17 +31,10 @@ Gem::Specification.new do |spec|
|
|
30
31
|
spec.require_paths = ["lib"]
|
31
32
|
|
32
33
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
33
|
-
|
34
|
-
spec.
|
35
|
-
spec.add_development_dependency "rubocop-rails"
|
36
|
-
spec.add_development_dependency "ruby-jing"
|
37
|
-
spec.add_development_dependency "simplecov"
|
38
|
-
spec.add_development_dependency "vcr"
|
39
|
-
spec.add_development_dependency "webmock"
|
40
|
-
|
41
|
-
spec.add_dependency "faraday", "~> 1.0"
|
34
|
+
|
35
|
+
spec.add_dependency "faraday", "~> 2.7.0"
|
42
36
|
spec.add_dependency "relaton-bib", "~> 1.14.0"
|
43
|
-
spec.add_dependency "
|
37
|
+
spec.add_dependency "relaton-index", "~> 0.2.0"
|
44
38
|
|
45
39
|
# Uncomment to register a new dependency of your gem
|
46
40
|
# spec.add_dependency "example-gem", "~> 1.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.14.
|
4
|
+
version: 1.14.3
|
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: 2023-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -24,118 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.6'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rubocop
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rubocop-performance
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop-rails
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: ruby-jing
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: simplecov
|
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
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: vcr
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: webmock
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
27
|
- !ruby/object:Gem::Dependency
|
126
28
|
name: faraday
|
127
29
|
requirement: !ruby/object:Gem::Requirement
|
128
30
|
requirements:
|
129
31
|
- - "~>"
|
130
32
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
33
|
+
version: 2.7.0
|
132
34
|
type: :runtime
|
133
35
|
prerelease: false
|
134
36
|
version_requirements: !ruby/object:Gem::Requirement
|
135
37
|
requirements:
|
136
38
|
- - "~>"
|
137
39
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
40
|
+
version: 2.7.0
|
139
41
|
- !ruby/object:Gem::Dependency
|
140
42
|
name: relaton-bib
|
141
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,19 +53,19 @@ dependencies:
|
|
151
53
|
- !ruby/object:Gem::Version
|
152
54
|
version: 1.14.0
|
153
55
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
56
|
+
name: relaton-index
|
155
57
|
requirement: !ruby/object:Gem::Requirement
|
156
58
|
requirements:
|
157
|
-
- - "
|
59
|
+
- - "~>"
|
158
60
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
61
|
+
version: 0.2.0
|
160
62
|
type: :runtime
|
161
63
|
prerelease: false
|
162
64
|
version_requirements: !ruby/object:Gem::Requirement
|
163
65
|
requirements:
|
164
|
-
- - "
|
66
|
+
- - "~>"
|
165
67
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
68
|
+
version: 0.2.0
|
167
69
|
description: 'RelatonIana: Ruby XMLDOC impementation.'
|
168
70
|
email:
|
169
71
|
- open.source@ribose.com
|
@@ -211,14 +113,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
211
113
|
requirements:
|
212
114
|
- - ">="
|
213
115
|
- !ruby/object:Gem::Version
|
214
|
-
version: 2.
|
116
|
+
version: 2.7.0
|
215
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
118
|
requirements:
|
217
119
|
- - ">="
|
218
120
|
- !ruby/object:Gem::Version
|
219
121
|
version: '0'
|
220
122
|
requirements: []
|
221
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.3.26
|
222
124
|
signing_key:
|
223
125
|
specification_version: 4
|
224
126
|
summary: 'RelatonIana: Ruby XMLDOC impementation.'
|