relaton-itu 1.7.9 → 1.7.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_itu/hit_collection.rb +34 -24
- data/lib/relaton_itu/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f6c98c70c690f45d82159a4225bdd5cafe84e4e8fe170f1dc79e4dbae232a66
|
4
|
+
data.tar.gz: 7e08f450152af6f8cfc7778b7dc3598ac462ece4e1211e3d833510f90b34840a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 503c67ce3ec4d6ca257cd04f1ee5c00a26a6468df4f7466be2b8d735e84043605fa72f9304338dc5a9cd9f9ff2845fb66b4cfb59a32d3c6eca4e6eedbea45b8c
|
7
|
+
data.tar.gz: 7cd2cd6444c7654a448f929e81d00ed9bb01bc36d6e24afcea7552b067ac53ca18301bbd7eb07fd7521e127ed80af6fd5b1c6d455426908d326904455854d181
|
@@ -17,37 +17,50 @@ module RelatonItu
|
|
17
17
|
|
18
18
|
# @param ref [String]
|
19
19
|
# @param year [String]
|
20
|
-
def initialize(ref, year = nil) # rubocop:
|
20
|
+
def initialize(ref, year = nil) # rubocop:todo Metrics/MethodLength
|
21
21
|
text = ref.sub /(?<=\.)Imp\s?(?=\d)/, ""
|
22
22
|
super text, year
|
23
23
|
@agent = Mechanize.new
|
24
24
|
agent.user_agent_alias = "Mac Safari"
|
25
25
|
@gi_imp = /\.Imp\d/.match?(ref)
|
26
|
-
if ref.match? /^(ITU-T|ITU-R\sRR)/
|
27
|
-
url = "#{DOMAIN}/net4/ITU-T/search/GlobalSearch/Search"
|
28
|
-
data = { json: params.to_json }
|
29
|
-
resp = agent.post url, data.to_json, "Content-Type" => "application/json"
|
30
|
-
@array = hits JSON.parse(resp.body)
|
31
|
-
elsif ref.match? /^ITU-R/
|
32
|
-
rf = ref.sub(/^ITU-R\s/, "").upcase
|
33
|
-
url = "https://raw.githubusercontent.com/relaton/relaton-data-itu-r/master/data/#{rf}.yaml"
|
34
|
-
resp = Net::HTTP.get_response(URI(url))
|
35
|
-
if resp.code == "404"
|
36
|
-
@array = []
|
37
|
-
return
|
38
|
-
end
|
39
26
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
@array = [hit]
|
27
|
+
case ref
|
28
|
+
when /^(ITU-T|ITU-R\sRR)/
|
29
|
+
request_search
|
30
|
+
when /^ITU-R\s([-_.\w]+)$/
|
31
|
+
request_document($1.upcase)
|
46
32
|
end
|
47
33
|
end
|
48
34
|
|
49
35
|
private
|
50
36
|
|
37
|
+
def request_search
|
38
|
+
url = "#{DOMAIN}/net4/ITU-T/search/GlobalSearch/Search"
|
39
|
+
data = { json: params.to_json }
|
40
|
+
resp = agent.post url, data.to_json, "Content-Type" => "application/json"
|
41
|
+
@array = hits JSON.parse(resp.body)
|
42
|
+
end
|
43
|
+
|
44
|
+
# @param ref [String] a document ref
|
45
|
+
def request_document(ref) # rubocop:todo Metrics/MethodLength
|
46
|
+
uri = URI::HTTPS.build(
|
47
|
+
host: "raw.githubusercontent.com",
|
48
|
+
path: "/relaton/relaton-data-itu-r/master/data/#{ref}.yaml"
|
49
|
+
)
|
50
|
+
resp = Net::HTTP.get_response(uri)
|
51
|
+
if resp.code == "404"
|
52
|
+
@array = []
|
53
|
+
return
|
54
|
+
end
|
55
|
+
|
56
|
+
hash = YAML.safe_load resp.body
|
57
|
+
item_hash = HashConverter.hash_to_bib(hash)
|
58
|
+
item = ItuBibliographicItem.new **item_hash
|
59
|
+
hit = Hit.new({ url: uri.to_s }, self)
|
60
|
+
hit.fetch = item
|
61
|
+
@array = [hit]
|
62
|
+
end
|
63
|
+
|
51
64
|
# @return [String]
|
52
65
|
def group
|
53
66
|
@group ||= case text
|
@@ -57,10 +70,8 @@ module RelatonItu
|
|
57
70
|
end
|
58
71
|
end
|
59
72
|
|
60
|
-
# rubocop:disable Metrics/MethodLength
|
61
|
-
|
62
73
|
# @return [Hash]
|
63
|
-
def params
|
74
|
+
def params # rubocop:disable Metrics/MethodLength
|
64
75
|
{
|
65
76
|
"Input" => text,
|
66
77
|
"Start" => 0,
|
@@ -107,7 +118,6 @@ module RelatonItu
|
|
107
118
|
"SearchType" => "All",
|
108
119
|
}
|
109
120
|
end
|
110
|
-
# rubocop:enable Metrics/MethodLength
|
111
121
|
|
112
122
|
# @param data [Hash]
|
113
123
|
# @return [Array<RelatonItu::Hit>]
|
data/lib/relaton_itu/version.rb
CHANGED
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.7.
|
4
|
+
version: 1.7.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|