relaton-bipm 1.19.0 → 1.19.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_bipm/bipm_bibliography.rb +1 -1
- data/lib/relaton_bipm/committee.rb +23 -17
- data/lib/relaton_bipm/hash_converter.rb +1 -2
- data/lib/relaton_bipm/rawdata_bipm_metrologia/article_parser.rb +3 -4
- data/lib/relaton_bipm/rawdata_bipm_metrologia/fetcher.rb +1 -1
- data/lib/relaton_bipm/version.rb +1 -1
- data/lib/relaton_bipm/xml_parser.rb +3 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d26cb426c0ebdcd6e4544117b76fabc440ce698ae86511d2fa13022fedc0fa33
|
4
|
+
data.tar.gz: b0dae1c393906430b924171c4bc9dc0ddc723108372fd7ac351092845153cb6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfcf6fc883da15803965d74ef0faee65f5aabc637b382e55586d63ace8647f988862748a88269fe3bc33c27308c41a2801c5d5bed7c408e736c451e1b7ba1f03
|
7
|
+
data.tar.gz: 6a1b674e7285565be0fd400f4b27fa9066483fb2500bea43bde9aec6f8c95aa483602d74946b1acb0a669203467a8739bd8e4e5b11eb2ef01958203058651780
|
@@ -2,7 +2,7 @@ require "mechanize"
|
|
2
2
|
|
3
3
|
module RelatonBipm
|
4
4
|
class BipmBibliography
|
5
|
-
GH_ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-bipm/
|
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
|
@@ -1,27 +1,31 @@
|
|
1
1
|
module RelatonBipm
|
2
|
-
class Committee
|
2
|
+
class Committee < RelatonBib::LocalizedString
|
3
|
+
ACRONYMS = YAML.load_file File.join(__dir__, "acronyms.yaml")
|
4
|
+
|
3
5
|
# @return [String]
|
4
6
|
attr_reader :acronym
|
5
7
|
|
6
8
|
# @return [RelatonBib::LocalizedString]
|
7
9
|
attr_reader :content
|
8
10
|
|
9
|
-
# @param
|
10
|
-
# @param
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
# @param [String] acronym
|
12
|
+
# @param [Hash] args
|
13
|
+
# @option args [RelatonBib::LocalisedString, String, nil] :content
|
14
|
+
# @option args [String, nil] :language
|
15
|
+
# @option args [String, nil] :script
|
16
|
+
def initialize(acronym:, **args)
|
17
|
+
unless ACRONYMS[acronym]
|
14
18
|
Util.warn "Invalid acronym: `#{acronym}`. Allowed " \
|
15
|
-
"values: `#{
|
19
|
+
"values: `#{ACRONYMS.map { |k, _v| k }.join '`, `'}`"
|
16
20
|
end
|
17
21
|
|
18
22
|
@acronym = acronym
|
19
|
-
|
23
|
+
super(*localized_args(acronym, **args))
|
20
24
|
end
|
21
25
|
|
22
26
|
# @param builder [Nokogiri::XML::Builder]
|
23
27
|
def to_xml(builder)
|
24
|
-
builder.committee(acronym: acronym) { |b|
|
28
|
+
builder.committee(acronym: acronym) { |b| super b }
|
25
29
|
end
|
26
30
|
|
27
31
|
# @param prefix [String]
|
@@ -32,13 +36,13 @@ module RelatonBipm
|
|
32
36
|
pref += "committee"
|
33
37
|
out = count > 1 ? "#{pref}::\n" : ""
|
34
38
|
out += "#{pref}.acronym:: #{acronym}\n"
|
35
|
-
out +
|
39
|
+
out + super(pref)
|
36
40
|
end
|
37
41
|
|
38
42
|
# @return [Hash]
|
39
43
|
def to_hash
|
40
44
|
hash = { "acronym" => acronym }
|
41
|
-
cnt =
|
45
|
+
cnt = super
|
42
46
|
case cnt
|
43
47
|
when Array then hash["variants"] = cnt
|
44
48
|
when Hash then hash.merge! cnt
|
@@ -49,12 +53,14 @@ module RelatonBipm
|
|
49
53
|
|
50
54
|
private
|
51
55
|
|
52
|
-
def
|
53
|
-
if
|
54
|
-
|
55
|
-
elsif
|
56
|
-
|
57
|
-
|
56
|
+
def localized_args(accronym, **args)
|
57
|
+
if args[:content].is_a? String
|
58
|
+
[args[:content], args[:language], args[:script]]
|
59
|
+
elsif args[:content].nil?
|
60
|
+
lang = args[:language] || ACRONYMS.dig(acronym, "en") ? "en" : ACRONYMS[acronym]&.keys&.first
|
61
|
+
script = args[:script] || lang == "en" ? "Latn" : nil
|
62
|
+
[ACRONYMS.dig(accronym, lang), lang, script]
|
63
|
+
else [args[:content]]
|
58
64
|
end
|
59
65
|
end
|
60
66
|
end
|
@@ -73,8 +73,7 @@ module RelatonBipm
|
|
73
73
|
|
74
74
|
cmt = ret[:editorialgroup][:committee].map do |c|
|
75
75
|
if (vars = committee_variants c).any?
|
76
|
-
|
77
|
-
Committee.new acronym: c[:acronym], content: content
|
76
|
+
Committee.new acronym: c[:acronym], content: vars
|
78
77
|
else
|
79
78
|
Committee.new(**c)
|
80
79
|
end
|
@@ -161,10 +161,9 @@ module RelatonBipm
|
|
161
161
|
# @return [RelatonBib::FullName] full name
|
162
162
|
#
|
163
163
|
def fullname(name)
|
164
|
-
|
165
|
-
|
166
|
-
|
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.
|
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
|
data/lib/relaton_bipm/version.rb
CHANGED
@@ -58,12 +58,9 @@ module RelatonBipm
|
|
58
58
|
|
59
59
|
cm = eg.xpath("committee").map do |c|
|
60
60
|
vars = variants c
|
61
|
-
cnt =
|
62
|
-
|
63
|
-
|
64
|
-
RelatonBib::LocalizedString.new c.text, c[:language], c[:script]
|
65
|
-
end
|
66
|
-
Committee.new acronym: c[:acronym], content: cnt
|
61
|
+
cnt = vars.any? ? vars : c.text
|
62
|
+
args = c.to_h.transform_keys(&:to_sym).select { |k, _| %i[language script locale].include?(k) }
|
63
|
+
Committee.new acronym: c[:acronym], content: cnt, **args
|
67
64
|
end
|
68
65
|
wg = eg.xpath("workgroup").map do |w|
|
69
66
|
WorkGroup.new content: w.text, acronym: w[:acronym]
|
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.19.
|
4
|
+
version: 1.19.2
|
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-
|
11
|
+
date: 2024-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|