relaton-iec 1.7.2 → 1.7.3

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: 157261e9f755e3f373aa9bc025389029f4b069519d7ab4842ea41d3c9a9e19ce
4
- data.tar.gz: 89f46eb034143a119e842677074058db9a684eacef09dc4c5b42ec8670f1636f
3
+ metadata.gz: 3398e512749f7c734e53ea2538e6b39ad87d95c175a35dc339b604e20d674ca4
4
+ data.tar.gz: 7414e6addf0ffc4cc87ff8c9a1fead896b386399d3c33a87602e8cef376cf6c6
5
5
  SHA512:
6
- metadata.gz: ecc69a778b11e14465ef0c1827eb038d22fee208f8920772670d95bb48c62d656179871bf47ef6ef4b7a3615ea997349eeee819bd0bd585133c8c3b794afa737
7
- data.tar.gz: 74c0e6583725319b9a45429f5cbb9bc7c6434a830268215e243029a3334516854cce54b28229e6797361665bb79da9d42a994bd62cd331710987bb3d46c86244
6
+ metadata.gz: e60740affa737419167ff5c6fbdaefa4baa53d152a0e92662786bf86ca20fba6dbfeb6c822eaa0f32bd9d24314f80f999e4008ea7117130d6120a7aef05ea2a9
7
+ data.tar.gz: 4f02935efb8932622d86f70a501a4aeafef0b990362bc0f291e816d29f2c5b6fe9b65198f97378d7906409a34a12853b0b53bda240860228c2251ff1c837ecb8
@@ -51,7 +51,10 @@ module RelatonIec
51
51
  # @return [Array<RelatonIec::Hit>]
52
52
  def results(uri, part)
53
53
  contains = "[contains(.,'Part #{part}:')]" if part
54
- Nokogiri::HTML(OpenURI.open_uri(uri)).xpath(
54
+ resp = OpenURI.open_uri(uri, "User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) "\
55
+ "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36")
56
+ doc = Nokogiri::HTML(resp)
57
+ doc.xpath(
55
58
  "//body/li#{contains}",
56
59
  "//ul[contains(@class,'search-results')]/li#{contains}",
57
60
  "//ul[contains(@class,'morethesame')]/li#{contains}"
@@ -85,10 +85,16 @@ module RelatonIec
85
85
  workers.result.sort_by { |a| a[:i] }.map { |x| x[:hit] }
86
86
  end
87
87
 
88
- def isobib_search_filter(code, year) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
89
- docidrx = %r{^(ISO|IEC)[^0-9]*\s[0-9-]+}
90
- corrigrx = %r{^(ISO|IEC)[^0-9]*\s[0-9-]+:[0-9]+/}
91
- warn "[relaton-iec] (\"#{code}\") fetching..."
88
+ def isobib_search_filter(reference, year, opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
89
+ %r{
90
+ ^(?<code>(?:ISO|IEC)[^\d]*\s[\d-]+\w?)
91
+ (:(?<year1>\d{4}))?
92
+ (?<bundle>\+[^\s\/]+)?
93
+ (\/(?<corr>AMD\s\d+))?
94
+ }x =~ reference.upcase
95
+ year ||= year1
96
+ corr&.sub! " ", ""
97
+ warn "[relaton-iec] (\"#{reference}\") fetching..."
92
98
  result = search(code, year)
93
99
  if result.empty? && /(?<=-)(?<part>\d+)/ =~ code
94
100
  # try to search packaged standard
@@ -97,9 +103,16 @@ module RelatonIec
97
103
  else ref = code
98
104
  end
99
105
  result.select do |i|
100
- i.hit[:code] &&
101
- i.hit[:code].match(docidrx).to_s.include?(ref) &&
102
- corrigrx !~ i.hit[:code]
106
+ %r{
107
+ ^(?<code2>(?:ISO|IEC)[^\d]*\s\d+(-\w+)?)
108
+ (:(?<year2>\d{4}))?
109
+ (?<bundle2>\+[^\s\/]+)?
110
+ (\/(?<corr2>AMD\d+))?
111
+ }x =~ i.hit[:code]
112
+ code2.sub! /(?<=-\d)\w*/, "" if part
113
+ code2.sub! /-\d+\w*/, "" if opts[:all_parts]
114
+ ref == code2 && (year.nil? || year == year2) && bundle == bundle2 &&
115
+ corr == corr2
103
116
  end
104
117
  end
105
118
 
@@ -160,10 +173,10 @@ module RelatonIec
160
173
  { years: missed_years }
161
174
  end
162
175
 
163
- def iecbib_get1(code, year, _opts)
176
+ def iecbib_get1(code, year, opts)
164
177
  return iev if code.casecmp("IEV").zero?
165
178
 
166
- result = isobib_search_filter(code, year) || return
179
+ result = isobib_search_filter(code, year, opts) || return
167
180
  ret = isobib_results_filter(result, year)
168
181
  if ret[:ret]
169
182
  warn "[relaton-iec] (\"#{code}\") found "\
@@ -172,6 +172,8 @@ module RelatonIec
172
172
  if wip
173
173
  statuses = YAML.load_file File.join __dir__, "statuses.yml"
174
174
  s = wip.at("STAGE").text
175
+ return unless statuses[s]
176
+
175
177
  stage, substage = statuses[s]["stage"].split "."
176
178
  else
177
179
  stage = "60"
@@ -1,3 +1,3 @@
1
1
  module RelatonIec
2
- VERSION = "1.7.2".freeze
2
+ VERSION = "1.7.3".freeze
3
3
  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: 1.7.2
4
+ version: 1.7.3
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-12-01 00:00:00.000000000 Z
11
+ date: 2020-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase