relaton-itu 0.7.0 → 0.8.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: 4790976517afd8706abfa87e7626af60f1615a0a0348f8b953f646c58d18eb48
4
- data.tar.gz: c633aed5322a24fd22d5716339084407f8c4d3afff63e5e31400dc72ee7b3045
3
+ metadata.gz: caf4c7e674479b6b0caaa75dd8ef0dff3c1f3274db3d8ca8c2f3a139b7709d46
4
+ data.tar.gz: c39ba0a9d6171fa83e91c9a5cc1109ef5c5150854b45692daafe3f8b7acb50a1
5
5
  SHA512:
6
- metadata.gz: 1028fab59b0caf1a282e6d00b8bb252ce865dc9bfe145e2271e3db0a3a02e2dc7665cad7d99537a50f9c5c5d1dd804a80041d33900bb9e61b8eba9be328381cd
7
- data.tar.gz: d681bd49733e7e3c63d18981c2046ad1ef32c05abfcbae10afc439796d3aeb3898488eb83d44a992cefce0c58e1ec58cc3e790fe7b483eac3e54cce6e9e1a2c7
6
+ metadata.gz: 4d27fe629aa5b8eb16512592ec6f180c37ed1c620a4be3802298992b31983ac63184a46f3e37c14dc49a870576e4826f0c85a5a2de95ea1c208c9e99d3a15fc8
7
+ data.tar.gz: dac4e205554c678dbd95ee90b0e899e740f9e4f334df1914f6dbd394a8e2a8432986c111b1d2f3b8107a504758664e82e600b19664c13e30fbd0045c479daa82
@@ -2,50 +2,11 @@
2
2
 
3
3
  module RelatonItu
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
@@ -6,28 +6,13 @@ require "net/http"
6
6
 
7
7
  module RelatonItu
8
8
  # Page of hit collection.
9
- class HitCollection < Array
9
+ class HitCollection < RelatonBib::HitCollection
10
10
  DOMAIN = "https://www.itu.int".freeze
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
- def initialize(ref_nbr, year = nil) #(text, hit_pages = nil)
24
- @text = ref_nbr
25
- @year = year
26
- # from, to = nil
27
- # if year
28
- # from = Date.strptime year, "%Y"
29
- # to = from.next_year.prev_day
30
- # end
14
+ def initialize(ref_nbr, year = nil)
15
+ super
31
16
  group = %r{(OB|Operational Bulletin) No} =~ text ? "Publications" : "Recommendations"
32
17
  url = "#{DOMAIN}/net4/ITU-T/search/GlobalSearch/Search"
33
18
  params = {
@@ -79,36 +64,13 @@ module RelatonItu
79
64
  data = { json: params.to_json }
80
65
  resp = Net::HTTP.post(URI(url), data.to_json, "Content-Type" => "application/json")
81
66
  doc = JSON.parse resp.body
82
- hits = doc["results"].map do |h|
67
+ @array = doc["results"].map do |h|
83
68
  code = h["Media"]["Name"]
84
69
  title = h["Title"]
85
70
  url = h["Redirection"]
86
71
  type = group.downcase[0...-1]
87
72
  Hit.new({ code: code, title: title, url: url, type: type }, self)
88
73
  end
89
- concat hits
90
- @fetched = false
91
- end
92
-
93
- # @return [RelatonItu::HitCollection]
94
- def fetch
95
- workers = RelatonBib::WorkersPool.new 4
96
- workers.worker(&:fetch)
97
- each do |hit|
98
- workers << hit
99
- end
100
- workers.end
101
- workers.result
102
- @fetched = true
103
- self
104
- end
105
-
106
- def to_s
107
- inspect
108
- end
109
-
110
- def inspect
111
- "<#{self.class}:#{format('%#.14x', object_id << 1)} @fetched=#{@fetched}>"
112
74
  end
113
75
  end
114
76
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonItu
2
- VERSION = "0.7.0".freeze
2
+ VERSION = "0.8.0".freeze
3
3
  end
@@ -37,5 +37,5 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency "webmock"
38
38
  spec.add_development_dependency "ruby-jing"
39
39
 
40
- spec.add_dependency "relaton-iso-bib", "~> 0.7.0"
40
+ spec.add_dependency "relaton-iso-bib", "~> 0.8.0"
41
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-itu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.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-17 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: 'RelatonItu: retrieve ITU Standards for bibliographic use using the BibliographicItem
168
168
  model'
169
169
  email: