relaton-iec 0.8.0 → 0.9.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_iec/hit.rb +1 -40
- data/lib/relaton_iec/hit_collection.rb +3 -36
- data/lib/relaton_iec/version.rb +1 -1
- data/relaton_iec.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5bd7f61db81db9185f68ef6a40b7988e53363cb31d4b3e98210da625f1f408d
|
4
|
+
data.tar.gz: 39f8464d2dad234528b42532a765627af36f1436065b53889c26a3765eb0603c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0485d74b4bbbcea6244ae74cfd3b1d5901ea5a1b2695a7fa3dfae3516beb0dd7d73f9d7b923651ed2f9d3aa953632244d08541558a7cf0275e28ca8654fd9753'
|
7
|
+
data.tar.gz: ff9fd992c3952c7f0544434a76460a3bbd3efbc98eb8c427c3ba188f2009e18d3dbfc673dea79d1009f5921a7c214ca9a958bae98c1ddb9252e3cd8c0cd2cd5f
|
data/lib/relaton_iec/hit.rb
CHANGED
@@ -2,50 +2,11 @@
|
|
2
2
|
|
3
3
|
module RelatonIec
|
4
4
|
# Hit.
|
5
|
-
class Hit
|
6
|
-
# @return [Isobib::HitCollection]
|
7
|
-
attr_reader :hit_collection
|
8
|
-
|
9
|
-
# @return [Array<Hash>]
|
10
|
-
attr_reader :hit
|
11
|
-
|
12
|
-
# @param hit [Hash]
|
13
|
-
# @param hit_collection [Isobib:HitCollection]
|
14
|
-
def initialize(hit, hit_collection = nil)
|
15
|
-
@hit = hit
|
16
|
-
@hit_collection = hit_collection
|
17
|
-
end
|
18
|
-
|
5
|
+
class Hit < RelatonBib::Hit
|
19
6
|
# Parse page.
|
20
7
|
# @return [Isobib::IsoBibliographicItem]
|
21
8
|
def fetch
|
22
9
|
@fetch ||= Scrapper.parse_page @hit
|
23
10
|
end
|
24
|
-
|
25
|
-
# @return [String]
|
26
|
-
def to_s
|
27
|
-
inspect
|
28
|
-
end
|
29
|
-
|
30
|
-
# @return [String]
|
31
|
-
def inspect
|
32
|
-
"<#{self.class}:#{format('%#.14x', object_id << 1)} "\
|
33
|
-
"@text=\"#{@hit_collection&.text}\" "\
|
34
|
-
"@fetched=\"#{!@fetch.nil?}\" "\
|
35
|
-
"@fullIdentifier=\"#{@fetch&.shortref(nil)}\" "\
|
36
|
-
"@title=\"#{@hit[:code]}\">"
|
37
|
-
end
|
38
|
-
|
39
|
-
# @return [String]
|
40
|
-
def to_xml(opts = {})
|
41
|
-
#if builder
|
42
|
-
#fetch.to_xml builder, opts
|
43
|
-
#else
|
44
|
-
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
45
|
-
fetch.to_xml xml, opts
|
46
|
-
end
|
47
|
-
builder.doc.root.to_xml
|
48
|
-
#end
|
49
|
-
end
|
50
11
|
end
|
51
12
|
end
|
@@ -5,24 +5,14 @@ require "addressable/uri"
|
|
5
5
|
|
6
6
|
module RelatonIec
|
7
7
|
# Page of hit collection.
|
8
|
-
class HitCollection <
|
8
|
+
class HitCollection < RelatonBib::HitCollection
|
9
9
|
|
10
10
|
DOMAIN = "https://webstore.iec.ch"
|
11
11
|
|
12
|
-
# @return [TrueClass, FalseClass]
|
13
|
-
attr_reader :fetched
|
14
|
-
|
15
|
-
# @return [String]
|
16
|
-
attr_reader :text
|
17
|
-
|
18
|
-
# @return [String]
|
19
|
-
attr_reader :year
|
20
|
-
|
21
12
|
# @param ref_nbr [String]
|
22
13
|
# @param year [String]
|
23
14
|
def initialize(ref_nbr, year = nil) #(text, hit_pages = nil)
|
24
|
-
|
25
|
-
@year = year
|
15
|
+
super
|
26
16
|
from, to = nil
|
27
17
|
if year
|
28
18
|
from = Date.strptime year, "%Y"
|
@@ -30,36 +20,13 @@ module RelatonIec
|
|
30
20
|
end
|
31
21
|
url = "#{DOMAIN}/searchkey&RefNbr=#{ref_nbr}&From=#{from}&To=#{to}&start=1"
|
32
22
|
doc = Nokogiri::HTML OpenURI.open_uri(::Addressable::URI.parse(url).normalize)
|
33
|
-
|
23
|
+
@array = doc.css("ul.search-results > li").map do |h|
|
34
24
|
link = h.at('a[@href!="#"]')
|
35
25
|
code = link.text.tr [194, 160].pack("c*").force_encoding("UTF-8"), ""
|
36
26
|
title = h.xpath("text()").text.gsub(/[\r\n]/, "")
|
37
27
|
url = DOMAIN + link[:href]
|
38
28
|
Hit.new({ code: code, title: title, url: url }, self)
|
39
29
|
end
|
40
|
-
concat hits
|
41
|
-
@fetched = false
|
42
|
-
end
|
43
|
-
|
44
|
-
# @return [RelatonIec::HitCollection]
|
45
|
-
def fetch
|
46
|
-
workers = RelatonBib::WorkersPool.new 4
|
47
|
-
workers.worker(&:fetch)
|
48
|
-
each do |hit|
|
49
|
-
workers << hit
|
50
|
-
end
|
51
|
-
workers.end
|
52
|
-
workers.result
|
53
|
-
@fetched = true
|
54
|
-
self
|
55
|
-
end
|
56
|
-
|
57
|
-
def to_s
|
58
|
-
inspect
|
59
|
-
end
|
60
|
-
|
61
|
-
def inspect
|
62
|
-
"<#{self.class}:#{format('%#.14x', object_id << 1)} @fetched=#{@fetched}>"
|
63
30
|
end
|
64
31
|
end
|
65
32
|
end
|
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.9.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-02-
|
11
|
+
date: 2020-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
159
|
+
version: 0.8.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: 0.
|
166
|
+
version: 0.8.0
|
167
167
|
description: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IsoBibliographicItem
|
168
168
|
model'
|
169
169
|
email:
|