relaton-un 1.18.1 → 1.20.0

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: dae4aa964d9746c12a509b7d9ff2d58b50d6465ec8a6d4eca8a5a24255118080
4
- data.tar.gz: c8b47b15603b0b1b9565c0c12b5c6fb4b4a4352d207c228c314473981fef635c
3
+ metadata.gz: e9120476339806fdcd9a828b2964ac3ecbda39e6e36145677f845a7bb0aa9a85
4
+ data.tar.gz: a738350b59eb157fef698cab95ecd7b5b5d65cdf3b25ebea0edbe7ba850da95b
5
5
  SHA512:
6
- metadata.gz: b05b6dfcae803d7d0c3d8d9128258545f6487ce1e212f699ed1700d96d1de6abdc7d67a485185807b4c07d3749b4f0c23fae82a48bd2b32cb2979e65b93a925b
7
- data.tar.gz: 64cd19f4922196a8d5e2aaa914882031721b1fd6320ae516179a8a4360a1c9f310ae74bca238c810f78dee22b36bfdc44ed0f3fca396841fecd9663018d192a1
6
+ metadata.gz: 2b9a11306d032945d285d55353cc089b09ca35d97138d044778803a6fdbde552d4058c8eb7a90668e33653cf16d4e60b136fd132c066dae22904e73932b942d5
7
+ data.tar.gz: deb641be672158598d41550ff20bbcafb4a70dc13fbdd420d7a1ce5670263a2235b703831417ac4eaaf875ede2b3b48172242a74d40b509dd9c7088bea5c6132
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 `RelatonUn.configure` block.
26
+ === Search for a standard using keywords
29
27
 
30
28
  [source,ruby]
31
29
  ----
32
30
  require 'relaton_un'
33
31
  => true
34
32
 
35
- RelatonUn.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 = RelatonUn::UnBibliography.search("TRADE/CEFACT/2004/32")
45
34
  => <RelatonUn::HitCollection:0x007fc4e6ec2018 @ref=TRADE/CEFACT/2004/32 @fetched=false>
46
35
 
@@ -122,6 +111,10 @@ RelatonUn::UnBibliographicItem.new **bib_hash
122
111
  ...
123
112
  ----
124
113
 
114
+ === Logging
115
+
116
+ RelatonUn 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.
117
+
125
118
  == Development
126
119
 
127
120
  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"/>
@@ -12,7 +12,7 @@ module RelatonUn
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
@@ -10,21 +10,33 @@ module RelatonUn
10
10
  ret = super
11
11
  return if ret.nil?
12
12
 
13
- ret[:submissionlanguage] = RelatonBib.array ret[:submissionlanguage]
13
+ hash_to_bib_submissions ret
14
14
  session_hash_to_bib ret
15
+ ret[:distribution] = ret[:ext][:distribution] if ret.dig(:ext, :distribution)
16
+ ret[:job_number] = ret[:ext][:job_number] if ret.dig(:ext, :job_number)
15
17
  ret
16
18
  end
17
19
 
18
20
  private
19
21
 
22
+ def hash_to_bib_submissions(ret)
23
+ sm = ret.dig(:ext, :submissionlanguage) || ret[:submissionlanguage] # @TODO remove args[:submissionlanguage] after all gems are updated
24
+ return unless sm
25
+
26
+ ret[:submissionlanguage] = RelatonBib.array sm
27
+ end
28
+
20
29
  # @param ret [Hash]
21
30
  def session_hash_to_bib(ret)
22
- ret[:session] = Session.new(**ret[:session]) if ret[:session]
31
+ session = ret.dig(:ext, :session) || ret[:session] # @TODO remove ret[:session] after all gems are updated
32
+ return unless session
33
+
34
+ ret[:session] = Session.new(**session)
23
35
  end
24
36
 
25
37
  # @param ret [Hash]
26
38
  def editorialgroup_hash_to_bib(ret)
27
- eg = ret[:editorialgroup]
39
+ eg = ret.dig(:ext, :editorialgroup) || ret[:editorialgroup] # @TODO remove ret[:editorialgroup] after all gems are updated
28
40
  return unless eg
29
41
 
30
42
  committee = eg.map { |e| e[:committee] }
@@ -19,7 +19,7 @@ module RelatonUn
19
19
  # @param job_number [String, nil]
20
20
  def initialize(**args)
21
21
  if args[:distribution] && !DISTRIBUTIONS.has_value?(args[:distribution])
22
- Util.warn "WARNING: Invalid distribution: `#{args[:distribution]}`"
22
+ Util.warn "Invalid distribution: `#{args[:distribution]}`"
23
23
  end
24
24
  @submissionlanguage = args.delete :submissionlanguage
25
25
  @distribution = args.delete :distribution
@@ -67,14 +67,18 @@ module RelatonUn
67
67
  def to_hash(embedded: false) # rubocop:disable Metrics/AbcSize
68
68
  hash = super
69
69
  if submissionlanguage&.any?
70
- hash["submissionlanguage"] = single_element_array submissionlanguage
70
+ hash["ext"]["submissionlanguage"] = single_element_array submissionlanguage
71
71
  end
72
- hash["distribution"] = distribution if distribution
73
- hash["session"] = session.to_hash if session
74
- hash["job_number"] = job_number if job_number
72
+ hash["ext"]["distribution"] = distribution if distribution
73
+ hash["ext"]["session"] = session.to_hash if session
74
+ hash["ext"]["job_number"] = job_number if job_number
75
75
  hash
76
76
  end
77
77
 
78
+ def has_ext?
79
+ super || submissionlanguage&.any? || distribution || session || job_number
80
+ end
81
+
78
82
  # @param prefix [String]
79
83
  # @return [String]
80
84
  def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize
@@ -21,14 +21,14 @@ module RelatonUn
21
21
  # @param opts [Hash] options
22
22
  # @return [RelatonUn::UnBibliographicItem]
23
23
  def get(ref, _year = nil, _opts = {})
24
- Util.warn "(#{ref}) Fetching from documents.un.org ..."
24
+ Util.info "Fetching from documents.un.org ...", key: ref
25
25
  /^(?:UN\s)?(?<code>.*)/ =~ ref
26
26
  result = isobib_search_filter(code)
27
27
  if result
28
- Util.warn "(#{ref}) Found: `#{result.fetch.docidentifier[0].id}`"
28
+ Util.info "Found: `#{result.fetch.docidentifier[0].id}`", key: ref
29
29
  result.fetch
30
30
  else
31
- Util.warn "(#{ref}) Not found."
31
+ Util.info "Not found.", key: ref
32
32
  nil
33
33
  end
34
34
  end
@@ -1,9 +1,6 @@
1
1
  module RelatonUn
2
2
  module Util
3
3
  extend RelatonBib::Util
4
-
5
- def self.logger
6
- RelatonUn.configuration.logger
7
- end
4
+ PROGNAME = "relaton-un".freeze
8
5
  end
9
6
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonUn
2
- VERSION = "1.18.1".freeze
2
+ VERSION = "1.20.0".freeze
3
3
  end
@@ -57,6 +57,10 @@ module RelatonUn
57
57
  def fetch_submissionlanguage(ext)
58
58
  ext.xpath("./submissionlanguage").map(&:text)
59
59
  end
60
+
61
+ def create_doctype(type)
62
+ DocumentType.new type: type.text, abbreviation: type[:abbreviation]
63
+ end
60
64
  end
61
65
  end
62
66
  end
data/lib/relaton_un.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require "addressable"
2
2
  require "relaton_bib"
3
3
  require "relaton_un/version"
4
- require "relaton_un/config"
5
4
  require "relaton_un/util"
6
5
  require "relaton_un/document_type"
7
6
  require "relaton_un/un_bibliographic_item"
data/relaton_un.gemspec CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_dependency "addressable", "~> 2.8.0"
36
36
  spec.add_dependency "faraday", "~> 2.7.0"
37
37
  spec.add_dependency "http-cookie", "~> 1.0.5"
38
- spec.add_dependency "relaton-bib", "~> 1.18.0"
38
+ spec.add_dependency "relaton-bib", "~> 1.20.0"
39
39
  spec.add_dependency "unf_ext", ">= 0.0.7.7"
40
40
  end
41
41
  # rubocop:enable Metrics/BlockLength
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-un
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.1
4
+ version: 1.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-16 00:00:00.000000000 Z
11
+ date: 2024-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.18.0
61
+ version: 1.20.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.20.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: unf_ext
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -106,7 +106,6 @@ files:
106
106
  - grammars/relaton-un-compile.rng
107
107
  - grammars/relaton-un.rng
108
108
  - lib/relaton_un.rb
109
- - lib/relaton_un/config.rb
110
109
  - lib/relaton_un/document_type.rb
111
110
  - lib/relaton_un/editorialgroup.rb
112
111
  - lib/relaton_un/hash_converter.rb
@@ -127,7 +126,7 @@ licenses:
127
126
  metadata:
128
127
  homepage_uri: https://github.com/relaton/relaton-un
129
128
  source_code_uri: https://github.com/relaton/relaton-un
130
- post_install_message:
129
+ post_install_message:
131
130
  rdoc_options: []
132
131
  require_paths:
133
132
  - lib
@@ -142,8 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
141
  - !ruby/object:Gem::Version
143
142
  version: '0'
144
143
  requirements: []
145
- rubygems_version: 3.3.26
146
- signing_key:
144
+ rubygems_version: 3.3.27
145
+ signing_key:
147
146
  specification_version: 4
148
147
  summary: 'RelatonIso: retrieve CC Standards for bibliographic use using the IsoBibliographicItem
149
148
  model'
@@ -1,10 +0,0 @@
1
- module RelatonUn
2
- module Config
3
- include RelatonBib::Config
4
- end
5
- extend Config
6
-
7
- class Configuration < RelatonBib::Configuration
8
- PROGNAME = "relaton-un".freeze
9
- end
10
- end