relaton-itu 1.16.0 → 1.16.1

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: b7d07b59787bd399ec0100f37ab66cf50b2c69e1a30a1e5466db2ceca8dbf908
4
- data.tar.gz: ef1b9720c0797daba527de587e52d86866297aa3f9ada5ee594ac9ecec998f69
3
+ metadata.gz: ba25af96c755b3ba32e9318e989f3a7396538c23667112dcde1282fd22b64c4b
4
+ data.tar.gz: 1757b9672eeeae25548c7cf2ea3c6f2fb7beb9dbdc5740b452177e20540fc4dc
5
5
  SHA512:
6
- metadata.gz: 3ae2909366f26f5d76e6a44efd5eaf7cadb0efcb6b644dca908d48bc4e7af2e3404e5f4699085210d3aaf7fa58d6d221f059f70dc3f5c2a49a7b9f05fe1f7d8d
7
- data.tar.gz: e4b564c0166c953529af568bef7ea8e292eb72173d0fbf9c89626522d6a576383df57f6be5ffe714c2bbd82380f014439110caf2cb97072033200cee9148d8eb
6
+ metadata.gz: adc9864ea7e48260cb0aa5550b0fbaa2a4943359537acaf75a974514f9a034dd34a01842da5abd2b5b65cffb796f022dbb5f8527fc1addcd915e4646340eb502
7
+ data.tar.gz: 24b824c4af92c5aa195abd7681f9e24f370450555cef3018e67280257eccc0b6e4290a70c2270406f70e0714cbc5c651b2d1fdf94d4babff2ca37209a0455918
@@ -0,0 +1,10 @@
1
+ module RelatonItu
2
+ module Config
3
+ include RelatonBib::Config
4
+ end
5
+ extend Config
6
+
7
+ class Configuration < RelatonBib::Configuration
8
+ PROGNAME = "relaton-itu".freeze
9
+ end
10
+ end
@@ -17,7 +17,8 @@ module RelatonItu
17
17
  # @param workgroup [Hash, RelatonItu::ItuGroup, NilClass]
18
18
  def initialize(bureau:, group:, subgroup: nil, workgroup: nil)
19
19
  unless BUREAUS.include? bureau
20
- warn "[relaton-itu] WARNING: invalid bureau: #{bureau}"
20
+ Util.warn "WARNING: invalid bureau: `#{bureau}`"
21
+ Util.warn "WARNING: valid bureaus are: `#{BUREAUS.join('`, `')}`"
21
22
  end
22
23
  @bureau = bureau
23
24
  @group = group.is_a?(Hash) ? ItuGroup.new(**group) : group
@@ -10,7 +10,7 @@ module RelatonItu
10
10
  # @params structuredidentifier [RelatonItu::StructuredIdentifier]
11
11
  def initialize(**args)
12
12
  if args[:doctype] && !TYPES.include?(args[:doctype])
13
- warn "[relaton-itu] WARNING: invalid doctype: #{args[:doctype]}"
13
+ Util.warn "WARNING: invalid doctype: `#{args[:doctype]}`"
14
14
  end
15
15
  super
16
16
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "relaton_bib"
4
3
  require "relaton_itu/itu_bibliographic_item"
5
4
  require "relaton_itu/editorial_group"
6
5
  require "relaton_itu/structured_identifier"
@@ -23,9 +22,9 @@ module RelatonItu
23
22
  def search(refid)
24
23
  refid = RelatonItu::Pubid.parse refid if refid.is_a? String
25
24
  if refid.to_ref =~ /(ITU[\s-]T\s\w)\.(Suppl\.|Annex)\s?(\w?\d+)/
26
- correct_ref = "#{$~[1]} #{$~[2]} #{$~[3]}"
27
- warn "[relaton-itu] WARNING: Incorrect reference #{refid}"
28
- warn "[relaton-itu] the reference should be #{correct_ref}"
25
+ correct_ref = "`#{$~[1]}` `#{$~[2]}` `#{$~[3]}`"
26
+ Util.warn "WARNING: Incorrect reference `#{refid}`"
27
+ Util.warn "the reference should be #{correct_ref}"
29
28
  end
30
29
  HitCollection.new refid
31
30
  rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse,
@@ -64,20 +63,21 @@ module RelatonItu
64
63
  private
65
64
 
66
65
  def fetch_ref_err(refid, missed_years) # rubocop:disable Metrics/MethodLength
67
- warn "[relaton-itu] WARNING: no match found online for #{refid}. " \
68
- "The code must be exactly like it is on the standards website."
66
+ Util.warn "WARNING: no match found online for `#{refid}`. " \
67
+ "The code must be exactly like it is on the standards website."
69
68
  unless missed_years.empty?
70
- warn "[relaton-itu] (There was no match for #{refid.year}, though there " \
71
- "were matches found for #{missed_years.join(', ')}.)"
69
+ Util.warn "(There was no match for `#{refid.year}`, though there " \
70
+ "were matches found for `#{missed_years.join('`, `')}`.)"
72
71
  end
73
72
  # if /\d-\d/.match? refid.code
74
73
  # warn "[relaton-itu] The provided document part may not exist, or " \
75
74
  # "the document may no longer be published in parts."
76
75
  # else
77
- warn "[relaton-itu] If you wanted to cite all document parts for the reference, " \
78
- "use \"#{refid} (all parts)\".\nIf the document is not a standard, " \
79
- "use its document type abbreviation (TS, TR, PAS, Guide)."
76
+ Util.warn "If you wanted to cite all document parts for the reference, " \
77
+ "use `#{refid} (all parts)`.\nIf the document is not a standard, " \
78
+ "use its document type abbreviation `S`, `TR`, `PAS`, `Guide`)."
80
79
  # end
80
+ nil
81
81
  end
82
82
 
83
83
  def search_filter(refid) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
@@ -90,7 +90,7 @@ module RelatonItu
90
90
  # (?:\s\((?:(?<cormonth1>\d{2})/)?(?<coryear1>\d{4})\))?
91
91
  # }x =~ code
92
92
  # year ||= year1
93
- warn "[relaton-itu] (\"#{refid}\") fetching..."
93
+ Util.warn "(#{refid}) fetching..."
94
94
  result = search(refid)
95
95
  # refid.code.sub!(/(?<=\.)Imp(?=\d)/, "") if result.gi_imp
96
96
  # if corr1
@@ -143,7 +143,7 @@ module RelatonItu
143
143
  result = search_filter(refid) || return
144
144
  ret = isobib_results_filter(result, refid)
145
145
  if ret[:ret]
146
- warn "[relaton-itu] (\"#{refid}\") found #{ret[:ret].docidentifier.first&.id}"
146
+ Util.warn "(#{refid}) found `#{ret[:ret].docidentifier.first&.id}`"
147
147
  ret[:ret]
148
148
  else
149
149
  fetch_ref_err(refid, ret[:years])
@@ -0,0 +1,9 @@
1
+ module RelatonItu
2
+ module Util
3
+ extend RelatonBib::Util
4
+
5
+ def self.logger
6
+ RelatonItu.configuration.logger
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module RelatonItu
2
- VERSION = "1.16.0".freeze
2
+ VERSION = "1.16.1".freeze
3
3
  end
data/lib/relaton_itu.rb CHANGED
@@ -2,7 +2,10 @@ require "mechanize"
2
2
  require "parslet"
3
3
  require "digest/md5"
4
4
  require "relaton/index"
5
+ require "relaton_bib"
5
6
  require "relaton_itu/version"
7
+ require "relaton_itu/config"
8
+ require "relaton_itu/util"
6
9
  require "relaton_itu/pubid"
7
10
  require "relaton_itu/itu_bibliography"
8
11
  require "relaton_itu/data_fetcher"
@@ -14,9 +17,9 @@ module RelatonItu
14
17
  # Returns hash of XML reammar
15
18
  # @return [String]
16
19
  def self.grammar_hash
17
- gem_path = File.expand_path "..", __dir__
18
- grammars_path = File.join gem_path, "grammars", "*"
19
- grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
20
- Digest::MD5.hexdigest grammars
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 RelatonItu::VERSION + RelatonBib::VERSION # grammars
21
24
  end
22
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-itu
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: exe
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: mechanize
@@ -92,6 +92,7 @@ files:
92
92
  - grammars/relaton-itu-compile.rng
93
93
  - grammars/relaton-itu.rng
94
94
  - lib/relaton_itu.rb
95
+ - lib/relaton_itu/config.rb
95
96
  - lib/relaton_itu/data_fetcher.rb
96
97
  - lib/relaton_itu/data_parser_r.rb
97
98
  - lib/relaton_itu/editorial_group.rb
@@ -105,6 +106,7 @@ files:
105
106
  - lib/relaton_itu/pubid.rb
106
107
  - lib/relaton_itu/scrapper.rb
107
108
  - lib/relaton_itu/structured_identifier.rb
109
+ - lib/relaton_itu/util.rb
108
110
  - lib/relaton_itu/version.rb
109
111
  - lib/relaton_itu/xml_parser.rb
110
112
  - relaton-itu.gemspec