relaton-cen 1.16.1 → 1.16.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: a64d7b3c77fcd73b38bc5ce62313141e51da3b0f784532b6ff10da1069a7c528
4
- data.tar.gz: 6186b2913635bc27fc7cf8ea86961985a809063dc36ca60d75a78976b89949b5
3
+ metadata.gz: 2536bccf8d4ddbd3215a965683a22eea51e8739ea65a45b3f41a5f46fb63a035
4
+ data.tar.gz: 148612cdbba0da00f7e81e34c3c79e038cb85cb6249ff9923b0dc7267acb9afb
5
5
  SHA512:
6
- metadata.gz: ae0b06db552199faef6afda209aa35918b4b486a04e8979c4554527443ac29122e4c6dcb0597e6438898a4dbda24596e7ea436b4810e4becd57eda9415b23e5b
7
- data.tar.gz: 7a7644ba895afbfe99c9b5601a1cff601ebd7ee00f5ff842507d3f36f2ecd3ae53ecf054c162ac7d852ad435536997df827040604b15fa5f1f7039bb04b024fb
6
+ metadata.gz: 9eb0ea3431e54f1b1aade2bb02153c24ac4b2a531cd29e246b7b7cd0caf0af999da18ec56a4ecac1d2a7c125ac8148731d0dc27ec65a58b876f8a719006af9ce
7
+ data.tar.gz: 56bf1b0df47893249c88a05547fe5c2048112079b32499a5c673979ff05cf2c7a54402cd533d58ad8c986302e26681c4c3f66fd2ea39c097993c977701c58e95
data/README.adoc CHANGED
@@ -52,18 +52,40 @@ item = hit_collection[0].fetch
52
52
 
53
53
  === Get a standard by its code
54
54
 
55
+ Use `RelatonCen::CenBibliography.get(ref, year, options)` to get a standard by its code.
56
+
57
+ - `ref` is the standard code, e.g. `CEN ISO/TS 21003-7`
58
+ - `year` is the year of the standard, e.g. `2019` (optional)
59
+ - `options` is a hash of options:
60
+ - `keep_year` - keep the year in ID if true (optional)
61
+
55
62
  [source,ruby]
56
63
  ----
64
+ # With year in reference
65
+ RelatonCen::CenBibliography.get "EN 10160:1999"
66
+ [relaton-cen] (EN 10160:1999) fetching...
67
+ [relaton-cen] (EN 10160:1999) found `EN 10160:1999`
68
+ => #<RelatonCen::BibliographicItem:0x0000000112d8b900
69
+ ...
70
+
71
+ # With a year as a separate argument
72
+ RelatonCen::CenBibliography.get "EN 10160", "1999"
73
+
74
+ # To get the most recent version of a standard by its code use reference without year
57
75
  > RelatonCen::CenBibliography.get "CEN/CLC Guide 6"
58
76
  [relaton-cen] (CEN/CLC Guide 6) fetching...
59
- [isoics] code   not found in ICS list
60
- [relaton-cen] (CEN/CLC Guide 6) `found CEN/CLC Guide 6`
61
- =>
62
- #<RelatonCen::BibliographicItem:0x000000011371cb90
63
- @abstract=
64
- [#<RelatonBib::FormattedString:0x000000011371c5f0
65
- @content=
66
- "ISO/IEC Guide 71:2014 provides guidance to standards..."
77
+ [isoics] code not found in ICS list
78
+ [relaton-cen] (CEN/CLC Guide 6) found `CEN/CLC Guide 6`
79
+ => #<RelatonCen::BibliographicItem:0x0000000112d81680
80
+ ...
81
+
82
+ # To keep the year in ID use `keep_year` option
83
+ > RelatonCen::CenBibliography.get "CEN/CLC Guide 6", nil, keep_year: true
84
+ [relaton-cen] (CEN/CLC Guide 6) fetching...
85
+ [isoics] code not found in ICS list
86
+ [relaton-cen] (CEN/CLC Guide 6) found `CEN/CLC Guide 6:2014`
87
+ => #<RelatonCen::BibliographicItem:0x0000000112d8b400
88
+ ...
67
89
  ----
68
90
 
69
91
  === XML serialization
@@ -13,11 +13,14 @@ module RelatonCen
13
13
  raise RelatonBib::RequestError, e.message
14
14
  end
15
15
 
16
+ #
16
17
  # @param code [String] the CEN standard Code to look up
17
18
  # @param year [String] the year the standard was published (optional)
18
- # @param opts [Hash] options; restricted to :all_parts if all-parts
19
- # reference is required
19
+ # @param opts [Hash] options
20
+ # @option opts [Boolean] :keep_year don't upate reference
21
+ #
20
22
  # @return [RelatonBib::BibliographicItem, nil]
23
+ #
21
24
  def get(code, year = nil, opts = {})
22
25
  code_parts = code_to_parts code
23
26
  year ||= code_parts[:year] if code_parts
@@ -64,9 +67,8 @@ module RelatonCen
64
67
 
65
68
  # @param code [String]
66
69
  # @return [RelatonCen::HitCollection]
67
- def search_filter(code) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
70
+ def search_filter(code) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
68
71
  parts = code_to_parts code
69
- warn "[relaton-cen] (\"#{code}\") fetching..."
70
72
  result = search(code)
71
73
  result.select do |i|
72
74
  pts = code_to_parts i.hit[:code]
@@ -97,12 +99,14 @@ module RelatonCen
97
99
  { years: missed_years }
98
100
  end
99
101
 
100
- def bib_get(code, year, _opts)
102
+ def bib_get(code, year, opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
103
+ ref = year.nil? || code.match?(/:\d{4}/) ? code : "#{code}:#{year}"
104
+ warn "[relaton-cen] (#{ref}) fetching..."
101
105
  result = search_filter(code) || return
102
106
  ret = isobib_results_filter(result, year)
103
107
  if ret[:ret]
104
- bib = year ? ret[:ret] : ret[:ret].to_most_recent_reference
105
- warn "[relaton-cen] (#{code}) found `#{bib.docidentifier.first&.id}`"
108
+ bib = year || opts[:keep_year] ? ret[:ret] : ret[:ret].to_most_recent_reference
109
+ warn "[relaton-cen] (#{ref}) found `#{bib.docidentifier.first&.id}`"
106
110
  bib
107
111
  else
108
112
  fetch_ref_err(code, year, ret[:years])
@@ -41,8 +41,11 @@ module RelatonCen
41
41
  # @param doc [Mechanize::Page]
42
42
  # @return [Array<RelatonIsobib::Ics>]
43
43
  def fetch_ics(doc)
44
- doc.xpath("//tr[th[.='ICS']]/td/text()").map do |ics|
45
- RelatonIsoBib::Ics.new ics.text.match(/[^\s]+/).to_s
44
+ doc.xpath("//tr[th[.='ICS']]/td/text()").filter_map do |ics|
45
+ ics_code = ics.text.match(/[^\s]+/).to_s.gsub("\u00A0", "")
46
+ next if ics_code.empty?
47
+
48
+ RelatonIsoBib::Ics.new ics_code
46
49
  end
47
50
  end
48
51
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonCen
4
- VERSION = "1.16.1"
4
+ VERSION = "1.16.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-cen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.1
4
+ version: 1.16.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: 2023-09-06 00:00:00.000000000 Z
11
+ date: 2023-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize