relaton-cen 1.16.2 → 1.16.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: 2248f1f7fe9dd799b39377fdfd075fda4dc79ef9389a05e398a8f514c639619d
4
- data.tar.gz: 7b88f2fbcc7d1041659dfe82f0344159734a014cb982bfeb046bcb3b55be5d45
3
+ metadata.gz: c14f063a878f0d9c6267fd71b74fad6cb2500e91c3bdfded0f3ccf3b1c920b76
4
+ data.tar.gz: b744cd4445f3e322e07fa8a37cf5733efa9028a1a03269ad6992ef01f435abeb
5
5
  SHA512:
6
- metadata.gz: 9f3725d5b38db4229ec1c84a2a4033ef62a1c506cb07bec2f4059620ca74135fc1f58011017b4d7424ebae35c5a027cf3ef2ccb6ad1f276645aa35d434102985
7
- data.tar.gz: e4cd2809857e01da01a4f5ff703ea1aeb215e3d3a5396564883df0001c2f5e37c78606c4c837824a4aab13999f757bc831c2d063dfe81add6e957d9fcd1d45b6
6
+ metadata.gz: 3fd672f854de8a98a20c471940b49e55b47a0b1a73f0d243bcbbc3de41b6899130201beefa6bc49995cf605d3a365959e6172336a07fd04e484e8c8841686462
7
+ data.tar.gz: f89b16fb321f85aada7534f1b6b06b398170e06161992ef291a8a97e47c6b8da73ee50d6454c977b1bc4c6e473dbcfaa37e86fa66d6ebbfbb474158451b964b0
@@ -47,11 +47,11 @@ module RelatonCen
47
47
 
48
48
  def fetch_ref_err(code, year, missed_years) # rubocop:disable Metrics/MethodLength
49
49
  id = year ? "#{code}:#{year}" : code
50
- warn "[relaton-cen] WARNING: no match found online for #{id}. "\
51
- "The code must be exactly like it is on the standards website."
50
+ Util.warn "WARNING: no match found online for `#{id}`. " \
51
+ "The code must be exactly like it is on the standards website."
52
52
  unless missed_years.empty?
53
- warn "[relaton-cen] (There was no match for #{year}, though there "\
54
- "were matches found for #{missed_years.join(', ')}.)"
53
+ Util.warn "(There was no match for `#{year}`, though there " \
54
+ "were matches found for `#{missed_years.join('`, `')}`.)"
55
55
  end
56
56
  # if /\d-\d/.match? code
57
57
  # warn "[relaton-cen] The provided document part may not exist, or "\
@@ -101,12 +101,12 @@ module RelatonCen
101
101
 
102
102
  def bib_get(code, year, opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
103
103
  ref = year.nil? || code.match?(/:\d{4}/) ? code : "#{code}:#{year}"
104
- warn "[relaton-cen] (#{ref}) fetching..."
104
+ Util.warn "(#{ref}) fetching..."
105
105
  result = search_filter(code) || return
106
106
  ret = isobib_results_filter(result, year)
107
107
  if ret[:ret]
108
108
  bib = year || opts[:keep_year] ? ret[:ret] : ret[:ret].to_most_recent_reference
109
- warn "[relaton-cen] (#{ref}) found `#{bib.docidentifier.first&.id}`"
109
+ Util.warn "(#{ref}) found `#{bib.docidentifier.first&.id}`"
110
110
  bib
111
111
  else
112
112
  fetch_ref_err(code, year, ret[:years])
@@ -0,0 +1,10 @@
1
+ module RelatonCen
2
+ module Config
3
+ include RelatonBib::Config
4
+ end
5
+ extend Config
6
+
7
+ class Configuration < RelatonBib::Configuration
8
+ PROGNAME = "relaton-cen".freeze
9
+ end
10
+ end
@@ -41,8 +41,11 @@ module RelatonCen
41
41
  # @param doc [Mechanize::Page]
42
42
  # @return [Array<RelatonIsobib::Ics>]
43
43
  def fetch_ics(doc)
44
- doc.xpath("//tr[th[.='ICS']]/td/text()").map do |ics|
45
- RelatonIsoBib::Ics.new ics.text.match(/[^\s]+/).to_s
44
+ doc.xpath("//tr[th[.='ICS']]/td/text()").filter_map do |ics|
45
+ ics_code = ics.text.match(/[^\s]+/).to_s.gsub("\u00A0", "")
46
+ next if ics_code.empty?
47
+
48
+ RelatonIsoBib::Ics.new ics_code
46
49
  end
47
50
  end
48
51
 
@@ -0,0 +1,9 @@
1
+ module RelatonCen
2
+ module Util
3
+ extend RelatonBib::Util
4
+
5
+ def self.logger
6
+ RelatonCen.configuration.logger
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonCen
4
- VERSION = "1.16.2"
4
+ VERSION = "1.16.4"
5
5
  end
data/lib/relaton_cen.rb CHANGED
@@ -3,8 +3,10 @@
3
3
  require "digest/md5"
4
4
  require "mechanize"
5
5
  require "nokogiri"
6
- require_relative "relaton_cen/version"
7
6
  require "relaton_iso_bib"
7
+ require_relative "relaton_cen/version"
8
+ require "relaton_cen/config"
9
+ require "relaton_cen/util"
8
10
  require "relaton_cen/biblographic_item"
9
11
  require "relaton_cen/scrapper"
10
12
  require "relaton_cen/hit_collection"
@@ -17,9 +19,9 @@ module RelatonCen
17
19
  # Returns hash of XML greammar
18
20
  # @return [String]
19
21
  def self.grammar_hash
20
- gem_path = File.expand_path "..", __dir__
21
- grammars_path = File.join gem_path, "grammars", "*"
22
- grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
23
- Digest::MD5.hexdigest grammars
22
+ # gem_path = File.expand_path "..", __dir__
23
+ # grammars_path = File.join gem_path, "grammars", "*"
24
+ # grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
25
+ Digest::MD5.hexdigest RelatonCen::VERSION + RelatonIsoBib::VERSION + RelatonBib::VERSION # grammars
24
26
  end
25
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-cen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.2
4
+ version: 1.16.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: 2023-09-07 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: mechanize
@@ -69,11 +69,13 @@ files:
69
69
  - lib/relaton_cen/biblographic_item.rb
70
70
  - lib/relaton_cen/cen_bibliography.rb
71
71
  - lib/relaton_cen/committees.yaml
72
+ - lib/relaton_cen/config.rb
72
73
  - lib/relaton_cen/hash_converter.rb
73
74
  - lib/relaton_cen/hit.rb
74
75
  - lib/relaton_cen/hit_collection.rb
75
76
  - lib/relaton_cen/processor.rb
76
77
  - lib/relaton_cen/scrapper.rb
78
+ - lib/relaton_cen/util.rb
77
79
  - lib/relaton_cen/version.rb
78
80
  - lib/relaton_cen/xml_parser.rb
79
81
  - relaton_cen.gemspec