checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
- SHA256:
3
- metadata.gz: '07119c00b2305b22248c286fe2109109c0f155591ddf8cd2796cbc4aaa35c695'
4
- data.tar.gz: a7631ec9e3eb9b0484ccf1cace3e199303d7a99e23d0da3a7ac0e9d8b39cb820
2
+ SHA1:
3
+ metadata.gz: 7f223511bcf5da27381a805deae65c76f0f4a162
4
+ data.tar.gz: 6edce17c72bd41fdd860db9b8ce639d601f06f30
5
5
SHA512:
6
- metadata.gz: ca6ffa63dafd1993a4d8615f1d4025a8df799625e179ecae80676d9904432d5a5aedc1244482e1bd55ad2adadaead82e711cc6e082f55cc321049771ffaf2f9e
7
- data.tar.gz: 1368d6ff919457b8ec24363b8381cb0cc34c0f5c2c57847dff405804cab0a87361517c4b51a5bb9c1bd2d0df611488bf47e00a283a9641ea33b1fbcea5b1fc47
6
+ metadata.gz: bc39291b67506f26cf760f1528d15d8b1fb8c44c160d044a9fe031fa13d99cb0751cf285bb2381c1f7de7214c4d6f8f5e2a002daf46893048ead454e5917fcb8
7
+ data.tar.gz: 5c04836bad95cc3988bd7431c1c1251a83c8319c40b9399600723d2d2b9ff3c292c98fc35ee9127f8818ba3d4bbc61902270cba705b42f74c9891bd82cba8070
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
+ Encoding.default_external = Encoding::UTF_8
2
+ Encoding.default_internal = Encoding::UTF_8
3
+
1
4
source "https://rubygems.org"
2
5
3
6
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
data/Gemfile.lock CHANGED
@@ -1,32 +1,32 @@
1
1
PATH
2
2
remote: .
3
3
specs:
4
- relaton-iec (0.4.0)
4
+ relaton-iec (0.4.8)
5
5
addressable
6
6
relaton-iso-bib (~> 0.3.0)
7
7
8
8
GEM
9
9
remote: https://rubygems.org/
10
10
specs:
11
- addressable (2.6.0)
12
- public_suffix (>= 2.0.2, < 4.0)
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)
16
16
safe_yaml (~> 1.0.0)
17
- debase (0.2.2)
17
+ debase (0.2.4.1)
18
18
debase-ruby_core_source (>= 0.10.2)
19
19
debase-ruby_core_source (0.10.5)
20
20
diff-lcs (1.3)
21
21
docile (1.3.2)
22
22
equivalent-xml (0.6.0)
23
23
nokogiri (>= 1.4.3)
24
- hashdiff (0.4.0)
25
- isoics (0.1.7)
24
+ hashdiff (1.0.0)
25
+ isoics (0.1.8)
26
26
json (2.2.0)
27
27
method_source (0.9.2)
28
28
mini_portile2 (2.4.0)
29
- nokogiri (1.10.3)
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,12 +34,12 @@ GEM
34
34
pry-byebug (3.7.0)
35
35
byebug (~> 11.0)
36
36
pry (~> 0.10)
37
- public_suffix (3.1.1)
37
+ public_suffix (4.0.1)
38
38
rake (10.5.0)
39
- relaton-bib (0.3.0)
39
+ relaton-bib (0.3.9)
40
40
addressable
41
- nokogiri (~> 1.10)
42
- relaton-iso-bib (0.3.0)
41
+ nokogiri
42
+ relaton-iso-bib (0.3.9)
43
43
isoics (~> 0.1.6)
44
44
relaton-bib (~> 0.3.0)
45
45
ruby_deep_clone (~> 0.8.0)
@@ -47,7 +47,7 @@ GEM
47
47
rspec-core (~> 3.8.0)
48
48
rspec-expectations (~> 3.8.0)
49
49
rspec-mocks (~> 3.8.0)
50
- rspec-core (3.8.1)
50
+ rspec-core (3.8.2)
51
51
rspec-support (~> 3.8.0)
52
52
rspec-expectations (3.8.4)
53
53
diff-lcs (>= 1.2.0, < 2.0)
@@ -60,13 +60,13 @@ GEM
60
60
rake (>= 0.8.1)
61
61
ruby_deep_clone (0.8.0)
62
62
safe_yaml (1.0.5)
63
- simplecov (0.16.1)
63
+ simplecov (0.17.0)
64
64
docile (~> 1.1)
65
65
json (>= 1.8, < 3)
66
66
simplecov-html (~> 0.10.0)
67
67
simplecov-html (0.10.2)
68
68
vcr (5.0.0)
69
- webmock (3.6.0)
69
+ webmock (3.7.2)
70
70
addressable (>= 2.3.6)
71
71
crack (>= 0.3.2)
72
72
hashdiff (>= 0.4.0, < 2.0.0)
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
data/lib/relaton_iec.rb CHANGED
@@ -1,9 +1,13 @@
1
1
require "relaton_iec/version"
2
2
require "relaton_iec/iec_bibliography"
3
- if defined? Relaton
4
- require_relative "relaton/processor"
5
- Relaton::Registry.instance.register(Relaton::RelatonIec::Processor)
6
- end
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...
data/lib/relaton_iec/iec_bibliography.rb CHANGED
@@ -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
data/lib/relaton_iec/processor.rb ADDED
@@ -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
@@ -57,13 +57,14 @@ module RelatonIec
57
57
status, relations = fetch_status_relations hit_data[:url]
58
58
59
59
RelatonIsoBib::IsoBibliographicItem.new(
60
+ fetched: Date.today.to_s,
60
61
docid: [RelatonBib::DocumentIdentifier.new(id: hit_data[:code], type: "IEC")],
61
62
structuredidentifier: fetch_structuredidentifier(doc),
62
63
edition: edition,
63
64
language: ["en"],
64
65
script: ["Latn"],
65
66
title: fetch_titles(hit_data),
66
- type: fetch_type(doc),
67
+ doctype: fetch_type(doc),
67
68
docstatus: status,
68
69
ics: fetch_ics(doc),
69
70
date: fetch_dates(doc),
@@ -169,7 +170,8 @@ module RelatonIec
169
170
# end
170
171
Nokogiri::HTML(resp.body)
171
172
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
172
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError
173
+ Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
174
+ OpenSSL::SSL::SSLError
173
175
raise RelatonBib::RequestError, "Could not access #{url}"
174
176
end
175
177
# rubocop:enable Metrics/AbcSize
@@ -292,8 +294,8 @@ module RelatonIec
292
294
# @param doc [Nokogiri::HTML::Document]
293
295
# @return [String]
294
296
def fetch_type(doc)
295
- doc.at('//th[contains(., "Publication type")]/following-sibling::td/span')
296
- .text.downcase.tr " ", "-"
297
+ doc.at('//th[contains(., "Publication type")]/following-sibling::td/span').
298
+ text.downcase.tr " ", "-"
297
299
# type_match = title.match(%r{^(ISO|IWA|IEC)(?:(/IEC|/IEEE|/PRF|
298
300
# /NP)*\s|/)(TS|TR|PAS|AWI|CD|FDIS|NP|DIS|WD|R|Guide|(?=\d+))}x)
299
301
# #return "international-standard" if type_match.nil?
@@ -375,7 +377,7 @@ module RelatonIec
375
377
url = "www.iec.ch"
376
378
end
377
379
{ entity: { name: name, url: url, abbreviation: abbrev },
378
- role: ["publisher"] }
380
+ role: [type: "publisher"] }
379
381
end
380
382
end
381
383
data/lib/relaton_iec/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
module RelatonIec
2
- VERSION = "0.4.1".freeze
2
+ VERSION = "0.4.8".freeze
3
3
end
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.1
4
+ version: 0.4.8
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-07-29 00:00:00.000000000 Z
11
+ date: 2019-10-14 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: bundler
@@ -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
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
227
version: '0'
228
228
requirements: []
229
229
rubyforge_project:
230
- rubygems_version: 2.7.6
230
+ rubygems_version: 2.6.12
231
231
signing_key:
232
232
specification_version: 4
233
233
summary: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IsoBibliographicItem