relaton-itu 1.18.1 → 1.19.0
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/README.adoc +5 -12
- data/grammars/basicdoc.rng +3 -0
- data/lib/relaton_itu/data_fetcher.rb +2 -3
- data/lib/relaton_itu/document_type.rb +1 -1
- data/lib/relaton_itu/editorial_group.rb +1 -2
- data/lib/relaton_itu/hit_collection.rb +2 -2
- data/lib/relaton_itu/itu_bibliography.rb +6 -7
- data/lib/relaton_itu/pubid.rb +2 -2
- data/lib/relaton_itu/scrapper.rb +1 -1
- data/lib/relaton_itu/structured_identifier.rb +1 -1
- data/lib/relaton_itu/util.rb +1 -4
- data/lib/relaton_itu/version.rb +1 -1
- data/lib/relaton_itu/xml_parser.rb +5 -1
- data/lib/relaton_itu.rb +0 -1
- data/relaton-itu.gemspec +1 -1
- metadata +4 -5
- data/lib/relaton_itu/config.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 219f17d8c2ce91f1cda9b3d9a62dcff98acfda8509da719e2d85c5b7f889bdbb
|
4
|
+
data.tar.gz: 7e3571c36ed301ffe9e1810cab3a877c9657a54c16981905f4ff38c9028182a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
===
|
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.
|
data/grammars/basicdoc.rng
CHANGED
@@ -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
|
-
|
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
|
@@ -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 "
|
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.
|
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.
|
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.
|
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 "
|
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.
|
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.
|
72
|
-
"
|
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.
|
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])
|
data/lib/relaton_itu/pubid.rb
CHANGED
@@ -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.
|
69
|
-
|
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
|
|
data/lib/relaton_itu/scrapper.rb
CHANGED
@@ -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 "
|
14
|
+
Util.warn "Invalid bureau: `#{bureau}`"
|
15
15
|
end
|
16
16
|
@bureau = bureau
|
17
17
|
@docnumber = docnumber
|
data/lib/relaton_itu/util.rb
CHANGED
data/lib/relaton_itu/version.rb
CHANGED
@@ -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
|
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
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.
|
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.
|
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-
|
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.
|
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.
|
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
|