relaton-gb 1.16.0 → 1.16.1

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: af59eecad25f703949530ba1d289daac5eafea562bf4453b56e92e5951747ffa
4
- data.tar.gz: 7c6dcf93299919fe1869fb91c93f556382d129d1cfdc69c69c4d09027cfdb1ee
3
+ metadata.gz: 9abe3c75ca613bc38c155fd5f116ecd967b06eecd7abc78610b498f107d6ec8f
4
+ data.tar.gz: a01b3c0b36e744d4518a54c2e41576a3c87a996468ff17b19a7981c5ed1a058d
5
5
  SHA512:
6
- metadata.gz: c45e0158f52768fa4e1468794c9ec78a207db0105f8dc285368c6cde561c1f5695b85dd1699bf2b48a84ac703a6e74f363962536fc8df50c0389bf3055e6a0c8
7
- data.tar.gz: 8fd2778d0a2a78f5301666bc5615d7ddf73f2ec627d80ea254cd669915dbad1fcf33aa72ab2db24e50cd702faf85077403909e3d0b717d2e3a0474bd88ca6c20
6
+ metadata.gz: f10cfd40d9314992bae8b704118d53b519ce1c5f2145139e61f816559f28adbc17703a34e02556af92694e99f5b78371d6fbcea2732d3d3556d181dc7876d811
7
+ data.tar.gz: f6373a69761f186b254ef5dfacbee6f195143b6cf522dc2da06a9667a4bfd4df90be3ac001de734034655b48072ab7dbca632f73f77ebf2fe196f19ff8a081d2
@@ -0,0 +1,10 @@
1
+ module RelatonGb
2
+ module Config
3
+ include RelatonBib::Config
4
+ end
5
+ extend Config
6
+
7
+ class Configuration < RelatonBib::Configuration
8
+ PROGNAME = "relaton-gb".freeze
9
+ end
10
+ end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "relaton_iso_bib"
4
- require "cnccs"
5
3
  require "relaton_gb/gb_technical_committee"
6
4
  require "relaton_gb/gb_standard_type"
7
5
  require "relaton_gb/xml_parser"
@@ -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(/-/, 2) if /-/ =~ code
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 "[relaton-gb] WARNING: no match found on the GB website "\
69
- "for #{id}. The code must be exactly like it is on the website."
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 "[relaton-gb] (There was no match for #{year}, though there "\
72
- "were matches found for #{missed_years.join(', ')}.)"
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 "[relaton-gb] The provided document part may not exist, or the "\
76
- "document may no longer be published in parts."
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 "[relaton-gb] If you wanted to cite all document parts for the "\
79
- "reference, use \"#{code} (all parts)\".\nIf the document is not "\
80
- "a standard, use its document type abbreviation (TS, TR, PAS, "\
81
- "Guide)."
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 "[relaton-gb] (\"#{code}\") found #{ret[:ret].docidentifier.first.id}"
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 "[relaton-gb] (\"#{code}\") fetching..."
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)
@@ -0,0 +1,9 @@
1
+ module RelatonGb
2
+ module Util
3
+ extend RelatonBib::Util
4
+
5
+ def self.logger
6
+ RelatonGb.configuration.logger
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonGb
4
- VERSION = "1.16.0"
4
+ VERSION = "1.16.1"
5
5
  end
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.0
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-03 00:00:00.000000000 Z
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