relaton-iec 0.3.2 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/lib/relaton_iec.rb +8 -4
- data/lib/relaton_iec/iec_bibliography.rb +2 -2
- data/lib/relaton_iec/processor.rb +33 -0
- data/lib/relaton_iec/scrapper.rb +12 -7
- data/lib/relaton_iec/version.rb +1 -1
- data/relaton_iec.gemspec +1 -1
- metadata +5 -5
- data/lib/relaton/processor.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b0ad75aacbf0360cdcacc6e744dd6c26e6df9f0
|
4
|
+
data.tar.gz: 847e68d1a06123dfa521d7779f5608aa0702c4fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf0ceb4def8efe09e404c2b540700fb60709d52e184796742b6f5d7bd1e29dff3d6656201b631ecd1e50c27e6f96ec3749518eb2a82c7037c78f79102f334730
|
7
|
+
data.tar.gz: 4541bd9010a9ab99eb2a6903c03e5e07bbbc46710432bfc14d461196e8e52f81145c497294416e8b0605d66babfc6f20365d037d38a39169acb1f5d6ada7c32e
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
relaton-iec (0.
|
4
|
+
relaton-iec (0.4.4)
|
5
5
|
addressable
|
6
|
-
relaton-iso-bib (~> 0.
|
6
|
+
relaton-iso-bib (~> 0.3.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
addressable (2.
|
12
|
-
public_suffix (>= 2.0.2, <
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
13
|
byebug (11.0.1)
|
14
14
|
coderay (1.1.2)
|
15
15
|
crack (0.4.3)
|
@@ -26,7 +26,7 @@ GEM
|
|
26
26
|
json (2.2.0)
|
27
27
|
method_source (0.9.2)
|
28
28
|
mini_portile2 (2.4.0)
|
29
|
-
nokogiri (1.10.
|
29
|
+
nokogiri (1.10.4)
|
30
30
|
mini_portile2 (~> 2.4.0)
|
31
31
|
pry (0.12.2)
|
32
32
|
coderay (~> 1.1.0)
|
@@ -34,14 +34,14 @@ GEM
|
|
34
34
|
pry-byebug (3.7.0)
|
35
35
|
byebug (~> 11.0)
|
36
36
|
pry (~> 0.10)
|
37
|
-
public_suffix (
|
37
|
+
public_suffix (4.0.1)
|
38
38
|
rake (10.5.0)
|
39
|
-
relaton-bib (0.
|
39
|
+
relaton-bib (0.3.6)
|
40
40
|
addressable
|
41
|
-
nokogiri
|
42
|
-
relaton-iso-bib (0.
|
41
|
+
nokogiri
|
42
|
+
relaton-iso-bib (0.3.5)
|
43
43
|
isoics (~> 0.1.6)
|
44
|
-
relaton-bib (~> 0.
|
44
|
+
relaton-bib (~> 0.3.0)
|
45
45
|
ruby_deep_clone (~> 0.8.0)
|
46
46
|
rspec (3.8.0)
|
47
47
|
rspec-core (~> 3.8.0)
|
data/lib/relaton_iec.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
require "relaton_iec/version"
|
2
2
|
require "relaton_iec/iec_bibliography"
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
|
4
|
+
# if defined? Relaton
|
5
|
+
# require "relaton_iec/processor"
|
6
|
+
# # don't register the gem if it's required form relaton's registry
|
7
|
+
# return if caller.detect { |c| c.include? "register_gems" }
|
8
|
+
|
9
|
+
# Relaton::Registry.instance.register(RelatonIec::Processor)
|
10
|
+
# end
|
7
11
|
|
8
12
|
module RelatonIec
|
9
13
|
# Your code goes here...
|
@@ -13,7 +13,7 @@ module RelatonIec
|
|
13
13
|
# @return [RelatonIec::HitCollection]
|
14
14
|
def search(text, year = nil)
|
15
15
|
HitCollection.new text, year
|
16
|
-
rescue SocketError, OpenURI::HTTPError
|
16
|
+
rescue SocketError, OpenURI::HTTPError, OpenSSL::SSL::SSLError
|
17
17
|
raise RelatonBib::RequestError, "Could not access http://www.iec.ch"
|
18
18
|
end
|
19
19
|
|
@@ -131,7 +131,7 @@ module RelatonIec
|
|
131
131
|
fetch_pages(s, 3).each_with_index do |r, _i|
|
132
132
|
return { ret: r } if !year
|
133
133
|
|
134
|
-
r.
|
134
|
+
r.date.select { |d| d.type == "published" }.each do |d|
|
135
135
|
return { ret: r } if year.to_i == d.on.year
|
136
136
|
|
137
137
|
missed_years << d.on.year
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "relaton/processor"
|
2
|
+
|
3
|
+
module RelatonIec
|
4
|
+
class Processor < Relaton::Processor
|
5
|
+
def initialize
|
6
|
+
@short = :relaton_iec
|
7
|
+
@prefix = "IEC"
|
8
|
+
@defaultprefix = %r{^(IEC)[ /]|^IEV($| )}
|
9
|
+
@idtype = "IEC"
|
10
|
+
end
|
11
|
+
|
12
|
+
# @param code [String]
|
13
|
+
# @param date [String, NilClass] year
|
14
|
+
# @param opts [Hash]
|
15
|
+
# @return [RelatonIsoBib::IsoBibliographicItem]
|
16
|
+
def get(code, date, opts)
|
17
|
+
::RelatonIec::IecBibliography.get(code, date, opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param xml [String]
|
21
|
+
# @return [RelatonIsoBib::IsoBibliographicItem]
|
22
|
+
def from_xml(xml)
|
23
|
+
RelatonIsoBib::XMLParser.from_xml xml
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param hash [Hash]
|
27
|
+
# @return [RelatonIsoBib::IsoBibliographicItem]
|
28
|
+
def hash_to_bib(hash)
|
29
|
+
item_hash = ::RelatonIsoBib::HashConverter.hash_to_bib(hash)
|
30
|
+
::RelatonIsoBib::IsoBibliographicItem.new item_hash
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/relaton_iec/scrapper.rb
CHANGED
@@ -62,17 +62,17 @@ module RelatonIec
|
|
62
62
|
edition: edition,
|
63
63
|
language: ["en"],
|
64
64
|
script: ["Latn"],
|
65
|
-
|
65
|
+
title: fetch_titles(hit_data),
|
66
66
|
type: fetch_type(doc),
|
67
67
|
docstatus: status,
|
68
68
|
ics: fetch_ics(doc),
|
69
|
-
|
70
|
-
|
69
|
+
date: fetch_dates(doc),
|
70
|
+
contributor: fetch_contributors(hit_data[:code]),
|
71
71
|
editorialgroup: fetch_workgroup(doc),
|
72
72
|
abstract: fetch_abstract(doc),
|
73
73
|
copyright: fetch_copyright(hit_data[:code], doc),
|
74
74
|
link: fetch_link(doc, hit_data[:url]),
|
75
|
-
|
75
|
+
relation: relations,
|
76
76
|
)
|
77
77
|
end
|
78
78
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
@@ -169,7 +169,8 @@ module RelatonIec
|
|
169
169
|
# end
|
170
170
|
Nokogiri::HTML(resp.body)
|
171
171
|
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
172
|
-
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError
|
172
|
+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
|
173
|
+
OpenSSL::SSL::SSLError
|
173
174
|
raise RelatonBib::RequestError, "Could not access #{url}"
|
174
175
|
end
|
175
176
|
# rubocop:enable Metrics/AbcSize
|
@@ -326,7 +327,11 @@ module RelatonIec
|
|
326
327
|
intro, main, part = titles[0], titles[1], nil
|
327
328
|
end
|
328
329
|
when 3
|
329
|
-
|
330
|
+
if /^(Part|Partie) \d+:/ =~ titles[1]
|
331
|
+
intro, main, part = nil, titles[0], titles[1..2].join(" - ")
|
332
|
+
else
|
333
|
+
intro, main, part = titles[0], titles[1], titles[2]
|
334
|
+
end
|
330
335
|
else
|
331
336
|
intro, main, part = titles[0], titles[1], titles[2..-1]&.join(" -- ")
|
332
337
|
end
|
@@ -371,7 +376,7 @@ module RelatonIec
|
|
371
376
|
url = "www.iec.ch"
|
372
377
|
end
|
373
378
|
{ entity: { name: name, url: url, abbreviation: abbrev },
|
374
|
-
|
379
|
+
role: [type: "publisher"] }
|
375
380
|
end
|
376
381
|
end
|
377
382
|
|
data/lib/relaton_iec/version.rb
CHANGED
data/relaton_iec.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.
|
173
|
+
version: 0.3.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: 0.
|
180
|
+
version: 0.3.0
|
181
181
|
description: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IsoBibliographicItem
|
182
182
|
model'
|
183
183
|
email:
|
@@ -198,11 +198,11 @@ files:
|
|
198
198
|
- appveyor.yml
|
199
199
|
- bin/console
|
200
200
|
- bin/setup
|
201
|
-
- lib/relaton/processor.rb
|
202
201
|
- lib/relaton_iec.rb
|
203
202
|
- lib/relaton_iec/hit.rb
|
204
203
|
- lib/relaton_iec/hit_collection.rb
|
205
204
|
- lib/relaton_iec/iec_bibliography.rb
|
205
|
+
- lib/relaton_iec/processor.rb
|
206
206
|
- lib/relaton_iec/scrapper.rb
|
207
207
|
- lib/relaton_iec/statuses.yml
|
208
208
|
- lib/relaton_iec/version.rb
|
data/lib/relaton/processor.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require "relaton/processor"
|
2
|
-
|
3
|
-
module Relaton
|
4
|
-
module RelatonIec
|
5
|
-
class Processor < Relaton::Processor
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@short = :relaton_iec
|
9
|
-
@prefix = "IEC"
|
10
|
-
@defaultprefix = %r{^(IEC)[ /]|^IEV($| )}
|
11
|
-
@idtype = "IEC"
|
12
|
-
end
|
13
|
-
|
14
|
-
def get(code, date, opts)
|
15
|
-
::RelatonIec::IecBibliography.get(code, date, opts)
|
16
|
-
end
|
17
|
-
|
18
|
-
def from_xml(xml)
|
19
|
-
RelatonIsoBib::XMLParser.from_xml xml
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|