relaton-bipm 1.18.2 → 1.19.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: 7e3b95a4edc9d788cb85a8ac616dcaf8c3ae1957a3138ee45c049e20d92cd168
4
- data.tar.gz: bf39e7f015de4adddbda44451bac4efc9691f1e50df4cc6ea5969067677a5f44
3
+ metadata.gz: 6169158d13f03ec83666123ca52d0e87b7960ba13fe5b6d5051228c54158f93c
4
+ data.tar.gz: 46236ffb5e1f875fd042dd89fe866251962a553497dd9a8a474edcd6aa18e2fa
5
5
  SHA512:
6
- metadata.gz: 31ae9b9e3a97df4ee2bbaaa539a496babf1a28de8749fff8dbdd076251d63f188ac1ec88615ba651764fdfa730f242c4dbef535eb2a1fbe1d61d674e8970e631
7
- data.tar.gz: 4b883547bd97402ec22c9896c6aa535708748358aabf637755a2f305c7d64a30cbb2526ef689d3398fb4d5592680f5c40c87da61e71e50c4059d6df3dbd2a260
6
+ metadata.gz: d1b01efea043f825d7e08dcecc6396e21b56c75ab0131dffd6b5e936ea10e185e9f8412ddf9c30fa21f64eaf9e97408da92e06fedc2a7cbb1d9da581151ab0ea
7
+ data.tar.gz: 8cc33bc1d0b431ecd6d55c640ddcf5d715e640dfd2a926a5e2db5d72f442fefe93f527275f17236e2a815302cdb65ec9c47f71dd970b9d0eb708133765654d92
data/README.adoc CHANGED
@@ -179,24 +179,13 @@ Recommendation JCRB/43-1 (2021) / Recommandation JCRB/43-1 (2021)
179
179
  JCRB REC JCRB/43-1 (2021)
180
180
  ----
181
181
 
182
- === Configuration
183
-
184
- 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 `RelatonBipm.configure` block.
182
+ ==== Examples
185
183
 
186
184
  [source,ruby]
187
185
  ----
188
- require 'relaton_bipm'
186
+ require "relaton_bipm"
189
187
  => true
190
188
 
191
- RelatonBipm.configure do |config|
192
- config.logger.level = Logger::DEBUG
193
- end
194
- ----
195
-
196
- ==== Examples
197
-
198
- [source,ruby]
199
- ----
200
189
  # get BIPM brochure
201
190
  item = RelatonBipm::BipmBibliography.get "BIPM SI Brochure"
202
191
  [relaton-bipm] (BIPM SI Brochure) Fetching from Relaton repository ...
@@ -269,7 +258,7 @@ RelatonBipm::BipmBibliography.get "CIPM REC 1 (2005, FR)"
269
258
  [source,ruby]
270
259
  ----
271
260
  item.to_xml
272
- => "<bibitem id="BIPMSIBrochure" type="standard" schema-version="v1.2.1">
261
+ => "<bibitem id="BIPMSIBrochurePart1" type="standard" schema-version="v1.2.1">
273
262
  <fetched>2022-12-02</fetched>
274
263
  <title type="main" format="text/plain" language="en">The International System of Units</title>
275
264
  <title type="cover" format="text/plain" language="en">The International System of Units (SI)</title>
@@ -367,6 +356,10 @@ Done in: 82 sec.
367
356
  => nil
368
357
  ----
369
358
 
359
+ === Logging
360
+
361
+ RelatonBipm 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.
362
+
370
363
  == Development
371
364
 
372
365
  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.
@@ -23,12 +23,12 @@ module RelatonBipm
23
23
  # @param structuredidentifier [RelatonBipm::StructuredIdentifier]
24
24
  def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
25
25
  if args[:docstatus] && !STATUSES.include?(args[:docstatus].stage.value)
26
- Util.warn "WARNING: Invalid docstatus: `#{args[:docstatus].stage.value}`. " \
26
+ Util.warn "Invalid docstatus: `#{args[:docstatus].stage.value}`. " \
27
27
  "It should be one of: `#{STATUSES.join('`, `')}`"
28
28
  end
29
29
 
30
30
  if args[:si_aspect] && !SI_ASPECTS.include?(args[:si_aspect])
31
- Util.warn "WARNING: Invalid si_aspect: `#{args[:si_aspect]}``. " \
31
+ Util.warn "Invalid si_aspect: `#{args[:si_aspect]}``. " \
32
32
  "It should be one of: `#{SI_ASPECTS.join('`, `')}`"
33
33
  end
34
34
 
@@ -2,22 +2,22 @@ require "mechanize"
2
2
 
3
3
  module RelatonBipm
4
4
  class BipmBibliography
5
- GH_ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-bipm/master/".freeze
5
+ GH_ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-bipm/main/".freeze
6
6
  INDEX_FILE = "index2.yaml".freeze
7
7
 
8
8
  class << self
9
9
  # @param text [String]
10
10
  # @return [RelatonBipm::BipmBibliographicItem]
11
11
  def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
12
- Util.warn "(#{text}) Fetching from Relaton repository ..."
12
+ Util.info "Fetching from Relaton repository ...", key: text
13
13
  ref = text.sub(/^BIPM\s/, "")
14
14
  item = get_bipm ref
15
15
  unless item
16
- Util.warn "(#{text}) Not found."
16
+ Util.info "Not found.", key: text
17
17
  return
18
18
  end
19
19
 
20
- Util.warn("(#{text}) Found: `#{item.docidentifier[0].id}`")
20
+ Util.info "Found: `#{item.docidentifier[0].id}`", key: text
21
21
  item
22
22
  rescue Mechanize::ResponseCodeError => e
23
23
  raise RelatonBib::RequestError, e.message unless e.response_code == "404"
@@ -11,7 +11,7 @@ module RelatonBipm
11
11
  def initialize(acronym:, content: nil)
12
12
  acronyms = YAML.load_file File.join(__dir__, "acronyms.yaml")
13
13
  unless acronyms[acronym]
14
- Util.warn "WARNING: Invalid acronym: `#{acronym}`. Allowed " \
14
+ Util.warn "Invalid acronym: `#{acronym}`. Allowed " \
15
15
  "values: `#{acronyms.map { |k, _v| k }.join '`, `'}`"
16
16
  end
17
17
 
@@ -57,7 +57,7 @@ module RelatonBipm
57
57
  def write_file(path, item, warn_duplicate: true)
58
58
  content = serialize item
59
59
  if @files.include?(path)
60
- warn "File #{path} already exists" if warn_duplicate
60
+ Util.warn "File #{path} already exists" if warn_duplicate
61
61
  else
62
62
  @files << path
63
63
  end
@@ -22,7 +22,7 @@ module RelatonBipm
22
22
  #
23
23
  def check_type(type)
24
24
  # unless DOCTYPES.include? type
25
- # Util.warn "WARNING: invalid doctype: `#{type}`"
25
+ # Util.warn "invalid doctype: `#{type}`"
26
26
  # end
27
27
  end
28
28
  end
@@ -95,7 +95,7 @@ module RelatonBipm
95
95
  @id = match.named_captures.compact.transform_keys(&:to_sym)
96
96
  self
97
97
  rescue StandardError => e
98
- Util.warn "WARNING: Incorrect reference: `#{id}`"
98
+ Util.warn "Incorrect reference: `#{id}`"
99
99
  raise RelatonBib::RequestError, e
100
100
  end
101
101
 
@@ -161,10 +161,9 @@ module RelatonBipm
161
161
  # @return [RelatonBib::FullName] full name
162
162
  #
163
163
  def fullname(name)
164
- fname = forename name.at("./given-names")
165
- sname = name.at("./surname").text
166
- surname = RelatonBib::LocalizedString.new sname, "en", "Latn"
167
- RelatonBib::FullName.new surname: surname, forename: fname
164
+ cname = [name.at("./given-names"), name.at("./surname")].compact.map(&:text).join(" ")
165
+ completename = RelatonBib::LocalizedString.new cname, "en", "Latn"
166
+ RelatonBib::FullName.new completename: completename
168
167
  end
169
168
 
170
169
  #
@@ -31,7 +31,7 @@ module RelatonBipm
31
31
  def fetch_articles # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
32
32
  Dir["#{DIR}/**/*.xml"].each do |path|
33
33
  item = ArticleParser.parse path
34
- file = "#{item.docidentifier.first.id.downcase.gsub(' ', '-')}.#{@data_fetcher.ext}"
34
+ file = "#{item.docidentifier.first.id.downcase.tr(' ', '-')}.#{@data_fetcher.ext}"
35
35
  out_path = File.join(@data_fetcher.output, file)
36
36
  key = Id.new.parse(item.docidentifier.first.id).to_hash
37
37
  @data_fetcher.index2.add_or_update key, out_path
@@ -1,9 +1,6 @@
1
1
  module RelatonBipm
2
2
  module Util
3
3
  extend RelatonBib::Util
4
-
5
- def self.logger
6
- RelatonBipm.configuration.logger
7
- end
4
+ PROGNAME = "relaton-bipm".freeze
8
5
  end
9
6
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonBipm
2
- VERSION = "1.18.2".freeze
2
+ VERSION = "1.19.1".freeze
3
3
  end
@@ -97,6 +97,10 @@ module RelatonBipm
97
97
  # conts << RelatonBib::Address.new(city: city, country: country)
98
98
  # end
99
99
  # end
100
+
101
+ def create_doctype(type)
102
+ DocumentType.new type: type.text, abbreviation: type[:abbreviation]
103
+ end
100
104
  end
101
105
  end
102
106
  end
data/lib/relaton_bipm.rb CHANGED
@@ -3,7 +3,6 @@ require "fileutils"
3
3
  require "parslet"
4
4
  require "relaton_bib"
5
5
  require "relaton/index"
6
- require "relaton_bipm/config"
7
6
  require "relaton_bipm/util"
8
7
  require "relaton_bipm/id_parser"
9
8
  require "relaton_bipm/version"
data/relaton_bipm.gemspec CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
35
35
  spec.add_dependency "faraday", "~> 2.7.0"
36
36
  spec.add_dependency "mechanize", "~> 2.10"
37
37
  spec.add_dependency "parslet", "~> 2.0.0"
38
- spec.add_dependency "relaton-bib", "~> 1.18.0"
38
+ spec.add_dependency "relaton-bib", "~> 1.19.0"
39
39
  spec.add_dependency "relaton-index", "~> 0.2.2"
40
40
  spec.add_dependency "rubyzip", "~> 2.3.0"
41
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-bipm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.2
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-06-18 00:00:00.000000000 Z
11
+ date: 2024-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.18.0
61
+ version: 1.19.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.18.0
68
+ version: 1.19.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: relaton-index
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -127,7 +127,6 @@ files:
127
127
  - lib/relaton_bipm/bipm_si_brochure_parser.rb
128
128
  - lib/relaton_bipm/comment_periond.rb
129
129
  - lib/relaton_bipm/committee.rb
130
- - lib/relaton_bipm/config.rb
131
130
  - lib/relaton_bipm/data_fetcher.rb
132
131
  - lib/relaton_bipm/data_outcomes_parser.rb
133
132
  - lib/relaton_bipm/document_relation.rb
@@ -1,10 +0,0 @@
1
- module RelatonBipm
2
- module Config
3
- include RelatonBib::Config
4
- end
5
- extend Config
6
-
7
- class Configuration < RelatonBib::Configuration
8
- PROGNAME = "relaton-bipm".freeze
9
- end
10
- end