relaton-itu 1.7.6 → 1.8.0
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.rb +1 -0
- data/lib/relaton_itu/hash_converter.rb +9 -0
- data/lib/relaton_itu/hit.rb +1 -1
- data/lib/relaton_itu/hit_collection.rb +41 -26
- data/lib/relaton_itu/itu_bibliography.rb +21 -12
- data/lib/relaton_itu/scrapper.rb +50 -56
- data/lib/relaton_itu/version.rb +1 -1
- data/relaton-itu.gemspec +2 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d8d0bba9feeb4b7bc45281e572f44b5db041807f22693fdd64a14427037af52
|
4
|
+
data.tar.gz: e57274331dd84d03f72b27bac3c8f916e0e74bf40487d15d5b98197d9fa0c96a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 474d54e7621972e39a45b1924a8c10c1c65bc2b98d353c922033d32ff7584bea6bba69e7a69b3e453e80d176be0a3fd6a33924e7572eb50ccde51cb63d40b03c
|
7
|
+
data.tar.gz: 606f4346ef69872ba6a03c6ebddee02b0dc644b5cf2a0153929d0175ba4898d4f9b6a68cf6fb1bc3dc719486bbebd37596de512cf5657a8962cd376fd8ac60c3
|
data/lib/relaton_itu.rb
CHANGED
@@ -3,6 +3,15 @@ module RelatonItu
|
|
3
3
|
class << self
|
4
4
|
private
|
5
5
|
|
6
|
+
#
|
7
|
+
# Ovverides superclass's method
|
8
|
+
#
|
9
|
+
# @param item [Hash]
|
10
|
+
# @retirn [RelatonItu::ItuBibliographicItem]
|
11
|
+
def bib_item(item)
|
12
|
+
ItuBibliographicItem.new(**item)
|
13
|
+
end
|
14
|
+
|
6
15
|
def editorialgroup_hash_to_bib(ret)
|
7
16
|
eg = ret[:editorialgroup]
|
8
17
|
return unless eg
|
data/lib/relaton_itu/hit.rb
CHANGED
@@ -12,50 +12,66 @@ module RelatonItu
|
|
12
12
|
# @return [TrueClass, FalseClass]
|
13
13
|
attr_reader :gi_imp
|
14
14
|
|
15
|
+
# @return [Mechanize]
|
16
|
+
attr_reader :agent
|
17
|
+
|
15
18
|
# @param ref [String]
|
16
19
|
# @param year [String]
|
17
|
-
def initialize(ref, year = nil) # rubocop:
|
20
|
+
def initialize(ref, year = nil) # rubocop:todo Metrics/MethodLength
|
18
21
|
text = ref.sub /(?<=\.)Imp\s?(?=\d)/, ""
|
19
22
|
super text, year
|
23
|
+
@agent = Mechanize.new
|
24
|
+
agent.user_agent_alias = "Mac Safari"
|
20
25
|
@gi_imp = /\.Imp\d/.match?(ref)
|
21
|
-
if ref.match? /^(ITU-T|ITU-R\sRR)/
|
22
|
-
uri = URI "#{DOMAIN}/net4/ITU-T/search/GlobalSearch/Search"
|
23
|
-
data = { json: params.to_json }
|
24
|
-
resp = Net::HTTP.post(uri, data.to_json,
|
25
|
-
"Content-Type" => "application/json")
|
26
|
-
@array = hits JSON.parse(resp.body)
|
27
|
-
elsif ref.match? /^ITU-R/
|
28
|
-
rf = ref.sub(/^ITU-R\s/, "").upcase
|
29
|
-
url = "https://raw.githubusercontent.com/relaton/relaton-data-itu-r/master/data/#{rf}.yaml"
|
30
|
-
resp = Net::HTTP.get_response(URI(url))
|
31
|
-
if resp.code == "404"
|
32
|
-
@array = []
|
33
|
-
return
|
34
|
-
end
|
35
26
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@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)
|
42
32
|
end
|
43
33
|
end
|
44
34
|
|
45
35
|
private
|
46
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
|
+
|
47
64
|
# @return [String]
|
48
65
|
def group
|
49
66
|
@group ||= case text
|
50
|
-
when %r{OB|Operational Bulletin}, %r{^ITU-R\sRR}
|
67
|
+
when %r{OB|Operational Bulletin}, %r{^ITU-R\sRR}
|
68
|
+
"Publications"
|
51
69
|
when %r{^ITU-T} then "Recommendations"
|
52
70
|
end
|
53
71
|
end
|
54
72
|
|
55
|
-
# rubocop:disable Metrics/MethodLength
|
56
|
-
|
57
73
|
# @return [Hash]
|
58
|
-
def params
|
74
|
+
def params # rubocop:disable Metrics/MethodLength
|
59
75
|
{
|
60
76
|
"Input" => text,
|
61
77
|
"Start" => 0,
|
@@ -102,7 +118,6 @@ module RelatonItu
|
|
102
118
|
"SearchType" => "All",
|
103
119
|
}
|
104
120
|
end
|
105
|
-
# rubocop:enable Metrics/MethodLength
|
106
121
|
|
107
122
|
# @param data [Hash]
|
108
123
|
# @return [Array<RelatonItu::Hit>]
|
@@ -28,13 +28,14 @@ module RelatonItu
|
|
28
28
|
HitCollection.new text, year
|
29
29
|
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
|
30
30
|
EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
31
|
-
Net::ProtocolError,
|
32
|
-
raise RelatonBib::RequestError,
|
31
|
+
Net::ProtocolError, URI::InvalidURIError => e
|
32
|
+
raise RelatonBib::RequestError, e.message
|
33
33
|
end
|
34
34
|
|
35
35
|
# @param code [String] the ISO standard Code to look up (e..g "ISO 9000")
|
36
36
|
# @param year [String] the year the standard was published (optional)
|
37
|
-
# @param opts [Hash] options; restricted to :all_parts if all-parts
|
37
|
+
# @param opts [Hash] options; restricted to :all_parts if all-parts
|
38
|
+
# reference is required
|
38
39
|
# @return [String] Relaton XML serialisation of reference
|
39
40
|
def get(code, year = nil, opts = {}) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
40
41
|
if year.nil?
|
@@ -61,12 +62,12 @@ module RelatonItu
|
|
61
62
|
warn "[relaton-itu] WARNING: no match found online for #{id}. "\
|
62
63
|
"The code must be exactly like it is on the standards website."
|
63
64
|
unless missed_years.empty?
|
64
|
-
warn "[relaton-itu] (There was no match for #{year}, though there
|
65
|
-
"found for #{missed_years.join(', ')}.)"
|
65
|
+
warn "[relaton-itu] (There was no match for #{year}, though there "\
|
66
|
+
"were matches found for #{missed_years.join(', ')}.)"
|
66
67
|
end
|
67
68
|
if /\d-\d/.match? code
|
68
|
-
warn "[relaton-itu] The provided document part may not exist, or
|
69
|
-
"may no longer be published in parts."
|
69
|
+
warn "[relaton-itu] The provided document part may not exist, or "\
|
70
|
+
"the document may no longer be published in parts."
|
70
71
|
else
|
71
72
|
warn "[relaton-itu] If you wanted to cite all document parts for the reference, "\
|
72
73
|
"use \"#{code} (all parts)\".\nIf the document is not a standard, "\
|
@@ -77,10 +78,11 @@ module RelatonItu
|
|
77
78
|
|
78
79
|
def search_filter(code, year) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
79
80
|
%r{
|
80
|
-
^(?<pref1>ITU)?(-(?<type1>\w))?\s?(?<code1>[^\s\/]+(?:\/\w\.\d+)?)
|
81
|
+
^(?<pref1>ITU)?(-(?<type1>\w))?\s?(?<code1>[^\s\/]+(?:\/\w[\.\d]+)?)
|
82
|
+
(\s\(?(?<ver1>v\d+)\)?)?
|
81
83
|
(\s\(((?<month1>\d{2})\/)?(?<year1>\d{4})\))?
|
82
84
|
(\s-\s(?<buldate1>\d{2}\.\w{1,4}\.\d{4}))?
|
83
|
-
(
|
85
|
+
(\s(?<corr1>(Amd|Cor|Amendment|Corrigendum)\.?\s?\d+))?
|
84
86
|
(\s\(((?<cormonth1>\d{2})\/)?(?<coryear1>\d{4})\))?
|
85
87
|
}x =~ code
|
86
88
|
year ||= year1
|
@@ -89,21 +91,27 @@ module RelatonItu
|
|
89
91
|
warn "[relaton-itu] (\"#{code}\") fetching..."
|
90
92
|
result = search(code)
|
91
93
|
code1.sub! /(?<=\.)Imp(?=\d)/, "" if result.gi_imp
|
94
|
+
if corr1
|
95
|
+
corr1.sub!(/[\.\s]+/, " ").sub!("Amendment", "Amd")
|
96
|
+
corr1.sub!("Corrigendum", "Corr")
|
97
|
+
end
|
92
98
|
result.select do |i|
|
93
99
|
next true unless i.hit[:code]
|
94
100
|
|
95
101
|
%r{
|
96
102
|
^(?<pref2>ITU)?(-(?<type2>\w))?\s?(?<code2>[\S]+)
|
103
|
+
(\s\(?(?<ver2>v\d+)\)?)?
|
97
104
|
(\s\(((?<month2>\d{2})\/)?(?<year2>\d{4})\))?
|
98
105
|
(\s(?<corr2>(Amd|Cor)\.\s?\d+))?
|
99
106
|
(\s\(((?<cormonth2>\d{2})\/)?(?<coryear2>\d{4})\))?
|
100
107
|
}x =~ i.hit[:code]
|
101
108
|
/:[^\(]+\((?<buldate2>\d{2}\.\w{1,4}\.\d{4})\)/ =~ i.hit[:title]
|
102
109
|
corr2&.sub! /\.\s?/, " "
|
103
|
-
pref1 == pref2 && (!type1 || type1 == type2) && code1
|
110
|
+
pref1 == pref2 && (!type1 || type1 == type2) && code2.include?(code1) &&
|
104
111
|
(!year || year == year2) && (!month1 || month1 == month2) &&
|
105
112
|
corr1 == corr2 && (!coryear1 || coryear1 == coryear2) &&
|
106
|
-
buldate1 == buldate2 && (!cormonth1 || cormonth1 == cormonth2)
|
113
|
+
buldate1 == buldate2 && (!cormonth1 || cormonth1 == cormonth2) &&
|
114
|
+
(!ver1 || ver1 == ver2)
|
107
115
|
end
|
108
116
|
end
|
109
117
|
|
@@ -116,7 +124,8 @@ module RelatonItu
|
|
116
124
|
def isobib_results_filter(result, year)
|
117
125
|
missed_years = []
|
118
126
|
result.each do |r|
|
119
|
-
|
127
|
+
/\((\d{2}\/)?(?<pyear>\d{4})\)/ =~ r.hit[:code]
|
128
|
+
if !year || year == pyear
|
120
129
|
ret = r.fetch
|
121
130
|
return { ret: ret } if ret
|
122
131
|
end
|
data/lib/relaton_itu/scrapper.rb
CHANGED
@@ -24,20 +24,18 @@ module RelatonItu
|
|
24
24
|
}.freeze
|
25
25
|
|
26
26
|
class << self
|
27
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
28
|
-
|
29
27
|
# Parse page.
|
30
|
-
# @param
|
28
|
+
# @param hit [RelatonItu::Hit]
|
31
29
|
# @return [Hash]
|
32
|
-
def parse_page(
|
33
|
-
|
34
|
-
return unless doc
|
30
|
+
def parse_page(hit, imp = false) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
31
|
+
doc = get_page hit
|
32
|
+
return unless doc.code == "200"
|
35
33
|
|
36
34
|
if imp
|
37
35
|
a = doc.at "//span[contains(@id, 'tab_ig_uc_rec')]/a"
|
38
36
|
return unless a
|
39
37
|
|
40
|
-
|
38
|
+
doc = get_page hit, a[:href].to_s
|
41
39
|
end
|
42
40
|
|
43
41
|
# Fetch edition.
|
@@ -46,36 +44,37 @@ module RelatonItu
|
|
46
44
|
ItuBibliographicItem.new(
|
47
45
|
fetched: Date.today.to_s,
|
48
46
|
type: "standard",
|
49
|
-
docid: fetch_docid(doc,
|
47
|
+
docid: fetch_docid(doc, hit.hit[:title]),
|
50
48
|
edition: edition,
|
51
49
|
language: ["en"],
|
52
50
|
script: ["Latn"],
|
53
51
|
title: fetch_titles(doc),
|
54
|
-
doctype:
|
52
|
+
doctype: hit.hit[:type],
|
55
53
|
docstatus: fetch_status(doc),
|
56
54
|
ics: [], # fetch_ics(doc),
|
57
55
|
date: fetch_dates(doc),
|
58
|
-
contributor: fetch_contributors(
|
59
|
-
editorialgroup: fetch_workgroup(
|
60
|
-
abstract: fetch_abstract(doc),
|
61
|
-
copyright: fetch_copyright(
|
62
|
-
link: fetch_link(doc
|
56
|
+
contributor: fetch_contributors(hit.hit[:code]),
|
57
|
+
editorialgroup: fetch_workgroup(hit.hit[:code], doc),
|
58
|
+
abstract: fetch_abstract(doc, hit),
|
59
|
+
copyright: fetch_copyright(hit.hit[:code], doc),
|
60
|
+
link: fetch_link(doc),
|
63
61
|
relation: fetch_relations(doc),
|
64
62
|
place: ["Geneva"]
|
65
63
|
)
|
66
64
|
end
|
67
|
-
# rubocop:enable Metrics/AbcSize
|
68
65
|
|
69
66
|
private
|
70
67
|
|
71
68
|
# Fetch abstracts.
|
72
|
-
# @param doc [
|
73
|
-
# @
|
74
|
-
|
75
|
-
|
69
|
+
# @param doc [Mechanize::Page]
|
70
|
+
# @param hit [RelatonItu::Hit]
|
71
|
+
# @return [Array<Hash>]
|
72
|
+
def fetch_abstract(doc, hit) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
73
|
+
abstract_url = doc.at '//table/tr[td/span[.="In force"]]/td/span[contains(@id, "lbl_dms")]/div'
|
76
74
|
content = if abstract_url
|
77
75
|
url = abstract_url[:onclick].match(/https?[^']+/).to_s
|
78
|
-
|
76
|
+
rsp = hit.hit_collection.agent.get url
|
77
|
+
d = Nokogiri::HTML rsp.body.encode(undef: :replace, replace: "")
|
79
78
|
d.css("p.MsoNormal").text.gsub(/\r\n/, "").squeeze(" ").gsub(/\u00a0/, "")
|
80
79
|
elsif a = doc.at('//table/tr/td/span[contains(@class, "observation")]/text()')
|
81
80
|
a.text.strip
|
@@ -90,27 +89,20 @@ module RelatonItu
|
|
90
89
|
end
|
91
90
|
|
92
91
|
# Get page.
|
93
|
-
# @param
|
92
|
+
# @param hit [RelatonItu::Hit]
|
93
|
+
# @param url [String, nil]
|
94
94
|
# @return [Array<String, Nokogiri::HTML::Document>]
|
95
|
-
def get_page(url)
|
96
|
-
uri =
|
97
|
-
|
98
|
-
until resp.code == "200"
|
99
|
-
return if resp["location"] == "/en/publications/pages/notfound.aspx"
|
100
|
-
|
101
|
-
uri = URI resp["location"] if resp.code.match? /^30/
|
102
|
-
resp = Net::HTTP.get_response(uri)
|
103
|
-
end
|
104
|
-
[uri.to_s, Nokogiri::HTML(resp.body)]
|
95
|
+
def get_page(hit, url = nil)
|
96
|
+
uri = url || hit.hit[:url]
|
97
|
+
hit.hit_collection.agent.get uri
|
105
98
|
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
|
106
99
|
EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
107
100
|
Net::ProtocolError, OpenSSL::SSL::SSLError
|
108
|
-
raise RelatonBib::RequestError, "Could not access #{
|
101
|
+
raise RelatonBib::RequestError, "Could not access #{uri}"
|
109
102
|
end
|
110
|
-
# rubocop:enable Metrics/MethodLength
|
111
103
|
|
112
104
|
# Fetch docid.
|
113
|
-
# @param doc [
|
105
|
+
# @param doc [Mechanize::Page]
|
114
106
|
# @param title [String]
|
115
107
|
# @return [Hash]
|
116
108
|
def fetch_docid(doc, title)
|
@@ -123,6 +115,8 @@ module RelatonItu
|
|
123
115
|
docids
|
124
116
|
end
|
125
117
|
|
118
|
+
# @param text [String]
|
119
|
+
# @return [RelatonBib::DocumentIdentifier]
|
126
120
|
def createdocid(text) # rubocop:disable Metrics/MethodLength
|
127
121
|
%r{
|
128
122
|
^(?<code>((ITU-\w|ISO\/IEC)\s)?[^\(:]+)
|
@@ -132,7 +126,7 @@ module RelatonItu
|
|
132
126
|
# (\s\(((?<_cormonth>\d{2})\/)?(?<_coryear>\d{4})\))?
|
133
127
|
}x =~ text.squeeze(" ")
|
134
128
|
corr&.sub! /\.\s?/, " "
|
135
|
-
id = [code.sub(/[[:space:]]$/, ""), corr].compact.join "
|
129
|
+
id = [code.sub(/[[:space:]]$/, ""), corr].compact.join " "
|
136
130
|
id += " - #{buldate}" if buldate
|
137
131
|
type = id.match(%r{^\w+}).to_s
|
138
132
|
type = "ITU" if type == "G"
|
@@ -140,7 +134,7 @@ module RelatonItu
|
|
140
134
|
end
|
141
135
|
|
142
136
|
# Fetch status.
|
143
|
-
# @param doc [
|
137
|
+
# @param doc [Mechanize::Page]
|
144
138
|
# @return [RelatonBib::DocumentStatus, NilClass]
|
145
139
|
def fetch_status(doc)
|
146
140
|
s = doc.at("//table/tr/td/span[contains(@id, 'Label7')]",
|
@@ -153,7 +147,7 @@ module RelatonItu
|
|
153
147
|
|
154
148
|
# Fetch workgroup.
|
155
149
|
# @param code [String]
|
156
|
-
# @param doc [
|
150
|
+
# @param doc [Mechanize::Page]
|
157
151
|
# @return [RelatonItu::EditorialGroup, NilClass]
|
158
152
|
def fetch_workgroup(code, doc)
|
159
153
|
wg = doc.at('//table/tr/td/span[contains(@id, "Label8")]/a')
|
@@ -161,8 +155,7 @@ module RelatonItu
|
|
161
155
|
|
162
156
|
group = wg && itugroup(wg.text)
|
163
157
|
EditorialGroup.new(
|
164
|
-
bureau: code.match(/(?<=-)./).to_s,
|
165
|
-
group: group
|
158
|
+
bureau: code.match(/(?<=-)./).to_s, group: group
|
166
159
|
)
|
167
160
|
end
|
168
161
|
|
@@ -182,24 +175,24 @@ module RelatonItu
|
|
182
175
|
ItuGroup.new name: name, type: type, acronym: acronym
|
183
176
|
end
|
184
177
|
|
185
|
-
# rubocop:disable Metrics/MethodLength
|
186
|
-
|
187
178
|
# Fetch relations.
|
188
|
-
# @param doc [
|
179
|
+
# @param doc [Mechanize::Page]
|
189
180
|
# @return [Array<Hash>]
|
190
181
|
def fetch_relations(doc)
|
191
|
-
doc.xpath('//div[contains(@id, "tab_sup")]//table/tr[position()>2]')
|
182
|
+
doc.xpath('//div[contains(@id, "tab_sup")]//table/tr[position()>2]')
|
183
|
+
.map do |r|
|
192
184
|
ref = r.at('./td/span[contains(@id, "title_e")]/nobr/a')
|
193
|
-
fref = RelatonBib::FormattedRef.new(content: ref.text, language: "en",
|
194
|
-
|
185
|
+
fref = RelatonBib::FormattedRef.new(content: ref.text, language: "en",
|
186
|
+
script: "Latn")
|
187
|
+
bibitem = ItuBibliographicItem.new(formattedref: fref,
|
188
|
+
type: "standard")
|
195
189
|
{ type: "complements", bibitem: bibitem }
|
196
190
|
end
|
197
191
|
end
|
198
|
-
# rubocop:enable Metrics/MethodLength
|
199
192
|
|
200
193
|
# Fetch titles.
|
201
|
-
# @param doc [
|
202
|
-
# @return [
|
194
|
+
# @param doc [Mechanize::Page]
|
195
|
+
# @return [RelatonBib::TypedTitleStringCollection]
|
203
196
|
def fetch_titles(doc)
|
204
197
|
t = doc.at("//td[@class='title']|//div/table[1]/tr[4]/td/strong")
|
205
198
|
return [] unless t
|
@@ -208,7 +201,7 @@ module RelatonItu
|
|
208
201
|
end
|
209
202
|
|
210
203
|
# Fetch dates
|
211
|
-
# @param doc [
|
204
|
+
# @param doc [Mechanize::Page]
|
212
205
|
# @return [Array<Hash>]
|
213
206
|
def fetch_dates(doc) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
214
207
|
dates = []
|
@@ -224,7 +217,7 @@ module RelatonItu
|
|
224
217
|
end
|
225
218
|
|
226
219
|
# Scrape Operational Bulletin date.
|
227
|
-
# @param doc [
|
220
|
+
# @param doc [Mechanize::Page]
|
228
221
|
# @return [String]
|
229
222
|
def ob_date(doc)
|
230
223
|
pdate = doc.at('//table/tbody/tr/td[contains(text(), "Year:")]')
|
@@ -246,7 +239,7 @@ module RelatonItu
|
|
246
239
|
end
|
247
240
|
|
248
241
|
# Fetch contributors
|
249
|
-
# @param doc [
|
242
|
+
# @param doc [Mechanize::Page]
|
250
243
|
# @return [Array<Hash>]
|
251
244
|
def fetch_contributors(code)
|
252
245
|
return [] unless code
|
@@ -262,11 +255,10 @@ module RelatonItu
|
|
262
255
|
end
|
263
256
|
|
264
257
|
# Fetch links.
|
265
|
-
# @param doc [
|
266
|
-
# @param url [String]
|
258
|
+
# @param doc [Mechanize::Page]
|
267
259
|
# @return [Array<Hash>]
|
268
|
-
def fetch_link(doc
|
269
|
-
links = [{ type: "src", content:
|
260
|
+
def fetch_link(doc)
|
261
|
+
links = [{ type: "src", content: doc.uri.to_s }]
|
270
262
|
obp_elm = doc.at(
|
271
263
|
'//a[@title="Persistent link to download the PDF file"]',
|
272
264
|
"//font[contains(.,'PDF')]/../.."
|
@@ -277,6 +269,8 @@ module RelatonItu
|
|
277
269
|
links
|
278
270
|
end
|
279
271
|
|
272
|
+
# @param type [String]
|
273
|
+
# @param elm [Nokogiri::XML::Element]
|
280
274
|
def typed_link(type, elm)
|
281
275
|
{
|
282
276
|
type: type,
|
@@ -286,7 +280,7 @@ module RelatonItu
|
|
286
280
|
|
287
281
|
# Fetch copyright.
|
288
282
|
# @param code [String]
|
289
|
-
# @param doc [
|
283
|
+
# @param doc [Mechanize::Page]
|
290
284
|
# @return [Array<Hash>]
|
291
285
|
def fetch_copyright(code, doc)
|
292
286
|
abbreviation = code.match(/^[^-]+/).to_s
|
data/lib/relaton_itu/version.rb
CHANGED
data/relaton-itu.gemspec
CHANGED
@@ -37,5 +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 "
|
40
|
+
spec.add_dependency "mechanize", "~> 2.7.0"
|
41
|
+
spec.add_dependency "relaton-bib", "~> 1.8.0"
|
41
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.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: 2021-
|
11
|
+
date: 2021-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -122,20 +122,34 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: mechanize
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 2.7.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 2.7.0
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: relaton-bib
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - "~>"
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.
|
145
|
+
version: 1.8.0
|
132
146
|
type: :runtime
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.
|
152
|
+
version: 1.8.0
|
139
153
|
description: 'RelatonItu: retrieve ITU Standards for bibliographic use using the BibliographicItem
|
140
154
|
model'
|
141
155
|
email:
|
@@ -193,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
207
|
- !ruby/object:Gem::Version
|
194
208
|
version: '0'
|
195
209
|
requirements: []
|
196
|
-
rubygems_version: 3.
|
210
|
+
rubygems_version: 3.2.3
|
197
211
|
signing_key:
|
198
212
|
specification_version: 4
|
199
213
|
summary: 'RelatonItu: retrieve ITU Standards for bibliographic use using the BibliographicItem
|