relaton-iana 1.14.2 → 1.14.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e28db214fb7ee96d95437e096953b44088e3dcb0b0255a224773a2c3d0265ed2
4
- data.tar.gz: 397b757c60191a373016f767ef76bd34000a77d4039ea85bd022376ca40fc3f1
3
+ metadata.gz: dbfa9e6bb7c8bdc2772554010aaedc00425f0f43d757ac6d0a4b22688a9e52d7
4
+ data.tar.gz: 67b12ec014b790910297134c3a8b5fccc6ad14c9f0f085038942a26afd8b3bbb
5
5
  SHA512:
6
- metadata.gz: 82a9ba0764bae580b8938ef563e35b31da5a666e5accf9b99ff0f92ca9d1d2bb1c7f64515b545534efe1cb417cf68915507983be0fcbe34eb444380c3c5fe886
7
- data.tar.gz: c28062035798f285063e3fff10b6a508998512f77e8ed7d63c4918980df97de8b7e0c5bb2a2a98c7a1142b6e047040ddff7984e6179f21fb6fbc70fb6628ad60
6
+ metadata.gz: 5c5d6e87589523a0eda7d29f9cc99f70fb541f62b2be4e60ab286356fda69eaa1f7a3afc9de8359fbef33618a3d1573204632a845c305c802223cd6a6789733a
7
+ data.tar.gz: a0dab69a5515878c328fd837e048c6b9e47f44803d33ed3cf0e07bfea53f55223d7b8693bf1775b8f9fec7aa3651b13350fcdcf9dc2a07e4ed5a83f42f878c26
@@ -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
  #
@@ -41,6 +40,7 @@ module RelatonIana
41
40
  rescue StandardError => e
42
41
  warn "Error: #{e.message}. File: #{file}"
43
42
  end
43
+ @index.save
44
44
  end
45
45
 
46
46
  def parse(content)
@@ -70,6 +70,7 @@ module RelatonIana
70
70
  else
71
71
  @files << file
72
72
  end
73
+ @index.add_or_update bib.docnumber, file
73
74
  File.write file, c, encoding: "UTF-8"
74
75
  end
75
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/data/"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonIana
4
- VERSION = "1.14.2"
4
+ VERSION = "1.14.3"
5
5
  end
data/lib/relaton_iana.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "faraday"
4
+ require "relaton/index"
4
5
  require "relaton_bib"
5
6
  require_relative "relaton_iana/version"
6
7
  require_relative "relaton_iana/iana_bibliographic_item"
data/relaton_iana.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
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.
@@ -33,6 +34,7 @@ Gem::Specification.new do |spec|
33
34
 
34
35
  spec.add_dependency "faraday", "~> 2.7.0"
35
36
  spec.add_dependency "relaton-bib", "~> 1.14.0"
37
+ spec.add_dependency "relaton-index", "~> 0.2.0"
36
38
 
37
39
  # Uncomment to register a new dependency of your gem
38
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.2
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: 2023-05-20 00:00:00.000000000 Z
11
+ date: 2023-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.14.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: relaton-index
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.0
55
69
  description: 'RelatonIana: Ruby XMLDOC impementation.'
56
70
  email:
57
71
  - open.source@ribose.com