relaton-iso 0.10.0 → 0.11.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: f85cd97c6a51c622c7f21fb2c447239e78aec70b0e58d3eb29ee80c50bfda396
4
- data.tar.gz: 53f02460c301947d743e182a6a73c508b4b1f4f5fe2799e84c7ce1ceeec427ae
3
+ metadata.gz: 8e0de463206d283ea92a8668da7ec4606d1d263ad80d68990e29b81874ca2e0a
4
+ data.tar.gz: b82019ff896fb137c98c0feee5e63da20184163ed06d2ca6ce7dd47d147ef9fd
5
5
  SHA512:
6
- metadata.gz: 6b9608b0790000213d99fc943e84c91482ff7457fb04dd160d05ed8d839b8b03e3b21a7b3f48bb8226f4483e4e376b481cfbc2550906e0cc423ea5faa42acf3e
7
- data.tar.gz: 9c5e739da11a485be36b93811e6425f0a60bbaa090dde6f56774854b72a6ff4280022b15e7e90aee999546c5e281882252b42a0b0c368c002117b278d99e4137
6
+ metadata.gz: 59b7e4514351c77403511c8a16f6efe03cf52b48db50df18702a3785d78e4f089064867ddc36994143f3560ba481f45b7f38d3dc27611e2d6c0db8a4fe6fc63c
7
+ data.tar.gz: a55488e0a15715a2dcba61a13426da787809d5608dc0df74b24f2e892daf18c31b70ca19165f900af3a903b9f90032cfe880d772721caa2b645fe621f2ffeb87
@@ -3,9 +3,6 @@
3
3
  module RelatonIso
4
4
  # Hit.
5
5
  class Hit < RelatonBib::Hit
6
- # @return [RelatonIso::HitCollection]
7
- attr_reader :hit_collection
8
-
9
6
  # Parse page.
10
7
  # @param lang [String, NilClass]
11
8
  # @return [RelatonIso::IsoBibliographicItem]
@@ -13,25 +10,12 @@ module RelatonIso
13
10
  @fetch ||= Scrapper.parse_page @hit, lang
14
11
  end
15
12
 
16
- # @param builder [Nokogiri::XML::Builder]
17
- def to_xml(builder = nil, **opts)
18
- if builder
19
- fetch.to_xml builder, **opts
20
- else
21
- builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
22
- fetch.to_xml xml, **opts
23
- end
24
- builder.doc.root.to_xml
25
- end
26
- end
27
-
28
13
  def sort_weight
29
14
  case hit["publicationStatus"]
30
15
  when "Published" then 0
31
16
  when "Under development" then 1
32
17
  when "Withdrawn" then 2
33
- else
34
- 3
18
+ else 3
35
19
  end
36
20
  end
37
21
  end
@@ -1,32 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "forwardable"
4
3
  require "relaton_iso/hit"
5
4
 
6
5
  module RelatonIso
7
6
  # Page of hit collection.
8
- class HitCollection
9
- extend Forwardable
10
-
11
- def_delegators :@array, :<<, :[], :first, :empty?, :any?, :size
12
-
13
- # @return [String, NilClass]
14
- attr_reader :text
15
-
7
+ class HitCollection < RelatonBib::HitCollection
16
8
  # @param text [String] reference to search
17
9
  def initialize(text)
18
- @array = []
19
- @text = text
10
+ super
20
11
  %r{\s(?<num>\d+)(-(?<part>[\d-]+))?} =~ text
21
12
  http = Net::HTTP.new "www.iso.org", 443
22
13
  http.use_ssl = true
23
14
  search = ["status=ENT_ACTIVE,ENT_PROGRESS,ENT_INACTIVE,ENT_DELETED"]
24
15
  search << "docNumber=#{num}"
25
16
  search << "docPartNo=#{part}" if part
26
- # if year
27
- # search << "stageDateStart=#{Date.new(year.to_i).strftime("%Y-%m-%d")}"
28
- # search << "stageDateEnd=#{Date.new(year.to_i, 12, 31).strftime("%Y-%m-%d")}"
29
- # end
30
17
  q = search.join "&"
31
18
  resp = http.get("/cms/render/live/en/sites/isoorg.advancedSearch.do?#{q}",
32
19
  "Accept" => "application/json, text/plain, */*")
@@ -42,17 +29,6 @@ module RelatonIso
42
29
  end
43
30
  end
44
31
 
45
- def select(&block)
46
- me = DeepClone.clone self
47
- me.instance_variable_get(:@array).select!(&block)
48
- me
49
- end
50
-
51
- def reduce!(sum, &block)
52
- @array = @array.reduce sum, &block
53
- self
54
- end
55
-
56
32
  # @param lang [String, NilClass]
57
33
  # @return [RelatonIsoBib::IsoBibliographicItem]
58
34
  def to_all_parts(lang = nil)
@@ -73,26 +49,6 @@ module RelatonIso
73
49
  bibitem
74
50
  end
75
51
 
76
- def to_s
77
- inspect
78
- end
79
-
80
- def inspect
81
- "<#{self.class}:#{format('%#.14x', object_id << 1)} @ref=#{@text}>"
82
- end
83
-
84
- def to_xml(**opts)
85
- builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
86
- xml.documents do
87
- @array.each do |hit|
88
- hit.fetch
89
- hit.to_xml xml, **opts
90
- end
91
- end
92
- end
93
- builder.to_xml
94
- end
95
-
96
52
  private
97
53
 
98
54
  def parse_date(hit)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonIso
4
- VERSION = "0.10.0"
4
+ VERSION = "0.11.0"
5
5
  end
data/relaton_iso.gemspec CHANGED
@@ -37,6 +37,6 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency "vcr"
38
38
  spec.add_development_dependency "webmock"
39
39
 
40
- spec.add_dependency "relaton-iec", "~> 0.8.0"
41
- spec.add_dependency "relaton-iso-bib", "~> 0.7.0"
40
+ spec.add_dependency "relaton-iec", "~> 0.9.0"
41
+ spec.add_dependency "relaton-iso-bib", "~> 0.8.0"
42
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.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: byebug
@@ -156,28 +156,28 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 0.8.0
159
+ version: 0.9.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.8.0
166
+ version: 0.9.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: relaton-iso-bib
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: 0.7.0
173
+ version: 0.8.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.7.0
180
+ version: 0.8.0
181
181
  description: 'RelatonIso: retrieve ISO Standards for bibliographic use using the IsoBibliographicItem
182
182
  model'
183
183
  email: