relaton-bsi 1.9.2 → 1.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/lib/relaton_bsi/bsi_bibliography.rb +17 -12
- data/lib/relaton_bsi/hit_collection.rb +4 -5
- data/lib/relaton_bsi/scrapper.rb +1 -1
- data/lib/relaton_bsi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 575d3bddb3ae25f1eb02722c22b2828078dcfbdda026f1880cb9267f7063fe02
|
|
4
|
+
data.tar.gz: 9acb554596e76d303396f3ee3ca363a90debaf796e056d30a7a7cec1666c35d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97419068d0508756a60da761bfb2caa436959ccfc4939052149ee951d781ee74b1b5a401796e591ec54a94974365a1b2560ce77fd91f0e0704f903ef21d0dd67
|
|
7
|
+
data.tar.gz: 016d70fee73a215b58cc53b8101fa4c70b21e30a6229f727524a3604eaa838b9a2dc1c88493ec1f2a1992a45a8161ebcdf4a5e7103822ca3f44ed21a0549b5fb
|
data/.rubocop.yml
CHANGED
|
@@ -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
|
|
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 = {})
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
50
|
-
|
|
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
|
|
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
|
|
57
|
-
# "use \"#{code} (all parts)\".\nIf the document
|
|
58
|
-
# "use its document type abbreviation (TS, TR,
|
|
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]
|
|
@@ -28,11 +26,12 @@ 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].sub(/\sLOOSELEAF|\s\(A5 LAMINATED\)/, "")
|
|
33
32
|
Hit.new(
|
|
34
33
|
{
|
|
35
|
-
code:
|
|
34
|
+
code: code,
|
|
36
35
|
title: h[:title],
|
|
37
36
|
url: h[:handle],
|
|
38
37
|
date: h[:meta][:global][:publishedDate],
|
|
@@ -42,7 +41,7 @@ module RelatonBsi
|
|
|
42
41
|
doctype: h[:product_type],
|
|
43
42
|
}, self
|
|
44
43
|
)
|
|
45
|
-
end
|
|
44
|
+
end.sort_by { |h| h.hit[:date] }.reverse
|
|
46
45
|
end
|
|
47
46
|
end
|
|
48
47
|
end
|
data/lib/relaton_bsi/scrapper.rb
CHANGED
|
@@ -118,7 +118,7 @@ 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
123
|
if data.any? && data["variants"]["edges"][0]["node"]["isbn"]
|
|
124
124
|
isbn = data["variants"]["edges"][0]["node"]["isbn"]["value"]
|
data/lib/relaton_bsi/version.rb
CHANGED
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
|
+
version: 1.9.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: 2021-
|
|
11
|
+
date: 2021-12-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: equivalent-xml
|