relaton-iso 1.0.3 → 1.2.1

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: b085bd68fb134686bce61bdbb540360ebd52c6f3d7382db66a38b8b05f2e60b8
4
- data.tar.gz: 9c4c0858b18d5da5b45ee552b0489f881adcb7c944fc6817d2c6a378d0de371f
3
+ metadata.gz: 9e3b6cecb41e4d2c51cecad3b906e25fc1202ff2f9d69261d23a199c9084f0d8
4
+ data.tar.gz: 8a3f4c0a7857ef1c8668b1c1624f22573817b333a6bc674a77d729f2034098d9
5
5
  SHA512:
6
- metadata.gz: 3c6aac2f294c40fc3d8d946d9462e75e6784f593a9734ce6f8f2378a404fe07acbd4bc148d87db1d7e51fb3b460deb1a944d3894cd97ef1e58a0b6850dde6272
7
- data.tar.gz: efdc6acaaaa21d6c1b1354d8c7ff36fc327618edb47f58071e36a277f814f077c414da74c0c7c744bd564f75404fbc65f1d3367342a7cd098f7a5d3e1d4cf4c7
6
+ metadata.gz: 379e71ee50015f6ee0d012f3f157c1a355d5a69a670f3ed2a6dc7be6dafd86b4376808c8263f15c8deea3c85617ed7368dee72770c5d13e3f6e8948a1bfd9cea
7
+ data.tar.gz: d66f8ede9750f437adbc36682c4ae591ea800f887c8df54d36ea48f57ee1a09cd98e6e4b1b22dfc8653afdef2a29d7cf678782d41600110fca1e59e5074c77cc
@@ -5,6 +5,6 @@
5
5
  inherit_from:
6
6
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
7
7
  AllCops:
8
- TargetRubyVersion: 2.3
8
+ TargetRubyVersion: 2.4
9
9
  Rails:
10
- Enabled: true
10
+ Enabled: false
@@ -38,9 +38,10 @@ module RelatonIso
38
38
 
39
39
  if year.nil?
40
40
  /^(?<code1>[^\s]+(\s\w+)?\s[\d-]+)(:(?<year1>\d{4}))?(?<code2>\s\w+)?/ =~ code
41
+ /:(?<year2>\d{4})/ =~ corr
41
42
  unless code1.nil?
42
43
  code = code1 + code2.to_s
43
- year = year1
44
+ year = year2 || year1
44
45
  end
45
46
  end
46
47
  opts[:all_parts] ||= code !~ %r{^[^\s]+\s\d+-\d+} && opts[:all_parts].nil? && code2.nil?
@@ -145,7 +146,7 @@ module RelatonIso
145
146
  def isobib_results_filter(result, year, opts)
146
147
  missed_years = []
147
148
  hits = result.reduce!([]) do |hts, h|
148
- if !year || %r{:(?<iyear>\d{4})} =~ h.hit["docRef"] && iyear == year
149
+ if !year || %r{:(?<iyear>\d{4})(?!.*:\d{4})} =~ h.hit["docRef"] && iyear == year
149
150
  hts << h
150
151
  else
151
152
  missed_years << iyear
@@ -33,7 +33,21 @@ module RelatonIso
33
33
  "40" => "DIS",
34
34
  "50" => "FDIS",
35
35
  "60" => { "00" => "PRF", "60" => "FINAL" },
36
- }
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
37
51
 
38
52
  class << self
39
53
  # Parse page.
@@ -90,7 +104,7 @@ module RelatonIso
90
104
  d = l[:path] ? get_page(l[:path])[0] : doc
91
105
  unless d.at("//h5[@class='help-block'][.='недоступно на русском языке']")
92
106
  s << l
93
- titles << fetch_title(d, l[:lang])
107
+ titles += fetch_title(d, l[:lang])
94
108
 
95
109
  # Fetch abstracts.
96
110
  abstract_content = d.css("div[itemprop='description'] p").text
@@ -273,12 +287,14 @@ module RelatonIso
273
287
  # Fetch titles.
274
288
  # @param doc [Nokogiri::HTML::Document]
275
289
  # @param lang [String]
276
- # @return [Hash]
290
+ # @return [Array<RelatonBib::TypedTitleString>]
277
291
  def fetch_title(doc, lang)
278
292
  content = doc.at(
279
- "//nav[contains(@class,'eading-condensed')]/h2 | //nav[contains(@class,'eading-condensed')]/h3",
280
- )&.text
281
- RelatonIsoBib::HashConverter.split_title content, lang, script(lang)
293
+ "//nav[contains(@class,'heading-condensed')]/h2 | //nav[contains(@class,'heading-condensed')]/h3",
294
+ )&.text&.gsub(/\u2014/, "-")
295
+ return [] unless content
296
+
297
+ RelatonBib::TypedTitleString.from_string content, lang, script(lang)
282
298
  end
283
299
 
284
300
  # Return ISO script code.
@@ -320,17 +336,12 @@ module RelatonIso
320
336
  end
321
337
 
322
338
  def fetch_contributors(ref)
323
- ref.sub(/\s.*/, "").split("/").map do |abbrev|
324
- case abbrev
325
- when "IEC"
326
- name = "International Electrotechnical Commission"
327
- url = "www.iec.ch"
328
- else
329
- name = "International Organization for Standardization"
330
- url = "www.iso.org"
331
- end
332
- { entity: { name: name, url: url, abbreviation: abbrev },
333
- role: [type: "publisher"] }
339
+ ref.sub(/\s.*/, "").split("/").reduce([]) do |mem, abbrev|
340
+ publisher = PUBLISHERS[abbrev]
341
+ next mem unless publisher
342
+
343
+ publisher[:abbreviation] = abbrev
344
+ mem << { entity: publisher, role: [type: "publisher"] }
334
345
  end
335
346
  end
336
347
  # rubocop:enable Metrics/MethodLength
@@ -364,14 +375,14 @@ module RelatonIso
364
375
  # Fetch copyright.
365
376
  # @param ref [String]
366
377
  # @param doc [Nokogiri::HTML::Document]
367
- # @return [Hash]
378
+ # @return [Array<Hash>]
368
379
  def fetch_copyright(ref, doc)
369
380
  owner_name = ref.match(/.*?(?=\s)/).to_s
370
381
  from = ref.match(/(?<=:)\d{4}/).to_s
371
382
  if from.empty?
372
383
  from = doc.xpath("//span[@itemprop='releaseDate']").text.match(/\d{4}/).to_s
373
384
  end
374
- { owner: { name: owner_name }, from: from }
385
+ [{ owner: [{ name: owner_name }], from: from }]
375
386
  end
376
387
  end
377
388
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonIso
4
- VERSION = "1.0.3"
4
+ VERSION = "1.2.1"
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.1"
41
- spec.add_dependency "relaton-iso-bib", ">= 1.0.1"
40
+ spec.add_dependency "relaton-iec", "~> 1.2.0"
41
+ spec.add_dependency "relaton-iso-bib", "~> 1.2.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.3
4
+ version: 1.2.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-05-20 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -154,30 +154,30 @@ dependencies:
154
154
  name: relaton-iec
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">="
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 1.0.1
159
+ version: 1.2.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.1
166
+ version: 1.2.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.1
173
+ version: 1.2.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.1
180
+ version: 1.2.0
181
181
  description: 'RelatonIso: retrieve ISO Standards for bibliographic use using the IsoBibliographicItem
182
182
  model'
183
183
  email: