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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 249fe896ec8a77979ca15d6a42da98ad2ac2620cfe8dc0f468cd14277c5a35b0
4
- data.tar.gz: 62415ed835abc49cf00d3048b52556b3f718a4ad0dc531ec2c20572b95305210
3
+ metadata.gz: b5d5c3d1072abc13993b3e87a6fab21f15237273e8b369428adb6ba5694716d1
4
+ data.tar.gz: cc70ec5cd4b1d3f0c959befcda4932edeadafd07fd1cd08d699a6c27979074f1
5
5
  SHA512:
6
- metadata.gz: 65a5bcf91f851cc4ec3139fad83b0c83f143b1bafefe8c9638e34072f7d82f76b77517fedf153fcdf7b63ee903fcd372c64e378edaeb231835f477f004f7e94a
7
- data.tar.gz: 61cdc7df34b24f5d3f3e56b967e9e2b34337bc164b32691747853660cbb6c9e337a6eee058162f97e218da356f4028d7c107b4be4ed7dc10f99253e6985fccd9
6
+ metadata.gz: 635bac7f29a77bc1f4085ea43950cc6687bd5ae04c36d52a9e6a5009375878ddda0ae23a5cc2474377f7ca2b636784c58c7004306429cb942e336789299250f5
7
+ data.tar.gz: c172be34c767d2c2e883b80bc949b0d84f688cfa90b63d6fe751198075c3eb3892f1c4b19277f814dcb1854cf7adf248277bc0ece5ba8d41fa0604609c5d5733
@@ -16,7 +16,7 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '2.7', '2.6', '2.5', '2.4' ]
19
+ ruby: [ '2.7', '2.6', '2.5' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
22
  include:
data/.rubocop.yml CHANGED
@@ -5,6 +5,6 @@
5
5
  inherit_from:
6
6
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
7
7
  AllCops:
8
- TargetRubyVersion: 2.4
8
+ TargetRubyVersion: 2.5
9
9
  Rails:
10
10
  Enabled: false
@@ -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:disable Metrics/AbcSize,Metrics/MethodLength
21
- text = ref.sub /(?<=\.)Imp\s?(?=\d)/, ""
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
- hash = YAML.safe_load resp.body
41
- item_hash = HashConverter.hash_to_bib(hash)
42
- item = ItuBibliographicItem.new **item_hash
43
- hit = Hit.new({ url: url }, self)
44
- hit.fetch = item
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>]
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RelatonItu
2
- VERSION = "1.7.8".freeze
2
+ VERSION = "1.8.2".freeze
3
3
  end
@@ -33,7 +33,7 @@ module RelatonItu
33
33
  ItuGroup.new(
34
34
  type: group[:type],
35
35
  name: group.at("name").text,
36
- acronym: group.at("acronym").text,
36
+ acronym: group.at("acronym")&.text,
37
37
  period: itugroupperiod(group.at("period")),
38
38
  )
39
39
  end
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.4.0")
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.7.0"
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.7.8
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-04-22 00:00:00.000000000 Z
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: '0'
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: '0'
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.7.0
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.7.0
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.4.0
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.0.6
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