relaton-iso 1.0.1 → 1.1.0

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: 0cbed7056136ece40250512abb969807dbec09fc8ccf7f35c0630cf2bb505930
4
- data.tar.gz: f102924d725dbf89310e7b834cff58eea44e4bf394e8e32afa9b896dc6a49f3b
3
+ metadata.gz: 23dbce13e2b3ded9fbcca9cc7c9193fdf8bdec270fdf52b416652f334f8af593
4
+ data.tar.gz: bb3482b113d31b79c7050f0d2206cb3df3588f8ef1cc45e72721c9c2dfd50201
5
5
  SHA512:
6
- metadata.gz: 52e04fb0cc61407b669e0ad1cdc30220149efe16d72099ac97cca2503847e9d58e18cacd13703142a6bc654ce07c6d953e50640f9018849335b85782b700b840
7
- data.tar.gz: f54fc59412c41567637ab92df52dd528fd6c02e7699c5d89a9c385ea37c00e5fc8671581a46579580d467e6206b0f48782113f62a7a2bb163227ac3bc0bf349d
6
+ metadata.gz: a9bfbe60c42fb0ee0aee1e67c4b125715d3cad5ec9b52dfa87b1efb2484260ba768da03aabddc4794d28c2d18a840dc9f982eb28b1e41399f3166052806294d8
7
+ data.tar.gz: dd40529ac753e12996e0fc57abcf8b1bfa161059f726688ab0895f921cc8d65d3b6f224eb39a51081137b2338e0e891cc042d6cd470e2aa38195e53970bf6d63
@@ -12,7 +12,7 @@ module RelatonIso
12
12
  # @param text [String]
13
13
  # @return [RelatonIso::HitCollection]
14
14
  def search(text)
15
- HitCollection.new text
15
+ HitCollection.new text.gsub(/\u2013/, "-")
16
16
  rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
17
17
  EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
18
18
  Net::ProtocolError, OpenSSL::SSL::SSLError, Errno::ETIMEDOUT
@@ -26,15 +26,15 @@ module RelatonIso
26
26
  # return actual reference with year
27
27
  # @return [String] Relaton XML serialisation of reference
28
28
  def get(ref, year = nil, opts = {})
29
- opts[:ref] = ref
29
+ opts[:ref] = ref.gsub(/\u2013/, "-")
30
30
 
31
31
  %r{
32
32
  ^(?<code1>[^\s]+\s[^/]+) # match code
33
33
  /?
34
34
  (?<corr>(Amd|DAmd|(CD|WD|AWI|NP)\sAmd|Cor|CD\sCor|FDAmd|PRF\sAmd)\s\d+ # correction name
35
35
  :?(\d{4})?(/Cor\s\d+:\d{4})?) # match correction year
36
- }x =~ ref
37
- code = code1 || ref
36
+ }x =~ opts[:ref]
37
+ code = code1 || opts[:ref]
38
38
 
39
39
  if year.nil?
40
40
  /^(?<code1>[^\s]+(\s\w+)?\s[\d-]+)(:(?<year1>\d{4}))?(?<code2>\s\w+)?/ =~ code
@@ -25,6 +25,30 @@ module RelatonIso
25
25
  "Guide" => "guide",
26
26
  }.freeze
27
27
 
28
+ STGABBR = {
29
+ "00" => "NWIP",
30
+ "10" => "AWI",
31
+ "20" => "WD",
32
+ "30" => "CD",
33
+ "40" => "DIS",
34
+ "50" => "FDIS",
35
+ "60" => { "00" => "PRF", "60" => "FINAL" },
36
+ }.freeze
37
+
38
+ PUBLISHERS = {
39
+ "IEC" => { name: "International Electrotechnical Commission",
40
+ url: "www.iec.ch" },
41
+ "ISO" => { name: "International Organization for Standardization",
42
+ url: "www.iso.org" },
43
+ "IEEE" => { name: "Institute of Electrical and Electronics Engineers",
44
+ url: "www.ieee.org" },
45
+ "SAE" => { name: "SAE International", url: "www.sae.org" },
46
+ "CIE" => { name: " International Commission on Illumination",
47
+ url: "cie.co.at" },
48
+ "ASME" => { name: "American Society of Mechanical Engineers",
49
+ url: "www.asme.org" },
50
+ }.freeze
51
+
28
52
  class << self
29
53
  # Parse page.
30
54
  # @param hit_data [Hash]
@@ -176,10 +200,17 @@ module RelatonIso
176
200
  # @param status [String]
177
201
  # @return [Hash]
178
202
  def fetch_status(doc)
179
- stage, substage = doc.css("li.dropdown.active span.stage-code > strong").text.split "."
180
- RelatonBib::DocumentStatus.new(stage: stage, substage: substage)
203
+ stg, substg = doc.css(
204
+ "li.dropdown.active span.stage-code > strong",
205
+ ).text.split "."
206
+ RelatonBib::DocumentStatus.new(stage: stg, substage: substg)
181
207
  end
182
208
 
209
+ # def stage(stg, substg)
210
+ # abbr = STGABBR[stg].is_a?(Hash) ? STGABBR[stg][substg] : STGABBR[stg]
211
+ # RelatonBib::DocumentStatus::Stage.new value: stg, abbreviation: abbr
212
+ # end
213
+
183
214
  # Fetch workgroup.
184
215
  # @param doc [Nokogiri::HTML::Document]
185
216
  # @return [Hash]
@@ -303,17 +334,12 @@ module RelatonIso
303
334
  end
304
335
 
305
336
  def fetch_contributors(ref)
306
- ref.sub(/\s.*/, "").split("/").map do |abbrev|
307
- case abbrev
308
- when "IEC"
309
- name = "International Electrotechnical Commission"
310
- url = "www.iec.ch"
311
- else
312
- name = "International Organization for Standardization"
313
- url = "www.iso.org"
314
- end
315
- { entity: { name: name, url: url, abbreviation: abbrev },
316
- role: [type: "publisher"] }
337
+ ref.sub(/\s.*/, "").split("/").reduce([]) do |mem, abbrev|
338
+ publisher = PUBLISHERS[abbrev]
339
+ next mem unless publisher
340
+
341
+ publisher[:abbreviation] = abbrev
342
+ mem << { entity: publisher, role: [type: "publisher"] }
317
343
  end
318
344
  end
319
345
  # rubocop:enable Metrics/MethodLength
@@ -347,14 +373,14 @@ module RelatonIso
347
373
  # Fetch copyright.
348
374
  # @param ref [String]
349
375
  # @param doc [Nokogiri::HTML::Document]
350
- # @return [Hash]
376
+ # @return [Array<Hash>]
351
377
  def fetch_copyright(ref, doc)
352
378
  owner_name = ref.match(/.*?(?=\s)/).to_s
353
379
  from = ref.match(/(?<=:)\d{4}/).to_s
354
380
  if from.empty?
355
381
  from = doc.xpath("//span[@itemprop='releaseDate']").text.match(/\d{4}/).to_s
356
382
  end
357
- { owner: { name: owner_name }, from: from }
383
+ [{ owner: [{ name: owner_name }], from: from }]
358
384
  end
359
385
  end
360
386
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonIso
4
- VERSION = "1.0.1"
4
+ VERSION = "1.1.0"
5
5
  end
@@ -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", "~> 1.0.0"
41
- spec.add_dependency "relaton-iso-bib", "~> 1.0.0"
40
+ spec.add_dependency "relaton-iec", "~> 1.1.0"
41
+ spec.add_dependency "relaton-iso-bib", "~> 1.1.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: 1.0.1
4
+ version: 1.1.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-04-28 00:00:00.000000000 Z
11
+ date: 2020-06-03 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: 1.0.0
159
+ version: 1.1.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: 1.0.0
166
+ version: 1.1.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: 1.0.0
173
+ version: 1.1.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: 1.0.0
180
+ version: 1.1.0
181
181
  description: 'RelatonIso: retrieve ISO Standards for bibliographic use using the IsoBibliographicItem
182
182
  model'
183
183
  email: