relaton-bsi 1.9.4 → 1.9.5

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: e2749b7966d113cba9dc0cbd432b8f9d072c325397fd41c299425b19446570ea
4
- data.tar.gz: 66649bac24670c82a3089b52e0466f149d3b790ba4ec6686bc3b67917f6d329c
3
+ metadata.gz: 9db2a5ff65039b9e7bbda2507f116444d0f0cccc7919da1e3be8d735c94d5324
4
+ data.tar.gz: 903b68e85f928546ae715b4c0f88cf602e31717d38a39e8f7455df8d4c03ef31
5
5
  SHA512:
6
- metadata.gz: 4dcd33e8c4bf049237e3ca184c399c9d3f2f4cfb7ae3c9561ace6eecc03047fadab5268ba34ee382c4572e211740ea2b7b9142d7082148a3276fbc0b8ed9ca63
7
- data.tar.gz: 8346013400a2ebe7ed52a1982a792dc0502834dfb3097ecfa9ad9d3dc7f3a5d308cb94a15ebea2cf3988929e09534d2e1ecde846f1e84a46902bc194e96a96a5
6
+ metadata.gz: bb7f32531e7aedc5eb0d6499a31cabe1d642809f8b7f324e44bd3ea3af9e751415eb1f06fdb0cf003a3499b543fa202a046e9fce54e16965f39e6ca36c1b4ffd
7
+ data.tar.gz: d943a7d57ab744e350eb56bd325b7df2e2ea86c513032899b208aa8e9600a0a48c22a76b6cb887885f85edceb545bbe018a855870312e18a15ebd973a03b006a
@@ -33,9 +33,9 @@ module RelatonBsi
33
33
  #
34
34
  # @return [String] Relaton XML serialisation of reference
35
35
  def get(code, year = nil, opts = {})
36
- c, y = code.split ":"
37
- year ||= y
38
- ret = bib_get1(c, year, opts)
36
+ # y = code.split(":")[1]
37
+ year ||= code_parts(code)[:year]
38
+ ret = bib_get1(code, year, opts)
39
39
  return nil if ret.nil?
40
40
 
41
41
  ret = ret.to_most_recent_reference unless year || opts[:keep_year]
@@ -66,18 +66,30 @@ module RelatonBsi
66
66
  end
67
67
 
68
68
  def search_filter(code) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
69
- # %r{^BSI\s(?<code1>[^:]+)} =~ code
70
- code1 = code.sub(/^BSI\s/, "")
69
+ # %r{^(?:BSI\s)?(?<code1>[^:]+)} =~ code
70
+ # %r{^(?<code1>[^:]+)} =~ code.sub(/^BSI\s/, "")
71
+ cp1 = code_parts code
71
72
  warn "[relaton-bsi] (\"#{code}\") fetching..."
72
- return [] unless code1
73
+ return [] unless cp1
73
74
 
74
75
  result = search(code)
75
76
  result.select do |i|
76
- %r{^(?<code2>[^:]+)} =~ i.hit[:code]
77
- code2.include?(code1)
77
+ # %r{^(?<code2>[^:]+)} =~ i.hit[:code]
78
+ cp2 = code_parts i.hit[:code]
79
+ cp2[:code] == cp1[:code] && (!cp1[:a] || cp2[:a] == cp1[:a]) &&
80
+ (!cp1[:y] || cp2[:y] == cp1[:y])
78
81
  end
79
82
  end
80
83
 
84
+ def code_parts(code)
85
+ %r{
86
+ ^(?:BSI\s)?(?<code>[^:]+)
87
+ (?::(?<year>\d{4}))?
88
+ (?:\+(?<a>[^:]+):)?
89
+ (?::(?<y>\d{4}))?
90
+ }x.match code
91
+ end
92
+
81
93
  # Sort through the results from Isobib, fetching them three at a time,
82
94
  # and return the first result that matches the code,
83
95
  # matches the year (if provided), and which # has a title (amendments do not).
@@ -8,14 +8,14 @@ module RelatonBsi
8
8
  class HitCollection < RelatonBib::HitCollection
9
9
  DOMAIN = "https://shop.bsigroup.com"
10
10
 
11
-
12
11
  # @param ref [String]
13
12
  # @param year [String]
14
13
  def initialize(ref, year = nil)
15
14
  super ref, year
16
- # @agent = Mechanize.new
17
- # resp = agent.get "#{DOMAIN}/SearchResults/?q=#{ref}"
18
- config = Algolia::Search::Config.new(application_id: "575YE157G9", api_key: "a057b4e74099445df2eddb7940828a10")
15
+ config = Algolia::Search::Config.new(
16
+ application_id: "575YE157G9",
17
+ api_key: "a057b4e74099445df2eddb7940828a10",
18
+ )
19
19
  client = Algolia::Search::Client.new config, logger: ::Logger.new($stderr)
20
20
  index = client.init_index "shopify_products"
21
21
  resp = index.search text # , facetFilters: "product_type:standard"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonBsi
4
- VERSION = "1.9.4"
4
+ VERSION = "1.9.5"
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.4
4
+ version: 1.9.5
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-12-30 00:00:00.000000000 Z
11
+ date: 2022-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml