relaton-bsi 1.9.0 → 1.9.4

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: 7956b847d798601ca7e8d1f0d08ad59ff0904f9b8319bfff428a3365f686af67
4
- data.tar.gz: 4b33279c2c90e6be9cf718fd4770de6ca067d7a890b018b61350f0a3f644b92e
3
+ metadata.gz: e2749b7966d113cba9dc0cbd432b8f9d072c325397fd41c299425b19446570ea
4
+ data.tar.gz: 66649bac24670c82a3089b52e0466f149d3b790ba4ec6686bc3b67917f6d329c
5
5
  SHA512:
6
- metadata.gz: f93174899ac9ad8ae5462c127dfee8213703a1721d660875e4d3e548134b3001dbc7756f607f2923d2583979a1a8c416c90d741903be125ac36e3a20ca197918
7
- data.tar.gz: 285774c1eee290f9fb18af06b9f256bd80357c8ceef98189eb9c5fc022850809bc87e6efdb60ecd46ad083703b5850f8de7aa35184c0c4645beca31ac8b44090
6
+ metadata.gz: 4dcd33e8c4bf049237e3ca184c399c9d3f2f4cfb7ae3c9561ace6eecc03047fadab5268ba34ee382c4572e211740ea2b7b9142d7082148a3276fbc0b8ed9ca63
7
+ data.tar.gz: 8346013400a2ebe7ed52a1982a792dc0502834dfb3097ecfa9ad9d3dc7f3a5d308cb94a15ebea2cf3988929e09534d2e1ecde846f1e84a46902bc194e96a96a5
data/.rubocop.yml CHANGED
@@ -2,6 +2,8 @@
2
2
  # https://github.com/riboseinc/oss-guides
3
3
  # All project-specific additions and overrides should be specified in this file.
4
4
 
5
+ require: rubocop-rails
6
+
5
7
  inherit_from:
6
8
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
7
9
  AllCops:
data/README.adoc CHANGED
@@ -94,6 +94,16 @@ item.to_xml
94
94
  </bibitem>"
95
95
  ----
96
96
 
97
+ === Typed links
98
+
99
+ Each BSI document has `src` type link.
100
+
101
+ [source,ruby]
102
+ ----
103
+ item.link
104
+ => [#<RelatonBib::TypedUri:0x00007fc02a152768 @content=#<Addressable::URI:0x576c URI:https://shop.bsigroup.com/products/small-craft-remote-mechanical-steering-systems>, @type="src">]
105
+ ----
106
+
97
107
  With `bibdata: true` option XML output wrapped with `bibdata` element and `ext` element added.
98
108
  [source,ruby]
99
109
  ----
@@ -114,11 +124,10 @@ item.to_xml bibdata: true
114
124
  </bibdata>"
115
125
  ----
116
126
 
117
- === Get code, and year
127
+ === Get standard by code and year
118
128
  [source,ruby]
119
129
  ----
120
- RelatonBsi::BsiBibliographicItem RelatonBsi::BsiBibliography
121
- [7] pry(main)> RelatonBsi::BsiBibliography.get "BS EN ISO 8848:2021"
130
+ RelatonBsi::BsiBibliography.get "BS EN ISO 8848:2021"
122
131
  [relaton-bsi] ("BS EN ISO 8848:2021") fetching...
123
132
  [relaton-bsi] ("BS EN ISO 8848:2021") found BS EN ISO 8848:2021
124
133
  => #<RelatonBsi::BsiBibliographicItem:0x007feb14814ca8
@@ -24,17 +24,21 @@ module RelatonBsi
24
24
  raise RelatonBib::RequestError, e.message
25
25
  end
26
26
 
27
+ #
27
28
  # @param code [String] the BSI standard Code to look up
28
29
  # @param year [String] the year the standard was published (optional)
29
- # @param opts [Hash] options; restricted to :all_parts if all-parts reference is required
30
+ # @param opts [Hash] options
31
+ # @option opts [Boolean] :all_parts if all-parts reference is required
32
+ # @option opts [Boolean] :no_year if last published document is required
33
+ #
30
34
  # @return [String] Relaton XML serialisation of reference
31
- def get(code, year = nil, opts = {}) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
32
- c, y = code.split ':'
35
+ def get(code, year = nil, opts = {})
36
+ c, y = code.split ":"
33
37
  year ||= y
34
38
  ret = bib_get1(c, year, opts)
35
39
  return nil if ret.nil?
36
40
 
37
- # ret = ret.to_most_recent_reference unless year || opts[:keep_year]
41
+ ret = ret.to_most_recent_reference unless year || opts[:keep_year]
38
42
  # ret = ret.to_all_parts if opts[:all_parts]
39
43
  ret
40
44
  end
@@ -44,18 +48,19 @@ module RelatonBsi
44
48
  def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
45
49
  id = year ? "#{code}:#{year}" : code
46
50
  warn "[relaton-bsi] WARNING: no match found online for #{id}. "\
47
- "The code must be exactly like it is on the standards website."
51
+ "The code must be exactly like it is on the standards website."
48
52
  unless missed_years.empty?
49
- warn "[relaton-bsi] (There was no match for #{year}, though there were matches "\
50
- "found for #{missed_years.join(', ')}.)"
53
+ warn "[relaton-bsi] (There was no match for #{year}, though there "\
54
+ "were matches found for #{missed_years.join(', ')}.)"
51
55
  end
52
56
  # if /\d-\d/.match? code
53
- # warn "[relaton-bsi] The provided document part may not exist, or the document "\
54
- # "may no longer be published in parts."
57
+ # warn "[relaton-bsi] The provided document part may not exist, or "\
58
+ # "the document may no longer be published in parts."
55
59
  # else
56
- # warn "[relaton-bsi] If you wanted to cite all document parts for the reference, "\
57
- # "use \"#{code} (all parts)\".\nIf the document is not a standard, "\
58
- # "use its document type abbreviation (TS, TR, PAS, Guide)."
60
+ # warn "[relaton-bsi] If you wanted to cite all document parts for "\
61
+ # "the reference, use \"#{code} (all parts)\".\nIf the document "\
62
+ # "is not a standard, use its document type abbreviation (TS, TR, "\
63
+ # "PAS, Guide)."
59
64
  # end
60
65
  nil
61
66
  end
@@ -8,8 +8,6 @@ module RelatonBsi
8
8
  class HitCollection < RelatonBib::HitCollection
9
9
  DOMAIN = "https://shop.bsigroup.com"
10
10
 
11
- # @return [Mechanize]
12
- # attr_reader :agent
13
11
 
14
12
  # @param ref [String]
15
13
  # @param year [String]
@@ -20,7 +18,7 @@ module RelatonBsi
20
18
  config = Algolia::Search::Config.new(application_id: "575YE157G9", api_key: "a057b4e74099445df2eddb7940828a10")
21
19
  client = Algolia::Search::Client.new config, logger: ::Logger.new($stderr)
22
20
  index = client.init_index "shopify_products"
23
- resp = index.search text, facetFilters: "product_type:standard"
21
+ resp = index.search text # , facetFilters: "product_type:standard"
24
22
  @array = hits resp[:hits]
25
23
  end
26
24
 
@@ -28,11 +26,13 @@ module RelatonBsi
28
26
 
29
27
  # @param hits [Array<Hash>]
30
28
  # @return [Array<RelatonBsi::Hit>]
31
- def hits(hits) # rubocop:disable Metrics/MethodLength
29
+ def hits(hits) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
32
30
  hits.map do |h|
31
+ code = h[:meta][:global][:primaryDesignator]
32
+ .sub(/\s(?:LOOSELEAF|\(A5 LAMINATED\)|-\sTC$)/, "")
33
33
  Hit.new(
34
34
  {
35
- code: h[:meta][:global][:primaryDesignator],
35
+ code: code,
36
36
  title: h[:title],
37
37
  url: h[:handle],
38
38
  date: h[:meta][:global][:publishedDate],
@@ -42,7 +42,7 @@ module RelatonBsi
42
42
  doctype: h[:product_type],
43
43
  }, self
44
44
  )
45
- end
45
+ end.sort_by { |h| h.hit[:date] }.reverse
46
46
  end
47
47
  end
48
48
  end
@@ -118,9 +118,9 @@ module RelatonBsi
118
118
  # @param docid [String]
119
119
  # @param data [Hash]
120
120
  # @return [Array<RelatonBib::DocumentIdentifier>]
121
- def fetch_docid(docid, data)
121
+ def fetch_docid(docid, data) # rubocop:disable Metrics/AbcSize
122
122
  ids = [{ type: "BSI", id: docid }]
123
- if data.any?
123
+ if data.any? && data["variants"]["edges"][0]["node"]["isbn"]
124
124
  isbn = data["variants"]["edges"][0]["node"]["isbn"]["value"]
125
125
  ids << { type: "ISBN", id: isbn }
126
126
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonBsi
4
- VERSION = "1.9.0"
4
+ VERSION = "1.9.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-bsi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-26 00:00:00.000000000 Z
11
+ date: 2021-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml