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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 583c49d9de7b7d2b78f936a679d5d3fe99567688e3fb7770c6e2ec7fa4d79040
4
- data.tar.gz: efdf34b2534ae5669ed8330721d9fa1b8c7dda1259c5e85c58791570f3452a52
3
+ metadata.gz: f5bd7f61db81db9185f68ef6a40b7988e53363cb31d4b3e98210da625f1f408d
4
+ data.tar.gz: 39f8464d2dad234528b42532a765627af36f1436065b53889c26a3765eb0603c
5
5
  SHA512:
6
- metadata.gz: b97bdf48abef80db5f660d56aeaf04918904e820c70b17789fa1d1ffa953341bb1f3657c68fa012c9a1d68fbcb46c69b02c6d519c3234001a0e742f14c934586
7
- data.tar.gz: dfcb1ed0e9fd675c7ae06eb0395c82dd613b5ec3b7abeac2c5709175667bdec4e9f30ddd6af209aefaa7173e659b2ce7739e8c7fa166e8adfa3e41989811744a
6
+ metadata.gz: '0485d74b4bbbcea6244ae74cfd3b1d5901ea5a1b2695a7fa3dfae3516beb0dd7d73f9d7b923651ed2f9d3aa953632244d08541558a7cf0275e28ca8654fd9753'
7
+ data.tar.gz: ff9fd992c3952c7f0544434a76460a3bbd3efbc98eb8c427c3ba188f2009e18d3dbfc673dea79d1009f5921a7c214ca9a958bae98c1ddb9252e3cd8c0cd2cd5f
@@ -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 < Array
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
- @text = ref_nbr
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
- hits = doc.css("ul.search-results > li").map do |h|
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
@@ -1,3 +1,3 @@
1
1
  module RelatonIec
2
- VERSION = "0.8.0".freeze
2
+ VERSION = "0.9.0".freeze
3
3
  end
data/relaton_iec.gemspec CHANGED
@@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency "webmock"
35
35
 
36
36
  spec.add_dependency "addressable"
37
- spec.add_dependency "relaton-iso-bib", "~> 0.7.0"
37
+ spec.add_dependency "relaton-iso-bib", "~> 0.8.0"
38
38
  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.8.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-16 00:00:00.000000000 Z
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.7.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.7.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: