relaton-cen 1.16.0 → 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: b5f0cd6a09da357f5ca19fe9d38430f7880d9b9658ee89bbcdf56a7c081342f1
4
- data.tar.gz: c3645683652f184f5d037de48065b3e31dc173e84230de6f00d1f253f607febf
3
+ metadata.gz: 2248f1f7fe9dd799b39377fdfd075fda4dc79ef9389a05e398a8f514c639619d
4
+ data.tar.gz: 7b88f2fbcc7d1041659dfe82f0344159734a014cb982bfeb046bcb3b55be5d45
5
5
  SHA512:
6
- metadata.gz: 71f1f8971c40519883ead3fcd2a436a05c7d3826be5d1e1e3d3eae3e7d095a4b2c549228e918c18eff2df744fa4bd61297ec78a6c8481624b5106165aa7e8213
7
- data.tar.gz: 13f632f4e026a41ebce994abbf3e9ca9505b51ecc551ed44bb325681427aae678305b7ed9b955db674dd6a8c3dc132971408060c51bf269262df33ad3b9f7248
6
+ metadata.gz: 9f3725d5b38db4229ec1c84a2a4033ef62a1c506cb07bec2f4059620ca74135fc1f58011017b4d7424ebae35c5a027cf3ef2ccb6ad1f276645aa35d434102985
7
+ data.tar.gz: e4cd2809857e01da01a4f5ff703ea1aeb215e3d3a5396564883df0001c2f5e37c78606c4c837824a4aab13999f757bc831c2d063dfe81add6e957d9fcd1d45b6
data/Gemfile CHANGED
@@ -14,5 +14,5 @@ gem "rubocop-performance", "~> 1.11.0"
14
14
  gem "rubocop-rails", "~> 2.10.0"
15
15
  gem "ruby-jing"
16
16
  gem "simplecov"
17
- gem "vcr", "~> 5.0.0"
18
- gem "webmock"
17
+ gem "vcr", "~> 6.2.0"
18
+ gem "webmock", "~> 3.19.0"
data/README.adoc CHANGED
@@ -33,6 +33,8 @@ $ gem install relaton-cen
33
33
 
34
34
  == Usage
35
35
 
36
+ For CENELEC standards, use references with the prefix `CEN/CLC`. For example, `CEN/CLC Guide 6`.
37
+
36
38
  === Search for a standard using keywords
37
39
 
38
40
  [source,ruby]
@@ -48,18 +50,42 @@ item = hit_collection[0].fetch
48
50
  ...
49
51
  ----
50
52
 
53
+ === Get a standard by its code
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
+
51
62
  [source,ruby]
52
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
53
75
  > RelatonCen::CenBibliography.get "CEN/CLC Guide 6"
54
- [relaton-cen] ("CEN/CLC Guide 6") fetching...
55
- [isoics] code   not found in ICS list
56
- [relaton-cen] ("CEN/CLC Guide 6") found CEN/CLC Guide 6:2014
57
- =>
58
- #<RelatonCen::BibliographicItem:0x000000011371cb90
59
- @abstract=
60
- [#<RelatonBib::FormattedString:0x000000011371c5f0
61
- @content=
62
- "ISO/IEC Guide 71:2014 provides guidance to standards..."
76
+ [relaton-cen] (CEN/CLC Guide 6) fetching...
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
+ ...
63
89
  ----
64
90
 
65
91
  === XML serialization
@@ -106,14 +132,14 @@ item.link
106
132
  [source,ruby]
107
133
  ----
108
134
  RelatonCen::CenBibliography.get "CEN ISO/TS 21003-7:2019"
109
- [relaton-cen] ("CEN ISO/TS 21003-7") fetching...
110
- [relaton-cen] ("CEN ISO/TS 21003-7") found CEN ISO/TS 21003-7:2019
135
+ [relaton-cen] (CEN ISO/TS 21003-7) fetching...
136
+ [relaton-cen] (CEN ISO/TS 21003-7) found CEN `ISO/TS 21003-7:2019`
111
137
  => #<RelatonIsoBib::IsoBibliographicItem:0x00007fadcd596c58
112
138
  ...
113
139
 
114
140
  RelatonCen::CenBibliography.get "CEN ISO/TS 21003-7", "2019"
115
- [relaton-cen] ("CEN ISO/TS 21003-7") fetching...
116
- [relaton-cen] ("CEN ISO/TS 21003-7") found CEN ISO/TS 21003-7:2019
141
+ [relaton-cen] (CEN ISO/TS 21003-7) fetching...
142
+ [relaton-cen] (CEN ISO/TS 21003-7) found CEN `ISO/TS 21003-7:2019`
117
143
  => #<RelatonIsoBib::IsoBibliographicItem:0x00007fadcd5df9f8
118
144
  ...
119
145
  ----
@@ -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,15 @@ 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
- warn "[relaton-cen] (\"#{code}\") found #{ret[:ret].docidentifier.first&.id}"
105
- ret[:ret]
108
+ bib = year || opts[:keep_year] ? ret[:ret] : ret[:ret].to_most_recent_reference
109
+ warn "[relaton-cen] (#{ref}) found `#{bib.docidentifier.first&.id}`"
110
+ bib
106
111
  else
107
112
  fetch_ref_err(code, year, ret[:years])
108
113
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonCen
4
- VERSION = "1.16.0"
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.0
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-03 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