relaton-un 1.18.1 → 1.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +5 -12
- data/grammars/basicdoc.rng +3 -0
- data/lib/relaton_un/document_type.rb +1 -1
- data/lib/relaton_un/hash_converter.rb +15 -3
- data/lib/relaton_un/un_bibliographic_item.rb +9 -5
- data/lib/relaton_un/un_bibliography.rb +3 -3
- data/lib/relaton_un/util.rb +1 -4
- data/lib/relaton_un/version.rb +1 -1
- data/lib/relaton_un/xml_parser.rb +4 -0
- data/lib/relaton_un.rb +0 -1
- data/relaton_un.gemspec +1 -1
- metadata +8 -9
- data/lib/relaton_un/config.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9120476339806fdcd9a828b2964ac3ecbda39e6e36145677f845a7bb0aa9a85
|
4
|
+
data.tar.gz: a738350b59eb157fef698cab95ecd7b5b5d65cdf3b25ebea0edbe7ba850da95b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
===
|
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.
|
data/grammars/basicdoc.rng
CHANGED
@@ -10,21 +10,33 @@ module RelatonUn
|
|
10
10
|
ret = super
|
11
11
|
return if ret.nil?
|
12
12
|
|
13
|
-
|
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
|
-
|
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 "
|
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.
|
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.
|
28
|
+
Util.info "Found: `#{result.fetch.docidentifier[0].id}`", key: ref
|
29
29
|
result.fetch
|
30
30
|
else
|
31
|
-
Util.
|
31
|
+
Util.info "Not found.", key: ref
|
32
32
|
nil
|
33
33
|
end
|
34
34
|
end
|
data/lib/relaton_un/util.rb
CHANGED
data/lib/relaton_un/version.rb
CHANGED
data/lib/relaton_un.rb
CHANGED
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.
|
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.
|
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-
|
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.
|
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.
|
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.
|
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'
|