relaton-itu 1.18.0 → 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: ceb95b04193dbfb0259bad453b693555b280fc227f2ec32d87b4c742d0c4d86a
4
- data.tar.gz: 8be2489594922bb709ba9ff48e63753d62aa75b2bd770dc07bb8489f676ace3f
3
+ metadata.gz: 219f17d8c2ce91f1cda9b3d9a62dcff98acfda8509da719e2d85c5b7f889bdbb
4
+ data.tar.gz: 7e3571c36ed301ffe9e1810cab3a877c9657a54c16981905f4ff38c9028182a2
5
5
  SHA512:
6
- metadata.gz: 31f5da7f75f5b41cdc9e49bc5824e6f0b65b9fb1c133c6340e9b25947ef7b721391a38284c46a9369a7bccab43d7776b6ac9b3f64792b9f6e1ec915d0176f5ac
7
- data.tar.gz: ebcc191376a2deb893bc355aa09f160cb37fddf79b93a5b54949632093aff2ae007802338dcc9f16e5269ff7e22bb11892e53f2bb74185a3b51b1ee65479ada3
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.0".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
@@ -25,8 +25,8 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
27
27
 
28
- spec.add_dependency "mechanize", "~> 2.8.0"
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.0
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-01-07 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
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.8.0
19
+ version: '2.10'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.8.0
26
+ version: '2.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: parslet
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -130,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
129
  - !ruby/object:Gem::Version
131
130
  version: '0'
132
131
  requirements: []
133
- rubygems_version: 3.3.26
132
+ rubygems_version: 3.3.27
134
133
  signing_key:
135
134
  specification_version: 4
136
135
  summary: 'RelatonItu: retrieve ITU Standards for bibliographic use using the BibliographicItem
@@ -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