relaton-itu 1.7.8 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -1
- data/.rubocop.yml +1 -1
- data/lib/relaton_itu/hit_collection.rb +35 -25
- data/lib/relaton_itu/scrapper.rb +1 -1
- data/lib/relaton_itu/version.rb +1 -1
- data/lib/relaton_itu/xml_parser.rb +1 -1
- data/relaton-itu.gemspec +3 -3
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5d5c3d1072abc13993b3e87a6fab21f15237273e8b369428adb6ba5694716d1
|
4
|
+
data.tar.gz: cc70ec5cd4b1d3f0c959befcda4932edeadafd07fd1cd08d699a6c27979074f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 635bac7f29a77bc1f4085ea43950cc6687bd5ae04c36d52a9e6a5009375878ddda0ae23a5cc2474377f7ca2b636784c58c7004306429cb942e336789299250f5
|
7
|
+
data.tar.gz: c172be34c767d2c2e883b80bc949b0d84f688cfa90b63d6fe751198075c3eb3892f1c4b19277f814dcb1854cf7adf248277bc0ece5ba8d41fa0604609c5d5733
|
data/.github/workflows/rake.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -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:
|
21
|
-
text = ref.sub
|
20
|
+
def initialize(ref, year = nil) # rubocop:todo Metrics/MethodLength
|
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/
|
31
|
+
request_document(ref)
|
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.gsub(/[\s.]/, '_')}.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/scrapper.rb
CHANGED
@@ -70,7 +70,7 @@ module RelatonItu
|
|
70
70
|
# @param hit [RelatonItu::Hit]
|
71
71
|
# @return [Array<Hash>]
|
72
72
|
def fetch_abstract(doc, hit) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
73
|
-
abstract_url = doc.at '//table/tr/td/span[contains(@id, "lbl_dms")]/div'
|
73
|
+
abstract_url = doc.at '//table/tr[td/span[.="In force"]]/td/span[contains(@id, "lbl_dms")]/div'
|
74
74
|
content = if abstract_url
|
75
75
|
url = abstract_url[:onclick].match(/https?[^']+/).to_s
|
76
76
|
rsp = hit.hit_collection.agent.get url
|
data/lib/relaton_itu/version.rb
CHANGED
data/relaton-itu.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.bindir = "exe"
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
27
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
28
28
|
|
29
29
|
# spec.add_development_dependency "debase"
|
30
30
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
@@ -37,6 +37,6 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_development_dependency "vcr", "~> 5.0.0"
|
38
38
|
spec.add_development_dependency "webmock"
|
39
39
|
|
40
|
-
spec.add_dependency "mechanize"
|
41
|
-
spec.add_dependency "relaton-bib", "~> 1.
|
40
|
+
spec.add_dependency "mechanize", "~> 2.8.0"
|
41
|
+
spec.add_dependency "relaton-bib", "~> 1.8.0"
|
42
42
|
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.8.2
|
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-
|
11
|
+
date: 2021-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -126,30 +126,30 @@ dependencies:
|
|
126
126
|
name: mechanize
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - "
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 2.8.0
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - "
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: 2.8.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: relaton-bib
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.
|
145
|
+
version: 1.8.0
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.
|
152
|
+
version: 1.8.0
|
153
153
|
description: 'RelatonItu: retrieve ITU Standards for bibliographic use using the BibliographicItem
|
154
154
|
model'
|
155
155
|
email:
|
@@ -200,14 +200,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
200
|
requirements:
|
201
201
|
- - ">="
|
202
202
|
- !ruby/object:Gem::Version
|
203
|
-
version: 2.
|
203
|
+
version: 2.5.0
|
204
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - ">="
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
210
|
+
rubygems_version: 3.2.3
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: 'RelatonItu: retrieve ITU Standards for bibliographic use using the BibliographicItem
|