relaton-cen 1.16.1 → 1.16.2

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: 2248f1f7fe9dd799b39377fdfd075fda4dc79ef9389a05e398a8f514c639619d
4
+ data.tar.gz: 7b88f2fbcc7d1041659dfe82f0344159734a014cb982bfeb046bcb3b55be5d45
5
5
  SHA512:
6
- metadata.gz: ae0b06db552199faef6afda209aa35918b4b486a04e8979c4554527443ac29122e4c6dcb0597e6438898a4dbda24596e7ea436b4810e4becd57eda9415b23e5b
7
- data.tar.gz: 7a7644ba895afbfe99c9b5601a1cff601ebd7ee00f5ff842507d3f36f2ecd3ae53ecf054c162ac7d852ad435536997df827040604b15fa5f1f7039bb04b024fb
6
+ metadata.gz: 9f3725d5b38db4229ec1c84a2a4033ef62a1c506cb07bec2f4059620ca74135fc1f58011017b4d7424ebae35c5a027cf3ef2ccb6ad1f276645aa35d434102985
7
+ data.tar.gz: e4cd2809857e01da01a4f5ff703ea1aeb215e3d3a5396564883df0001c2f5e37c78606c4c837824a4aab13999f757bc831c2d063dfe81add6e957d9fcd1d45b6
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])
@@ -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.2"
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.2
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