relaton-gb 1.16.0 → 1.16.1
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/lib/relaton_gb/config.rb +10 -0
- data/lib/relaton_gb/gb_bibliographic_item.rb +0 -2
- data/lib/relaton_gb/gb_bibliography.rb +15 -15
- data/lib/relaton_gb/util.rb +9 -0
- data/lib/relaton_gb/version.rb +1 -1
- data/lib/relaton_gb.rb +9 -5
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9abe3c75ca613bc38c155fd5f116ecd967b06eecd7abc78610b498f107d6ec8f
|
|
4
|
+
data.tar.gz: a01b3c0b36e744d4518a54c2e41576a3c87a996468ff17b19a7981c5ed1a058d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f10cfd40d9314992bae8b704118d53b519ce1c5f2145139e61f816559f28adbc17703a34e02556af92694e99f5b78371d6fbcea2732d3d3556d181dc7876d811
|
|
7
|
+
data.tar.gz: f6373a69761f186b254ef5dfacbee6f195143b6cf522dc2da06a9667a4bfd4df90be3ac001de734034655b48072ab7dbca632f73f77ebf2fe196f19ff8a081d2
|
|
@@ -42,7 +42,7 @@ module RelatonGb
|
|
|
42
42
|
# @param year [String] the year the standard was published (optional)
|
|
43
43
|
# @param opts [Hash] options; restricted to :all_parts if all-parts reference is required
|
|
44
44
|
# @return [String] Relaton XML serialisation of reference
|
|
45
|
-
def get(code, year = nil, opts = {})
|
|
45
|
+
def get(code, year = nil, opts = {}) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
|
46
46
|
if year.nil?
|
|
47
47
|
/^(?<code1>[^-]+)-(?<year1>[^-]+)$/ =~ code
|
|
48
48
|
unless code1.nil?
|
|
@@ -52,7 +52,7 @@ module RelatonGb
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
code += ".1" if opts[:all_parts]
|
|
55
|
-
code, year = code.split(
|
|
55
|
+
code, year = code.split("-", 2) if code.include?("-")
|
|
56
56
|
ret = get1(code, year, opts)
|
|
57
57
|
return nil if ret.nil?
|
|
58
58
|
|
|
@@ -63,22 +63,22 @@ module RelatonGb
|
|
|
63
63
|
|
|
64
64
|
private
|
|
65
65
|
|
|
66
|
-
def fetch_ref_err(code, year, missed_years)
|
|
66
|
+
def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
|
|
67
67
|
id = year ? "#{code}:#{year}" : code
|
|
68
|
-
warn "
|
|
69
|
-
|
|
68
|
+
Util.warn "WARNING: no match found on the GB website for `#{id}`. " \
|
|
69
|
+
"The code must be exactly like it is on the website."
|
|
70
70
|
unless missed_years.empty?
|
|
71
|
-
warn "
|
|
72
|
-
|
|
71
|
+
Util.warn "(There was no match for `#{year}`, though there " \
|
|
72
|
+
"were matches found for `#{missed_years.join('`, `')}`.)"
|
|
73
73
|
end
|
|
74
74
|
if /\d-\d/.match? code
|
|
75
|
-
warn "
|
|
76
|
-
|
|
75
|
+
Util.warn "The provided document part may not exist, or " \
|
|
76
|
+
"the document may no longer be published in parts."
|
|
77
77
|
else
|
|
78
|
-
warn "
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
Util.warn "If you wanted to cite all document parts for the " \
|
|
79
|
+
"reference, use `#{code} (all parts)`.\nIf the document " \
|
|
80
|
+
"is not a standard, use its document type abbreviation " \
|
|
81
|
+
"(TS, TR, PAS, Guide)."
|
|
82
82
|
end
|
|
83
83
|
nil
|
|
84
84
|
end
|
|
@@ -89,7 +89,7 @@ module RelatonGb
|
|
|
89
89
|
result = search_filter(searchcode) || return
|
|
90
90
|
ret = results_filter(result, year)
|
|
91
91
|
if ret[:ret]
|
|
92
|
-
warn "
|
|
92
|
+
Util.warn "(#{code}) found `#{ret[:ret].docidentifier.first.id}`"
|
|
93
93
|
ret[:ret]
|
|
94
94
|
else
|
|
95
95
|
fetch_ref_err(code, year, ret[:years])
|
|
@@ -99,7 +99,7 @@ module RelatonGb
|
|
|
99
99
|
def search_filter(code)
|
|
100
100
|
# search filter needs to incorporate year
|
|
101
101
|
docidrx = %r{^[^\s]+\s[\d.-]+}
|
|
102
|
-
warn "
|
|
102
|
+
Util.warn "(#{code}) fetching..."
|
|
103
103
|
result = search(code)
|
|
104
104
|
result.select do |hit|
|
|
105
105
|
hit.docref && hit.docref.match(docidrx).to_s.include?(code)
|
data/lib/relaton_gb/version.rb
CHANGED
data/lib/relaton_gb.rb
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
require "digest/md5"
|
|
2
|
+
require "relaton_iso_bib"
|
|
3
|
+
require "cnccs"
|
|
1
4
|
require "relaton_gb/version"
|
|
5
|
+
require "relaton_gb/config"
|
|
6
|
+
require "relaton_gb/util"
|
|
2
7
|
require "relaton_gb/gb_bibliography"
|
|
3
|
-
require "digest/md5"
|
|
4
8
|
|
|
5
9
|
# if defined? Relaton
|
|
6
10
|
# require "relaton_gb/processor"
|
|
@@ -14,9 +18,9 @@ module RelatonGb
|
|
|
14
18
|
# Returns hash of XML reammar
|
|
15
19
|
# @return [String]
|
|
16
20
|
def self.grammar_hash
|
|
17
|
-
gem_path = File.expand_path "..", __dir__
|
|
18
|
-
grammars_path = File.join gem_path, "grammars", "*"
|
|
19
|
-
grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
|
20
|
-
Digest::MD5.hexdigest grammars
|
|
21
|
+
# gem_path = File.expand_path "..", __dir__
|
|
22
|
+
# grammars_path = File.join gem_path, "grammars", "*"
|
|
23
|
+
# grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
|
24
|
+
Digest::MD5.hexdigest RelatonGb::VERSION + RelatonIsoBib::VERSION + RelatonBib::VERSION # grammars
|
|
21
25
|
end
|
|
22
26
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton-gb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.16.
|
|
4
|
+
version: 1.16.1
|
|
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-
|
|
11
|
+
date: 2023-09-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cnccs
|
|
@@ -80,6 +80,7 @@ files:
|
|
|
80
80
|
- grammars/relaton-gb.rng
|
|
81
81
|
- lib/relaton_gb.rb
|
|
82
82
|
- lib/relaton_gb/ccs.rb
|
|
83
|
+
- lib/relaton_gb/config.rb
|
|
83
84
|
- lib/relaton_gb/gb_bibliographic_item.rb
|
|
84
85
|
- lib/relaton_gb/gb_bibliography.rb
|
|
85
86
|
- lib/relaton_gb/gb_scrapper.rb
|
|
@@ -92,6 +93,7 @@ files:
|
|
|
92
93
|
- lib/relaton_gb/scrapper.rb
|
|
93
94
|
- lib/relaton_gb/sec_scrapper.rb
|
|
94
95
|
- lib/relaton_gb/t_scrapper.rb
|
|
96
|
+
- lib/relaton_gb/util.rb
|
|
95
97
|
- lib/relaton_gb/version.rb
|
|
96
98
|
- lib/relaton_gb/xml_parser.rb
|
|
97
99
|
- lib/relaton_gb/yaml/prefixes.yaml
|