relaton-calconnect 1.18.0 → 1.19.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ac031a527346a0fe8c93195fccb82c8f560916ceb677089b1d3acf4d734d816
4
- data.tar.gz: 69af72168bc0f701a12f45cf39e8a97e804451f7886cef5d35a897793144a79c
3
+ metadata.gz: 9fcb3b4d62f90644c6d413e130c437e25fc5f79e93f4651c0c18b75afd378537
4
+ data.tar.gz: f701752957ca137ecb8cef0c69741279765b20f6a1d14f8b4cffe4de619dc682
5
5
  SHA512:
6
- metadata.gz: 4d44f4d1e9c069f95fc626bd624c09af792a40d201853bc508be30e2c91aba0c038e74a27f7fb3361bc94b64a44455ffd251de85c2272be81117ab9aa6e2ba72
7
- data.tar.gz: 8c1ec2768962fa88f10f40f3d01903bfb3fc09f99b2ac0eba8e77aa22bd3663738a271de669d811e58c835f24013122f6888e1c85cefc5ac68ae2bfe4288cf63
6
+ metadata.gz: 20192f06a9d2136cb690d2de1ae3286840fc8bb03443266f341fe27bafdda868c5223d78ceec9b11e078d15c543e02b78a59cff1575d15618cc26e4457f54d94
7
+ data.tar.gz: e110ed14e5bf719fe138e265f0da3a546db447e7d255da8a4ca3290b029336e68149c7c69d6077909b72d646b809a0fe6a215ff915c2a2a4c438e9d0dfa7d5c3
data/README.adoc CHANGED
@@ -23,24 +23,13 @@ Or install it yourself as:
23
23
 
24
24
  == Usage
25
25
 
26
- === Configuration
27
-
28
- Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonCalconnect.configure` block.
26
+ === Search for a standard using keywords
29
27
 
30
28
  [source,ruby]
31
29
  ----
32
30
  require 'relaton_calconnect'
33
31
  => true
34
32
 
35
- RelatonCalconnect.configure do |config|
36
- config.logger.level = Logger::DEBUG
37
- end
38
- ----
39
-
40
- === Search for a standard using keywords
41
-
42
- [source,ruby]
43
- ----
44
33
  hits = RelatonCalconnect::CcBibliography.search("CC/DIR 10005:2019")
45
34
  => <RelatonCalconnect::HitCollection:0x007f98e34a8bb0 @ref=CC/DIR 10005:2019 @fetched=false>
46
35
 
@@ -147,6 +136,10 @@ Done in: 20 sec.
147
136
  => nil
148
137
  ----
149
138
 
139
+ === Logging
140
+
141
+ RelatonCalconnect uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
142
+
150
143
  == Development
151
144
 
152
145
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -244,6 +244,9 @@
244
244
  <data type="ID"/>
245
245
  </attribute>
246
246
  <attribute name="reviewer"/>
247
+ <optional>
248
+ <attribute name="type"/>
249
+ </optional>
247
250
  <optional>
248
251
  <attribute name="date">
249
252
  <data type="dateTime"/>
@@ -29,14 +29,14 @@ module RelatonCalconnect
29
29
  end
30
30
  end
31
31
 
32
- Util.warn "(#{ref}) Fetching from Relaton repository ..."
32
+ Util.info "Fetching from Relaton repository ...", key: ref
33
33
  result = search(code, year, opts) || (return nil)
34
34
  ret = bib_results_filter(result, year)
35
35
  if ret[:ret]
36
- Util.warn "(#{ref}) Found: `#{ret[:ret].docidentifier.first.id}`"
36
+ Util.info "Found: `#{ret[:ret].docidentifier.first.id}`", key: ref
37
37
  ret[:ret]
38
38
  else
39
- Util.warn "(#{ref}) No found."
39
+ Util.info "No found.", key: ref
40
40
  fetch_ref_err(code, year, ret[:years])
41
41
  end
42
42
  end
@@ -55,12 +55,17 @@ module RelatonCalconnect
55
55
  #
56
56
  # @return [Hash]
57
57
  def bib_results_filter(result, year)
58
- missed_years = []
58
+ missed_years = Set.new
59
59
  result.each do |r|
60
60
  item = r.fetch
61
61
  item.fetched = Date.today.to_s
62
62
  return { ret: item } if !year
63
63
 
64
+ /:(?<id_year>\d{4})$/ =~ r.hit[:id]
65
+ return { ret: item } if year.to_i == id_year.to_i
66
+
67
+ missed_years << id_year.to_i if id_year
68
+
64
69
  item.date.select { |d| d.type == "published" }.each do |d|
65
70
  return { ret: item } if year.to_i == d.on(:year)
66
71
 
@@ -75,10 +80,10 @@ module RelatonCalconnect
75
80
  # @param missed_years [Array<Strig>]
76
81
  def fetch_ref_err(code, year, missed_years)
77
82
  # id = year ? "`#{code}` year `#{year}`" : code
78
- # Util.warn "WARNING: No match found online for #{id}. " \
83
+ # Util.info "WARNING: No match found online for #{id}. " \
79
84
  # "The code must be exactly like it is on the standards website."
80
85
  unless missed_years.empty?
81
- Util.warn "There was no match for `#{year}`, though there " \
86
+ Util.info "There was no match for `#{year}`, though there " \
82
87
  "were matches found for `#{missed_years.join('`, `')}`."
83
88
  end
84
89
  nil
@@ -67,9 +67,9 @@ module RelatonCalconnect
67
67
  write_doc doc["docid"]["id"], bib
68
68
  true
69
69
  rescue StandardError => e
70
- warn "Document: #{doc['docid']['id']}"
71
- warn e.message
72
- warn e.backtrace[0..5].join("\n")
70
+ Util.warn "Document: #{doc['docid']['id']}"
71
+ Util.warn e.message
72
+ Util.warn e.backtrace[0..5].join("\n")
73
73
  false
74
74
  end
75
75
 
@@ -81,7 +81,7 @@ module RelatonCalconnect
81
81
  end
82
82
  file = File.join @output, "#{docid.upcase.gsub(%r{[/\s:]}, '_')}.#{@ext}"
83
83
  if @files.include? file
84
- warn "#{file} exist"
84
+ Util.warn "#{file} exist"
85
85
  else
86
86
  @files << file
87
87
  end
@@ -12,7 +12,7 @@ module RelatonCalconnect
12
12
 
13
13
  def check_type(type)
14
14
  unless DOCTYPES.include? type
15
- Util.warn "WARNING: invalid doctype: `#{type}`"
15
+ Util.warn "Invalid doctype: `#{type}`"
16
16
  end
17
17
  end
18
18
  end
@@ -74,9 +74,16 @@ module RelatonCalconnect
74
74
  dtps = %w[CC CSD]
75
75
  did = array(doc["docid"]).detect { |id| dtps.include? id["type"].upcase }
76
76
  did["primary"] = true if did
77
+ # date_to_hash doc
77
78
  doc
78
79
  end
79
80
 
81
+ # def date_to_hash(doc)
82
+ # return if doc["date"] || !doc["revdate"]
83
+
84
+ # doc["date"] = { "type" => "published", "on" => doc["revdate"] }
85
+ # end
86
+
80
87
  def update_links(bib, links)
81
88
  links.each do |l|
82
89
  tu = l.transform_keys(&:to_sym)
@@ -1,9 +1,6 @@
1
1
  module RelatonCalconnect
2
2
  module Util
3
3
  extend RelatonBib::Util
4
-
5
- def self.logger
6
- RelatonCalconnect.configuration.logger
7
- end
4
+ PROGNAME = "relaton-calconnect".freeze
8
5
  end
9
6
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonCalconnect
2
- VERSION = "1.18.0".freeze
2
+ VERSION = "1.19.1".freeze
3
3
  end
@@ -20,6 +20,10 @@ module RelatonCalconnect
20
20
  end
21
21
  RelatonBib::EditorialGroup.new eg if eg.any?
22
22
  end
23
+
24
+ def create_doctype(type)
25
+ DocumentType.new type: type.text, abbreviation: type[:abbreviation]
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -1,7 +1,6 @@
1
1
  require "relaton/index"
2
2
  require "relaton_bib"
3
3
  require "relaton_calconnect/version"
4
- require "relaton_calconnect/config"
5
4
  require "relaton_calconnect/util"
6
5
  require "relaton_calconnect/document_type"
7
6
  require "relaton_calconnect/cc_bibliography"
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
28
28
 
29
29
  spec.add_dependency "faraday", "~> 2.7.0"
30
- spec.add_dependency "relaton-bib", "~> 1.18.0"
30
+ spec.add_dependency "relaton-bib", "~> 1.19.0"
31
31
  spec.add_dependency "relaton-index", "~> 0.2.0"
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-calconnect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
4
+ version: 1.19.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: 2024-01-06 00:00:00.000000000 Z
11
+ date: 2024-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.18.0
33
+ version: 1.19.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.18.0
40
+ version: 1.19.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: relaton-index
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +80,6 @@ files:
80
80
  - lib/relaton_calconnect.rb
81
81
  - lib/relaton_calconnect/cc_bibliographic_item.rb
82
82
  - lib/relaton_calconnect/cc_bibliography.rb
83
- - lib/relaton_calconnect/config.rb
84
83
  - lib/relaton_calconnect/data_fetcher.rb
85
84
  - lib/relaton_calconnect/document_type.rb
86
85
  - lib/relaton_calconnect/hash_converter.rb
@@ -112,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
111
  - !ruby/object:Gem::Version
113
112
  version: '0'
114
113
  requirements: []
115
- rubygems_version: 3.3.26
114
+ rubygems_version: 3.3.27
116
115
  signing_key:
117
116
  specification_version: 4
118
117
  summary: 'RelatonIso: retrieve CC Standards for bibliographic use using the IsoBibliographicItem
@@ -1,10 +0,0 @@
1
- module RelatonCalconnect
2
- module Config
3
- include RelatonBib::Config
4
- end
5
- extend Config
6
-
7
- class Configuration < RelatonBib::Configuration
8
- PROGNAME = "relaton-calconnect".freeze
9
- end
10
- end