relaton-iso 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: deb85071d2ebed9f1e67b59e9a537447760294a8ce80ff22be58d1d7998ab00e
4
- data.tar.gz: 35e80272681800ac9e9b74c7ad0cc27591064dc92cbfba32dab152bd7b522176
3
+ metadata.gz: 0cbed7056136ece40250512abb969807dbec09fc8ccf7f35c0630cf2bb505930
4
+ data.tar.gz: f102924d725dbf89310e7b834cff58eea44e4bf394e8e32afa9b896dc6a49f3b
5
5
  SHA512:
6
- metadata.gz: afdf9b868856297b715394060127a9ad5ec690a367e7031364a4cd17c906897a12e99f96d78b2fae16328e955b51ee42e8a7ec449ca341dd7eb3a769b8b4d1cf
7
- data.tar.gz: 75890dddb68e7ea33bfcf3bf92589dc61b9c3a8da166079e65bfce7f166c68cc62194e46b5c316ceed4f21f7d477c56eccda8b8d558230af24ed81bb0afc200d
6
+ metadata.gz: 52e04fb0cc61407b669e0ad1cdc30220149efe16d72099ac97cca2503847e9d58e18cacd13703142a6bc654ce07c6d953e50640f9018849335b85782b700b840
7
+ data.tar.gz: f54fc59412c41567637ab92df52dd528fd6c02e7699c5d89a9c385ea37c00e5fc8671581a46579580d467e6206b0f48782113f62a7a2bb163227ac3bc0bf349d
@@ -10,11 +10,12 @@ module RelatonIso
10
10
  @fetch ||= Scrapper.parse_page @hit, lang
11
11
  end
12
12
 
13
+ # @return [Integer]
13
14
  def sort_weight
14
- case hit["publicationStatus"]
15
- when "Published" then 0
16
- when "Under development" then 1
17
- when "Withdrawn" then 2
15
+ case hit["publicationStatus"] && hit["publicationStatus"]["key"]
16
+ when "ENT_ACTIVE" then 0
17
+ when "ENT_PROGRESS" then 1
18
+ when "ENT_INACTIVE" then 2
18
19
  else 3
19
20
  end
20
21
  end
@@ -5,6 +5,8 @@ require "relaton_iso/hit"
5
5
  module RelatonIso
6
6
  # Page of hit collection.
7
7
  class HitCollection < RelatonBib::HitCollection
8
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
9
+
8
10
  # @param text [String] reference to search
9
11
  def initialize(text)
10
12
  super
@@ -48,9 +50,12 @@ module RelatonIso
48
50
  end
49
51
  all_parts_item
50
52
  end
53
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
51
54
 
52
55
  private
53
56
 
57
+ # @param hit [Hash]
58
+ # @return [Date]
54
59
  def parse_date(hit)
55
60
  if hit["publicationDate"]
56
61
  Date.strptime(hit["publicationDate"], "%Y-%m")
@@ -13,9 +13,9 @@ module RelatonIso
13
13
  # @return [RelatonIso::HitCollection]
14
14
  def search(text)
15
15
  HitCollection.new text
16
- rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
17
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
18
- OpenSSL::SSL::SSLError, Errno::ETIMEDOUT
16
+ rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
17
+ EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
18
+ Net::ProtocolError, OpenSSL::SSL::SSLError, Errno::ETIMEDOUT
19
19
  raise RelatonBib::RequestError, "Could not access http://www.iso.org"
20
20
  end
21
21
 
@@ -58,6 +58,8 @@ module RelatonIso
58
58
 
59
59
  private
60
60
 
61
+ # rubocop:disable Metrics/MethodLength
62
+
61
63
  def fetch_ref_err(code, year, missed_years)
62
64
  id = year ? "#{code}:#{year}" : code
63
65
  warn "[relaton-iso] WARNING: no match found online for #{id}. "\
@@ -75,13 +77,7 @@ module RelatonIso
75
77
  nil
76
78
  end
77
79
 
78
- # def fetch_pages(s, n)
79
- # workers = RelatonBib::WorkersPool.new n
80
- # workers.worker { |w| { i: w[:i], hit: w[:hit].fetch } }
81
- # s.each_with_index { |hit, i| workers << { i: i, hit: hit } }
82
- # workers.end
83
- # workers.result.sort { |x, y| x[:i] <=> y[:i] }.map { |x| x[:hit] }
84
- # end
80
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
85
81
 
86
82
  # Search for hits. If no found then trying missed stages and ISO/IEC.
87
83
  #
@@ -114,6 +110,7 @@ module RelatonIso
114
110
  end
115
111
  res
116
112
  end
113
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
117
114
 
118
115
  # @param result [RelatonIso::HitCollection]
119
116
  # @param corr [String] correction
@@ -137,6 +134,8 @@ module RelatonIso
137
134
  end
138
135
  end
139
136
 
137
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
138
+
140
139
  # Sort through the results from RelatonIso, fetching them three at a time,
141
140
  # and return the first result that matches the code,
142
141
  # matches the year (if provided), and which # has a title (amendments do not).
@@ -146,8 +145,6 @@ module RelatonIso
146
145
  def isobib_results_filter(result, year, opts)
147
146
  missed_years = []
148
147
  hits = result.reduce!([]) do |hts, h|
149
- # if !year && h.hit["publicationStatus"] == "Withdrawn"
150
- # hts
151
148
  if !year || %r{:(?<iyear>\d{4})} =~ h.hit["docRef"] && iyear == year
152
149
  hts << h
153
150
  else
@@ -161,6 +158,7 @@ module RelatonIso
161
158
 
162
159
  { ret: hits.to_all_parts(opts[:lang]) }
163
160
  end
161
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
164
162
 
165
163
  # @param code [String]
166
164
  # @param year [String, NilClass]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonIso
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  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: 1.0.0
4
+ version: 1.0.1
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-04-25 00:00:00.000000000 Z
11
+ date: 2020-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug