relaton-itu 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 +4 -4
- data/lib/relaton_itu/config.rb +10 -0
- data/lib/relaton_itu/editorial_group.rb +2 -1
- data/lib/relaton_itu/itu_bibliographic_item.rb +1 -1
- data/lib/relaton_itu/itu_bibliography.rb +13 -13
- data/lib/relaton_itu/util.rb +9 -0
- data/lib/relaton_itu/version.rb +1 -1
- data/lib/relaton_itu.rb +7 -4
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ba25af96c755b3ba32e9318e989f3a7396538c23667112dcde1282fd22b64c4b
|
|
4
|
+
data.tar.gz: 1757b9672eeeae25548c7cf2ea3c6f2fb7beb9dbdc5740b452177e20540fc4dc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: adc9864ea7e48260cb0aa5550b0fbaa2a4943359537acaf75a974514f9a034dd34a01842da5abd2b5b65cffb796f022dbb5f8527fc1addcd915e4646340eb502
|
|
7
|
+
data.tar.gz: 24b824c4af92c5aa195abd7681f9e24f370450555cef3018e67280257eccc0b6e4290a70c2270406f70e0714cbc5c651b2d1fdf94d4babff2ca37209a0455918
|
|
@@ -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 "
|
|
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 "
|
|
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 = "
|
|
27
|
-
warn "
|
|
28
|
-
warn "
|
|
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 "
|
|
68
|
-
|
|
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 "
|
|
71
|
-
|
|
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 "
|
|
78
|
-
|
|
79
|
-
|
|
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 "
|
|
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 "
|
|
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])
|
data/lib/relaton_itu/version.rb
CHANGED
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.
|
|
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-
|
|
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
|