relaton-iso 1.0.3 → 1.2.1
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/.rubocop.yml +2 -2
- data/lib/relaton_iso/iso_bibliography.rb +3 -2
- data/lib/relaton_iso/scrapper.rb +30 -19
- data/lib/relaton_iso/version.rb +1 -1
- data/relaton_iso.gemspec +2 -2
- 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: 9e3b6cecb41e4d2c51cecad3b906e25fc1202ff2f9d69261d23a199c9084f0d8
|
4
|
+
data.tar.gz: 8a3f4c0a7857ef1c8668b1c1624f22573817b333a6bc674a77d729f2034098d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 379e71ee50015f6ee0d012f3f157c1a355d5a69a670f3ed2a6dc7be6dafd86b4376808c8263f15c8deea3c85617ed7368dee72770c5d13e3f6e8948a1bfd9cea
|
7
|
+
data.tar.gz: d66f8ede9750f437adbc36682c4ae591ea800f887c8df54d36ea48f57ee1a09cd98e6e4b1b22dfc8653afdef2a29d7cf678782d41600110fca1e59e5074c77cc
|
data/.rubocop.yml
CHANGED
@@ -38,9 +38,10 @@ module RelatonIso
|
|
38
38
|
|
39
39
|
if year.nil?
|
40
40
|
/^(?<code1>[^\s]+(\s\w+)?\s[\d-]+)(:(?<year1>\d{4}))?(?<code2>\s\w+)?/ =~ code
|
41
|
+
/:(?<year2>\d{4})/ =~ corr
|
41
42
|
unless code1.nil?
|
42
43
|
code = code1 + code2.to_s
|
43
|
-
year = year1
|
44
|
+
year = year2 || year1
|
44
45
|
end
|
45
46
|
end
|
46
47
|
opts[:all_parts] ||= code !~ %r{^[^\s]+\s\d+-\d+} && opts[:all_parts].nil? && code2.nil?
|
@@ -145,7 +146,7 @@ module RelatonIso
|
|
145
146
|
def isobib_results_filter(result, year, opts)
|
146
147
|
missed_years = []
|
147
148
|
hits = result.reduce!([]) do |hts, h|
|
148
|
-
if !year || %r{:(?<iyear>\d{4})} =~ h.hit["docRef"] && iyear == year
|
149
|
+
if !year || %r{:(?<iyear>\d{4})(?!.*:\d{4})} =~ h.hit["docRef"] && iyear == year
|
149
150
|
hts << h
|
150
151
|
else
|
151
152
|
missed_years << iyear
|
data/lib/relaton_iso/scrapper.rb
CHANGED
@@ -33,7 +33,21 @@ module RelatonIso
|
|
33
33
|
"40" => "DIS",
|
34
34
|
"50" => "FDIS",
|
35
35
|
"60" => { "00" => "PRF", "60" => "FINAL" },
|
36
|
-
}
|
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
|
37
51
|
|
38
52
|
class << self
|
39
53
|
# Parse page.
|
@@ -90,7 +104,7 @@ module RelatonIso
|
|
90
104
|
d = l[:path] ? get_page(l[:path])[0] : doc
|
91
105
|
unless d.at("//h5[@class='help-block'][.='недоступно на русском языке']")
|
92
106
|
s << l
|
93
|
-
titles
|
107
|
+
titles += fetch_title(d, l[:lang])
|
94
108
|
|
95
109
|
# Fetch abstracts.
|
96
110
|
abstract_content = d.css("div[itemprop='description'] p").text
|
@@ -273,12 +287,14 @@ module RelatonIso
|
|
273
287
|
# Fetch titles.
|
274
288
|
# @param doc [Nokogiri::HTML::Document]
|
275
289
|
# @param lang [String]
|
276
|
-
# @return [
|
290
|
+
# @return [Array<RelatonBib::TypedTitleString>]
|
277
291
|
def fetch_title(doc, lang)
|
278
292
|
content = doc.at(
|
279
|
-
"//nav[contains(@class,'
|
280
|
-
)&.text
|
281
|
-
|
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)
|
282
298
|
end
|
283
299
|
|
284
300
|
# Return ISO script code.
|
@@ -320,17 +336,12 @@ module RelatonIso
|
|
320
336
|
end
|
321
337
|
|
322
338
|
def fetch_contributors(ref)
|
323
|
-
ref.sub(/\s.*/, "").split("/").
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
name = "International Organization for Standardization"
|
330
|
-
url = "www.iso.org"
|
331
|
-
end
|
332
|
-
{ entity: { name: name, url: url, abbreviation: abbrev },
|
333
|
-
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"] }
|
334
345
|
end
|
335
346
|
end
|
336
347
|
# rubocop:enable Metrics/MethodLength
|
@@ -364,14 +375,14 @@ module RelatonIso
|
|
364
375
|
# Fetch copyright.
|
365
376
|
# @param ref [String]
|
366
377
|
# @param doc [Nokogiri::HTML::Document]
|
367
|
-
# @return [Hash]
|
378
|
+
# @return [Array<Hash>]
|
368
379
|
def fetch_copyright(ref, doc)
|
369
380
|
owner_name = ref.match(/.*?(?=\s)/).to_s
|
370
381
|
from = ref.match(/(?<=:)\d{4}/).to_s
|
371
382
|
if from.empty?
|
372
383
|
from = doc.xpath("//span[@itemprop='releaseDate']").text.match(/\d{4}/).to_s
|
373
384
|
end
|
374
|
-
{ owner: { name: owner_name }, from: from }
|
385
|
+
[{ owner: [{ name: owner_name }], from: from }]
|
375
386
|
end
|
376
387
|
end
|
377
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", "
|
41
|
-
spec.add_dependency "relaton-iso-bib", "
|
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.
|
4
|
+
version: 1.2.1
|
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-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -154,30 +154,30 @@ dependencies:
|
|
154
154
|
name: relaton-iec
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.0
|
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.0
|
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.0
|
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.0
|
180
|
+
version: 1.2.0
|
181
181
|
description: 'RelatonIso: retrieve ISO Standards for bibliographic use using the IsoBibliographicItem
|
182
182
|
model'
|
183
183
|
email:
|