relaton-iho 1.16.0 → 1.16.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f42703d14350d77f2b7f27e05bcd39eb2368b93e41663958334510b4f39de72
4
- data.tar.gz: 4858a670fa0dbb5c1d12fd2401ebbce7ef44c9dd57d5f3a30498abb700f2b82d
3
+ metadata.gz: 9081030fd9879044f6a850380bd33459ce7ecdd76869c37364b0364e5b4069cd
4
+ data.tar.gz: e65329781f6306a9eda0850bbff0951d348aaff0359067de4d9c9636dcf31ebb
5
5
  SHA512:
6
- metadata.gz: adf0bec1036948bb9501671ca7116aad714d9accdeeb4ab973c7aec4d64bdf74ffb0a7dc9952d007a19d7ddb6a133d2f146190e4c6c06cd823e5bf8cc80ce7a2
7
- data.tar.gz: e08a8892bdc5f10e359fcba761c8f0bd1757bfe91abb7e906fa866c7697a03f97c1cbc0d8bb90da92a228d89208efebb20bf23228439d58a89be9f6e99131245
6
+ metadata.gz: 584611520dcf2fc502065c40755d328b720026811164bdf265a16e121b2e26e1f77f81ae06e42ca71ba37fd16214ee52ed149a9f3c8529cb2074d895cad3302f
7
+ data.tar.gz: 68bee2e7910c5863aae0411af064c6825f124fff7a996550fdf983f5300bd45deeae128a6aeeac2e3da39bf272c8efe9e3af4c9e0117c7451bbf8aa0a2146fd0
@@ -0,0 +1,10 @@
1
+ module RelatonIho
2
+ module Config
3
+ include RelatonBib::Config
4
+ end
5
+ extend Config
6
+
7
+ class Configuration < RelatonBib::Configuration
8
+ PROGNAME = "relaton-iho".freeze
9
+ end
10
+ end
@@ -14,21 +14,26 @@ module RelatonIho
14
14
  # @return [RelatonIho::IhoBibliographicItem, nil] the IHO standard or nil if not found
15
15
  #
16
16
  def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
17
- warn "[relaton-iho] (\"#{text}\") fetching..."
17
+ Util.warn "(#{text}) fetching..."
18
18
  ref = text.sub(/^IHO\s/, "").sub(/^([[:alpha:]]+)(\d+)/, '\1-\2')
19
19
  index = Relaton::Index.find_or_create :iho, url: "#{ENDPOINT}index.zip"
20
20
  row = index.search(ref).max_by { |r| r[:id] }
21
- return unless row
21
+ unless row
22
+ Util.warn "(#{text}) not found"
23
+ return
24
+ end
22
25
 
23
26
  uri = URI("#{ENDPOINT}#{row[:file]}")
24
27
  resp = Net::HTTP.get_response uri
25
- return unless resp.code == "200"
28
+ unless resp.code == "200"
29
+ raise RelatonBib::RequestError, "Could not access #{uri}: HTTP #{resp.code}"
30
+ end
26
31
 
27
32
  yaml = RelatonBib.parse_yaml resp.body, [Date]
28
33
  hash = HashConverter.hash_to_bib yaml
29
34
  hash[:fetched] = Date.today.to_s
30
35
  item = IhoBibliographicItem.new(**hash)
31
- warn "[relaton-iho] (\"#{text}\") found #{item.docidentifier.first.id}"
36
+ Util.warn "(#{text}) found `#{item.docidentifier.first.id}`"
32
37
  item
33
38
  rescue SocketError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
34
39
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
@@ -0,0 +1,9 @@
1
+ module RelatonIho
2
+ module Util
3
+ extend RelatonBib::Util
4
+
5
+ def self.logger
6
+ RelatonIho.configuration.logger
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module RelatonIho
2
- VERSION = "1.16.0".freeze
2
+ VERSION = "1.16.1".freeze
3
3
  end
data/lib/relaton_iho.rb CHANGED
@@ -3,6 +3,8 @@ require "yaml"
3
3
  require "relaton_bib"
4
4
  require "relaton/index"
5
5
  require "relaton_iho/version"
6
+ require "relaton_iho/config"
7
+ require "relaton_iho/util"
6
8
  require "relaton_iho/iho_bibliography"
7
9
  require "relaton_iho/hash_converter"
8
10
  require "relaton_iho/xml_parser"
@@ -17,9 +19,9 @@ module RelatonIho
17
19
  # Returns hash of XML reammar
18
20
  # @return [String]
19
21
  def self.grammar_hash
20
- gem_path = File.expand_path "..", __dir__
21
- grammars_path = File.join gem_path, "grammars", "*"
22
- grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
23
- Digest::MD5.hexdigest grammars
22
+ # gem_path = File.expand_path "..", __dir__
23
+ # grammars_path = File.join gem_path, "grammars", "*"
24
+ # grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
25
+ Digest::MD5.hexdigest RelatonIho::VERSION + RelatonBib::VERSION # grammars
24
26
  end
25
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iho
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.0
4
+ version: 1.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-03 00:00:00.000000000 Z
11
+ date: 2023-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton-bib
@@ -62,6 +62,7 @@ files:
62
62
  - grammars/relaton-iho.rng
63
63
  - lib/relaton_iho.rb
64
64
  - lib/relaton_iho/comment_periond.rb
65
+ - lib/relaton_iho/config.rb
65
66
  - lib/relaton_iho/editorial_group.rb
66
67
  - lib/relaton_iho/eg.yml
67
68
  - lib/relaton_iho/hash_converter.rb
@@ -69,6 +70,7 @@ files:
69
70
  - lib/relaton_iho/iho_bibliography.rb
70
71
  - lib/relaton_iho/iho_group.rb
71
72
  - lib/relaton_iho/processor.rb
73
+ - lib/relaton_iho/util.rb
72
74
  - lib/relaton_iho/version.rb
73
75
  - lib/relaton_iho/xml_parser.rb
74
76
  - relaton_iho.gemspec