relaton-itu 1.18.1 → 1.19.0

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: 4feed9e3d20fa1ff371c313f632f82a18285cd21a1437ddc1d0e1f0840e77b52
4
- data.tar.gz: 4d8e6ab3951378ef210e7759702baacff44af33b401fbdc9fee9ec20fe961c47
3
+ metadata.gz: 219f17d8c2ce91f1cda9b3d9a62dcff98acfda8509da719e2d85c5b7f889bdbb
4
+ data.tar.gz: 7e3571c36ed301ffe9e1810cab3a877c9657a54c16981905f4ff38c9028182a2
5
5
  SHA512:
6
- metadata.gz: ba1d009a5e8ef6744ebc47b58fe581573f4db7ca2d91ff67fba3b0207160d5e82ca422fdb36712fd145d1e2e5c742b2d09d2071a596c7148c229bc9eeb742b92
7
- data.tar.gz: 659b0cbc5e52f96ebee57eba1090b5010539e9edfc81f0dd25435e153eb1b7e9aec6579edde895e144a57fe7ca5664067607c9783d9b3874cab20627951a83e9
6
+ metadata.gz: 7bd181e792b81c2edf7a8e21133e8241ac3e918f930911631ab1adf9a1e1207281c0845b858d024bf39f025bb7ef212cba834c3efe1e8ac7afcae19a262f3451
7
+ data.tar.gz: 61b8a6c59a46a2197bd3cc0af81397407f5f617ef9819b66b2a2d97619bffdbfa24a4fba6b3fe8d5dc0d264c23a4bb0441608da4802dc3b097c361fed655edfc
data/README.adoc CHANGED
@@ -29,24 +29,13 @@ Or install it yourself as:
29
29
 
30
30
  == Usage
31
31
 
32
- === Configuration
33
-
34
- Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonItu.configure` block.
32
+ === Search for a standard using keywords
35
33
 
36
34
  [source,ruby]
37
35
  ----
38
36
  require 'relaton_itu'
39
37
  => true
40
38
 
41
- RelatonItu.configure do |config|
42
- config.logger.level = Logger::DEBUG
43
- end
44
- ----
45
-
46
- === Search for a standard using keywords
47
-
48
- [source,ruby]
49
- ----
50
39
  hit_collection = RelatonItu::ItuBibliography.search("ITU-T L.163")
51
40
  => <RelatonItu::HitCollection:0x007fbf5fb4ab60 @ref=ITU-T L.163 @fetched=false>
52
41
 
@@ -165,6 +154,10 @@ Done in: 390 sec.
165
154
  => nil
166
155
  ----
167
156
 
157
+ === Logging
158
+
159
+ RelatonItu uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
160
+
168
161
  == Development
169
162
 
170
163
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -244,6 +244,9 @@
244
244
  <data type="ID"/>
245
245
  </attribute>
246
246
  <attribute name="reviewer"/>
247
+ <optional>
248
+ <attribute name="type"/>
249
+ </optional>
247
250
  <optional>
248
251
  <attribute name="date">
249
252
  <data type="dateTime"/>
@@ -36,8 +36,7 @@ module RelatonItu
36
36
  bib = DataParserR.parse doc, url, type
37
37
  write_file bib
38
38
  rescue => e # rubocop:disable Style/RescueStandardError
39
- warn e.message
40
- warn e.backtrace
39
+ Util.error "#{e.message}\n#{e.backtrace}"
41
40
  end
42
41
 
43
42
  def self.fetch(output: "data", format: "yaml")
@@ -128,7 +127,7 @@ module RelatonItu
128
127
  id = bib.docidentifier[0].id.gsub(/[\s.]/, "_")
129
128
  file = "#{@output}/#{id}.#{@ext}"
130
129
  if files.include? file
131
- warn "File #{file} exists."
130
+ Util.warn "File #{file} exists."
132
131
  else
133
132
  files << file
134
133
  end
@@ -14,7 +14,7 @@ module RelatonItu
14
14
 
15
15
  def check_type(type)
16
16
  unless TYPES.include? type
17
- Util.warn "WARNING: Invalid doctype: `#{type}`"
17
+ Util.warn "Invalid doctype: `#{type}`"
18
18
  end
19
19
  end
20
20
  end
@@ -17,8 +17,7 @@ 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
- Util.warn "WARNING: Invalid bureau: `#{bureau}`"
21
- Util.warn "WARNING: Valid bureaus are: `#{BUREAUS.join('`, `')}`"
20
+ Util.warn "Invalid bureau: `#{bureau}`\nValid bureaus are: `#{BUREAUS.join('`, `')}`"
22
21
  end
23
22
  @bureau = bureau
24
23
  @group = group.is_a?(Hash) ? ItuGroup.new(**group) : group
@@ -40,7 +40,7 @@ module RelatonItu
40
40
  private
41
41
 
42
42
  def request_search
43
- Util.warn "(#{@refid}) Fetching from www.itu.int ..."
43
+ Util.info "Fetching from www.itu.int ...", key: @refid.to_s
44
44
  url = "#{DOMAIN}/net4/ITU-T/search/GlobalSearch/RunSearch"
45
45
  data = { json: params.to_json }
46
46
  resp = agent.post url, data
@@ -48,7 +48,7 @@ module RelatonItu
48
48
  end
49
49
 
50
50
  def request_document # rubocop:todo Metrics/MethodLength, Metrics/AbcSize
51
- Util.warn "(#{@refid}) Fetching from Relaton repository ..."
51
+ Util.info "Fetching from Relaton repository ...", key: @refid.to_s
52
52
  index = Relaton::Index.find_or_create :itu, url: "#{GH_ITU_R}index-v1.zip", file: INDEX_FILE
53
53
  row = index.search(@refid.to_ref).min_by { |i| i[:id] }
54
54
  return unless row
@@ -23,8 +23,7 @@ module RelatonItu
23
23
  refid = RelatonItu::Pubid.parse refid if refid.is_a? String
24
24
  if refid.to_ref =~ /(ITU[\s-]T\s\w)\.(Suppl\.|Annex)\s?(\w?\d+)/
25
25
  correct_ref = "#{$~[1]} #{$~[2]} #{$~[3]}"
26
- Util.warn "WARNING: Incorrect reference: `#{refid}`"
27
- Util.warn "the reference should be: `#{correct_ref}`"
26
+ Util.info "Incorrect reference: `#{refid}`, the reference should be: `#{correct_ref}`"
28
27
  end
29
28
  HitCollection.new refid
30
29
  rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse,
@@ -63,13 +62,13 @@ module RelatonItu
63
62
  private
64
63
 
65
64
  def fetch_ref_err(refid, missed_years) # rubocop:disable Metrics/MethodLength
66
- # Util.warn "WARNING: no match found online for `#{refid}`. " \
65
+ # Util.warn "no match found online for `#{refid}`. " \
67
66
  # "The code must be exactly like it is on the standards website."
68
- Util.warn "(#{refid}) Not found."
67
+ Util.info "Not found.", key: refid.to_s
69
68
  if missed_years.any?
70
69
  plural = missed_years.size > 1 ? "s" : ""
71
- Util.warn "(#{refid}) There was no match for `#{refid.year}` year, though " \
72
- "there were matches found for `#{missed_years.join('`, `')}` year#{plural}."
70
+ Util.info "There was no match for `#{refid.year}` year, though there were matches " \
71
+ "found for `#{missed_years.join('`, `')}` year#{plural}.", key: refid.to_s
73
72
  end
74
73
  # if /\d-\d/.match? refid.code
75
74
  # warn "[relaton-itu] The provided document part may not exist, or " \
@@ -144,7 +143,7 @@ module RelatonItu
144
143
  result = search_filter(refid) || return
145
144
  ret = isobib_results_filter(result, refid)
146
145
  if ret[:ret]
147
- Util.warn "(#{refid}) Found: `#{ret[:ret].docidentifier.first&.id}`"
146
+ Util.info "Found: `#{ret[:ret].docidentifier.first&.id}`", key: refid.to_s
148
147
  ret[:ret]
149
148
  else
150
149
  fetch_ref_err(refid, ret[:years])
@@ -65,8 +65,8 @@ module RelatonItu
65
65
  id_parts = Parser.new.parse(id).to_h.transform_values(&:to_s)
66
66
  new(**id_parts)
67
67
  rescue Parslet::ParseFailed => e
68
- Util.warn "WARNING: `#{id}` is invalid ITU publication identifier \n" \
69
- "#{e.parse_failure_cause.ascii_tree}"
68
+ Util.error "`#{id}` is invalid ITU publication identifier\n" \
69
+ "#{e.parse_failure_cause.ascii_tree}"
70
70
  raise e
71
71
  end
72
72
 
@@ -87,7 +87,7 @@ module RelatonItu
87
87
  script: "Latn",
88
88
  }]
89
89
  rescue Mechanize::ResponseCodeError => e
90
- Util.warn "HTTP Service Unavailable: #{e.message}"
90
+ Util.error "HTTP Service Unavailable: #{e.message}"
91
91
  []
92
92
  end
93
93
 
@@ -11,7 +11,7 @@ module RelatonItu
11
11
  # @param annexid [String, NilClass]
12
12
  def initialize(bureau:, docnumber:, annexid: nil)
13
13
  unless EditorialGroup::BUREAUS.include? bureau
14
- Util.warn "WARNING: Invalid bureau: `#{bureau}`"
14
+ Util.warn "Invalid bureau: `#{bureau}`"
15
15
  end
16
16
  @bureau = bureau
17
17
  @docnumber = docnumber
@@ -1,9 +1,6 @@
1
1
  module RelatonItu
2
2
  module Util
3
3
  extend RelatonBib::Util
4
-
5
- def self.logger
6
- RelatonItu.configuration.logger
7
- end
4
+ PROGNAME = "relaton-itu".freeze
8
5
  end
9
6
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonItu
2
- VERSION = "1.18.1".freeze
2
+ VERSION = "1.19.0".freeze
3
3
  end
@@ -8,7 +8,7 @@ module RelatonItu
8
8
  # @param item_hash [Hash]
9
9
  # @return [RelatonItu::ItuBibliographicItem]
10
10
  def bib_item(item_hash)
11
- ItuBibliographicItem.new **item_hash
11
+ ItuBibliographicItem.new(**item_hash)
12
12
  end
13
13
 
14
14
  # @param ext [Nokogiri::XML::Element]
@@ -59,6 +59,10 @@ module RelatonItu
59
59
  an = sid.at("annexid")&.text
60
60
  StructuredIdentifier.new(bureau: br, docnumber: dn, annexid: an)
61
61
  end
62
+
63
+ def create_doctype(type)
64
+ DocumentType.new type: type.text, abbreviation: type[:abbreviation]
65
+ end
62
66
  end
63
67
  end
64
68
  end
data/lib/relaton_itu.rb CHANGED
@@ -4,7 +4,6 @@ require "digest/md5"
4
4
  require "relaton/index"
5
5
  require "relaton_bib"
6
6
  require "relaton_itu/version"
7
- require "relaton_itu/config"
8
7
  require "relaton_itu/util"
9
8
  require "relaton_itu/document_type"
10
9
  require "relaton_itu/pubid"
data/relaton-itu.gemspec CHANGED
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency "mechanize", "~> 2.10"
29
29
  spec.add_dependency "parslet", "~> 2.0.0"
30
- spec.add_dependency "relaton-bib", "~> 1.18.0"
30
+ spec.add_dependency "relaton-bib", "~> 1.19.0"
31
31
  spec.add_dependency "relaton-index", "~> 0.2.0"
32
32
  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.18.1
4
+ version: 1.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-19 00:00:00.000000000 Z
11
+ date: 2024-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.18.0
47
+ version: 1.19.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.18.0
54
+ version: 1.19.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: relaton-index
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -92,7 +92,6 @@ 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
96
95
  - lib/relaton_itu/data_fetcher.rb
97
96
  - lib/relaton_itu/data_parser_r.rb
98
97
  - lib/relaton_itu/document_type.rb
@@ -1,10 +0,0 @@
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