relaton-iso 1.0.2 → 1.2.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/lib/relaton_iso/scrapper.rb +48 -20
- data/lib/relaton_iso/version.rb +1 -1
- data/relaton_iso.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 695d73fc8a0ec542936778c62629e23278859d137bc6ee9b84e6d20336d832da
|
4
|
+
data.tar.gz: 1c529be373cf17e122e7d98cb910e83474916bb9d2b9d38a612c8a5f3d41aeb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecdd90086da2528bf41a05e499da97f10409a69004e7d45786bffcabce715bc5f3261f25a79212b56f9171cbd66ef56a82b382a3c26750f0fed8a2d1142ba922
|
7
|
+
data.tar.gz: d23cdc8f56ec945e945a8b5a5cede2f84e9f68c0419f6e9fc16403988d5f8fd4917656a327ed921f216783829ec2fd91073a2f59adc982cfe249a73f2bc516c2
|
data/lib/relaton_iso/scrapper.rb
CHANGED
@@ -25,6 +25,30 @@ module RelatonIso
|
|
25
25
|
"Guide" => "guide",
|
26
26
|
}.freeze
|
27
27
|
|
28
|
+
STGABBR = {
|
29
|
+
"00" => "NWIP",
|
30
|
+
"10" => "AWI",
|
31
|
+
"20" => "WD",
|
32
|
+
"30" => "CD",
|
33
|
+
"40" => "DIS",
|
34
|
+
"50" => "FDIS",
|
35
|
+
"60" => { "00" => "PRF", "60" => "FINAL" },
|
36
|
+
}.freeze
|
37
|
+
|
38
|
+
PUBLISHERS = {
|
39
|
+
"IEC" => { name: "International Electrotechnical Commission",
|
40
|
+
url: "www.iec.ch" },
|
41
|
+
"ISO" => { name: "International Organization for Standardization",
|
42
|
+
url: "www.iso.org" },
|
43
|
+
"IEEE" => { name: "Institute of Electrical and Electronics Engineers",
|
44
|
+
url: "www.ieee.org" },
|
45
|
+
"SAE" => { name: "SAE International", url: "www.sae.org" },
|
46
|
+
"CIE" => { name: " International Commission on Illumination",
|
47
|
+
url: "cie.co.at" },
|
48
|
+
"ASME" => { name: "American Society of Mechanical Engineers",
|
49
|
+
url: "www.asme.org" },
|
50
|
+
}.freeze
|
51
|
+
|
28
52
|
class << self
|
29
53
|
# Parse page.
|
30
54
|
# @param hit_data [Hash]
|
@@ -80,7 +104,7 @@ module RelatonIso
|
|
80
104
|
d = l[:path] ? get_page(l[:path])[0] : doc
|
81
105
|
unless d.at("//h5[@class='help-block'][.='недоступно на русском языке']")
|
82
106
|
s << l
|
83
|
-
titles
|
107
|
+
titles += fetch_title(d, l[:lang])
|
84
108
|
|
85
109
|
# Fetch abstracts.
|
86
110
|
abstract_content = d.css("div[itemprop='description'] p").text
|
@@ -176,10 +200,17 @@ module RelatonIso
|
|
176
200
|
# @param status [String]
|
177
201
|
# @return [Hash]
|
178
202
|
def fetch_status(doc)
|
179
|
-
|
180
|
-
|
203
|
+
stg, substg = doc.css(
|
204
|
+
"li.dropdown.active span.stage-code > strong",
|
205
|
+
).text.split "."
|
206
|
+
RelatonBib::DocumentStatus.new(stage: stg, substage: substg)
|
181
207
|
end
|
182
208
|
|
209
|
+
# def stage(stg, substg)
|
210
|
+
# abbr = STGABBR[stg].is_a?(Hash) ? STGABBR[stg][substg] : STGABBR[stg]
|
211
|
+
# RelatonBib::DocumentStatus::Stage.new value: stg, abbreviation: abbr
|
212
|
+
# end
|
213
|
+
|
183
214
|
# Fetch workgroup.
|
184
215
|
# @param doc [Nokogiri::HTML::Document]
|
185
216
|
# @return [Hash]
|
@@ -256,12 +287,14 @@ module RelatonIso
|
|
256
287
|
# Fetch titles.
|
257
288
|
# @param doc [Nokogiri::HTML::Document]
|
258
289
|
# @param lang [String]
|
259
|
-
# @return [
|
290
|
+
# @return [Array<RelatonBib::TypedTitleString>]
|
260
291
|
def fetch_title(doc, lang)
|
261
292
|
content = doc.at(
|
262
|
-
"//nav[contains(@class,'
|
263
|
-
)&.text
|
264
|
-
|
293
|
+
"//nav[contains(@class,'heading-condensed')]/h2 | //nav[contains(@class,'heading-condensed')]/h3",
|
294
|
+
)&.text&.gsub(/\u2014/, "-")
|
295
|
+
return [] unless content
|
296
|
+
|
297
|
+
RelatonBib::TypedTitleString.from_string content, lang, script(lang)
|
265
298
|
end
|
266
299
|
|
267
300
|
# Return ISO script code.
|
@@ -303,17 +336,12 @@ module RelatonIso
|
|
303
336
|
end
|
304
337
|
|
305
338
|
def fetch_contributors(ref)
|
306
|
-
ref.sub(/\s.*/, "").split("/").
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
name = "International Organization for Standardization"
|
313
|
-
url = "www.iso.org"
|
314
|
-
end
|
315
|
-
{ entity: { name: name, url: url, abbreviation: abbrev },
|
316
|
-
role: [type: "publisher"] }
|
339
|
+
ref.sub(/\s.*/, "").split("/").reduce([]) do |mem, abbrev|
|
340
|
+
publisher = PUBLISHERS[abbrev]
|
341
|
+
next mem unless publisher
|
342
|
+
|
343
|
+
publisher[:abbreviation] = abbrev
|
344
|
+
mem << { entity: publisher, role: [type: "publisher"] }
|
317
345
|
end
|
318
346
|
end
|
319
347
|
# rubocop:enable Metrics/MethodLength
|
@@ -347,14 +375,14 @@ module RelatonIso
|
|
347
375
|
# Fetch copyright.
|
348
376
|
# @param ref [String]
|
349
377
|
# @param doc [Nokogiri::HTML::Document]
|
350
|
-
# @return [Hash]
|
378
|
+
# @return [Array<Hash>]
|
351
379
|
def fetch_copyright(ref, doc)
|
352
380
|
owner_name = ref.match(/.*?(?=\s)/).to_s
|
353
381
|
from = ref.match(/(?<=:)\d{4}/).to_s
|
354
382
|
if from.empty?
|
355
383
|
from = doc.xpath("//span[@itemprop='releaseDate']").text.match(/\d{4}/).to_s
|
356
384
|
end
|
357
|
-
{ owner: { name: owner_name }, from: from }
|
385
|
+
[{ owner: [{ name: owner_name }], from: from }]
|
358
386
|
end
|
359
387
|
end
|
360
388
|
end
|
data/lib/relaton_iso/version.rb
CHANGED
data/relaton_iso.gemspec
CHANGED
@@ -37,6 +37,6 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_development_dependency "vcr"
|
38
38
|
spec.add_development_dependency "webmock"
|
39
39
|
|
40
|
-
spec.add_dependency "relaton-iec", "~> 1.
|
41
|
-
spec.add_dependency "relaton-iso-bib", "~> 1.
|
40
|
+
spec.add_dependency "relaton-iec", "~> 1.2.0"
|
41
|
+
spec.add_dependency "relaton-iso-bib", "~> 1.2.0"
|
42
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.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: 2020-
|
11
|
+
date: 2020-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -156,28 +156,28 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.
|
159
|
+
version: 1.2.0
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 1.
|
166
|
+
version: 1.2.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: relaton-iso-bib
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1.
|
173
|
+
version: 1.2.0
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 1.
|
180
|
+
version: 1.2.0
|
181
181
|
description: 'RelatonIso: retrieve ISO Standards for bibliographic use using the IsoBibliographicItem
|
182
182
|
model'
|
183
183
|
email:
|