relaton-bipm 1.12.3 → 1.13.2
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 +4 -4
- data/README.adoc +29 -29
- data/grammars/biblio.rng +8 -5
- data/grammars/isodoc.rng +27 -1
- data/lib/relaton_bipm/bipm_bibliography.rb +19 -6
- data/lib/relaton_bipm/data_fetcher.rb +35 -4
- data/lib/relaton_bipm/index.rb +1 -1
- data/lib/relaton_bipm/version.rb +1 -1
- data/lib/relaton_bipm/xml_parser.rb +0 -11
- data/relaton_bipm.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8684961db2e3b70deffa9ba3a943ac4ce4990edd0b00a0e5311c0d92ca61f344
|
|
4
|
+
data.tar.gz: 4d585b8f37043d19e14bf2bf9f1a9ee32186978f86db61a9fa2aade824171133
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f426fa79bd1c71061fe411ff764435817c49d0a9c9e56333304ae54390a6f20384dbdaf40fba7e19062c3618ca212fbd2d21dc3180ee461f75d0d2f5d6c6ffe3
|
|
7
|
+
data.tar.gz: 0b7b9707e8cd16955591edd14592bc59550cb0efb21cfcdceacd5733a471af0d4b8ee4ec39138e8ae6653f22e006144195e1ab8e1a685e95199f2f6408ebdee5
|
data/README.adoc
CHANGED
|
@@ -39,35 +39,34 @@ Or install it yourself as:
|
|
|
39
39
|
|
|
40
40
|
Allowed document names are:
|
|
41
41
|
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
- sib-a4
|
|
42
|
+
- CCEM-GD-RSI-1
|
|
43
|
+
- CCL-GD-MeP-1
|
|
44
|
+
- CCL-GD-MeP-2
|
|
45
|
+
- CCL-GD-MeP-3
|
|
46
|
+
- CCM-GD-RSI-1
|
|
47
|
+
- CCM-GD-RSI-2
|
|
48
|
+
- SI MEP A1
|
|
49
|
+
- SI MEP Cd1
|
|
50
|
+
- Rapport BIPM-2019/05
|
|
51
|
+
- SI MEP KUPRTM
|
|
52
|
+
- SI MEP KAPRT
|
|
53
|
+
- SI MEP K1
|
|
54
|
+
- SI MEP KLJNT
|
|
55
|
+
- SI MEP KRPRT
|
|
56
|
+
- SI MEP Kg1
|
|
57
|
+
- SI MEP M1
|
|
58
|
+
- SI MEP Mol1
|
|
59
|
+
- SI MEP S1
|
|
60
|
+
- SI Brochure
|
|
62
61
|
|
|
63
62
|
==== Reference structire for Metrologia documents
|
|
64
63
|
|
|
65
|
-
`BIPM Metrologia {JOURNAL} {VOLUME} {ISSUE} {
|
|
64
|
+
`BIPM Metrologia {JOURNAL} {VOLUME} {ISSUE} {PAGE}`
|
|
66
65
|
|
|
67
66
|
- `{JOURNAL}` - number of journal, required
|
|
68
67
|
- `{VOLUME}` - number of volume, optional
|
|
69
68
|
- `{ISSUE}` - number of issue, optional
|
|
70
|
-
- `{
|
|
69
|
+
- `{PAGE}` - number of page, optional
|
|
71
70
|
|
|
72
71
|
==== Reference structures for CCTF (CCDS), CGMP, CIPM documents
|
|
73
72
|
|
|
@@ -94,13 +93,13 @@ require 'relaton_bipm'
|
|
|
94
93
|
=> true
|
|
95
94
|
|
|
96
95
|
# get BIPM brochure
|
|
97
|
-
item = RelatonBipm::BipmBibliography.get "BIPM
|
|
98
|
-
[relaton-bipm] ("BIPM
|
|
99
|
-
[relaton-bipm] ("BIPM
|
|
96
|
+
item = RelatonBipm::BipmBibliography.get "BIPM SI Brochure"
|
|
97
|
+
[relaton-bipm] ("BIPM SI Brochure") fetching...
|
|
98
|
+
[relaton-bipm] ("BIPM SI Brochure") found BIPM SI Brochure
|
|
100
99
|
=> #<RelatonBipm::BipmBibliographicItem:0x007ffb83982fe8
|
|
101
100
|
...
|
|
102
101
|
|
|
103
|
-
# get BIPM Metrologia
|
|
102
|
+
# get BIPM Metrologia page
|
|
104
103
|
bib = RelatonBipm::BipmBibliography.get "BIPM Metrologia 29 6 373"
|
|
105
104
|
[relaton-bipm] ("BIPM Metrologia 29 6 373") fetching...
|
|
106
105
|
[relaton-bipm] ("BIPM Metrologia 29 6 373") found Metrologia 29 6 373
|
|
@@ -172,11 +171,12 @@ RelatonBipm::BipmBibliography.get "CIPM Recommendation 1948"
|
|
|
172
171
|
[source,ruby]
|
|
173
172
|
----
|
|
174
173
|
item.to_xml
|
|
175
|
-
=> "<bibitem id="
|
|
174
|
+
=> "<bibitem id="BIPMSIBrochure" type="standard">
|
|
176
175
|
<fetched>2021-01-10</fetched>
|
|
177
176
|
<title format="text/plain" language="en" script="Latn">The International System of Units (SI)</title>
|
|
178
177
|
<title format="text/plain" language="fr" script="Latn">Le Système international d’unités (SI)</title>
|
|
179
|
-
<
|
|
178
|
+
<uri type="src">https://www.bipm.org/en/publications/si-brochure</uri>
|
|
179
|
+
<docidentifier type="BIPM">BIPM SI Brochure</docidentifier>
|
|
180
180
|
<date type="updated">
|
|
181
181
|
<on>2019-05-20</on>
|
|
182
182
|
</date>
|
|
@@ -205,7 +205,7 @@ item.to_xml bibdata: true
|
|
|
205
205
|
<title format="text/plain" language="en" script="Latn">The International System of Units (SI)</title>
|
|
206
206
|
<title format="text/plain" language="fr" script="Latn">Le Système international d’unités (SI)</title>
|
|
207
207
|
<uri type="src">https://www.bipm.org/en/publications/si-brochure</uri>
|
|
208
|
-
<docidentifier type="BIPM">
|
|
208
|
+
<docidentifier type="BIPM">BIPM SI Brochure</docidentifier>
|
|
209
209
|
<date type="updated">
|
|
210
210
|
<on>2019-05-20</on>
|
|
211
211
|
</date>
|
data/grammars/biblio.rng
CHANGED
|
@@ -225,9 +225,9 @@
|
|
|
225
225
|
<zeroOrMore>
|
|
226
226
|
<ref name="forename"/>
|
|
227
227
|
</zeroOrMore>
|
|
228
|
-
<
|
|
229
|
-
<ref name="
|
|
230
|
-
</
|
|
228
|
+
<optional>
|
|
229
|
+
<ref name="formatted-initials"/>
|
|
230
|
+
</optional>
|
|
231
231
|
<ref name="surname"/>
|
|
232
232
|
<zeroOrMore>
|
|
233
233
|
<ref name="addition"/>
|
|
@@ -247,8 +247,8 @@
|
|
|
247
247
|
<ref name="LocalizedString"/>
|
|
248
248
|
</element>
|
|
249
249
|
</define>
|
|
250
|
-
<define name="
|
|
251
|
-
<element name="
|
|
250
|
+
<define name="formatted-initials">
|
|
251
|
+
<element name="formatted-initials">
|
|
252
252
|
<ref name="LocalizedString"/>
|
|
253
253
|
</element>
|
|
254
254
|
</define>
|
|
@@ -264,6 +264,9 @@
|
|
|
264
264
|
</define>
|
|
265
265
|
<define name="forename">
|
|
266
266
|
<element name="forename">
|
|
267
|
+
<optional>
|
|
268
|
+
<attribute name="initial"/>
|
|
269
|
+
</optional>
|
|
267
270
|
<ref name="LocalizedString"/>
|
|
268
271
|
</element>
|
|
269
272
|
</define>
|
data/grammars/isodoc.rng
CHANGED
|
@@ -69,6 +69,17 @@
|
|
|
69
69
|
</zeroOrMore>
|
|
70
70
|
</element>
|
|
71
71
|
</define>
|
|
72
|
+
<define name="AdmonitionType">
|
|
73
|
+
<choice>
|
|
74
|
+
<value>warning</value>
|
|
75
|
+
<value>note</value>
|
|
76
|
+
<value>tip</value>
|
|
77
|
+
<value>important</value>
|
|
78
|
+
<value>caution</value>
|
|
79
|
+
<value>statement</value>
|
|
80
|
+
<value>editorial</value>
|
|
81
|
+
</choice>
|
|
82
|
+
</define>
|
|
72
83
|
<define name="index">
|
|
73
84
|
<element name="index">
|
|
74
85
|
<optional>
|
|
@@ -1274,7 +1285,12 @@
|
|
|
1274
1285
|
</define>
|
|
1275
1286
|
<define name="span">
|
|
1276
1287
|
<element name="span">
|
|
1277
|
-
<
|
|
1288
|
+
<optional>
|
|
1289
|
+
<attribute name="class"/>
|
|
1290
|
+
</optional>
|
|
1291
|
+
<optional>
|
|
1292
|
+
<attribute name="style"/>
|
|
1293
|
+
</optional>
|
|
1278
1294
|
<oneOrMore>
|
|
1279
1295
|
<ref name="TextElement"/>
|
|
1280
1296
|
</oneOrMore>
|
|
@@ -2493,6 +2509,16 @@
|
|
|
2493
2509
|
<text/>
|
|
2494
2510
|
</element>
|
|
2495
2511
|
</optional>
|
|
2512
|
+
<optional>
|
|
2513
|
+
<element name="amendment">
|
|
2514
|
+
<text/>
|
|
2515
|
+
</element>
|
|
2516
|
+
</optional>
|
|
2517
|
+
<optional>
|
|
2518
|
+
<element name="corrigendum">
|
|
2519
|
+
<text/>
|
|
2520
|
+
</element>
|
|
2521
|
+
</optional>
|
|
2496
2522
|
<optional>
|
|
2497
2523
|
<element name="language">
|
|
2498
2524
|
<text/>
|
|
@@ -15,11 +15,14 @@ module RelatonBipm
|
|
|
15
15
|
class << self
|
|
16
16
|
# @param text [String]
|
|
17
17
|
# @return [RelatonBipm::BipmBibliographicItem]
|
|
18
|
-
def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize
|
|
18
|
+
def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
19
19
|
warn "[relaton-bipm] (\"#{text}\") fetching..."
|
|
20
20
|
ref = text.sub(/^BIPM\s/, "")
|
|
21
21
|
item = ref.match?(/^Metrologia/i) ? get_metrologia(ref, magent) : get_bipm(ref, magent)
|
|
22
|
-
|
|
22
|
+
unless item
|
|
23
|
+
warn "[relaton-bipm] (\"#{text}\") not found."
|
|
24
|
+
return
|
|
25
|
+
end
|
|
23
26
|
|
|
24
27
|
warn("[relaton-bipm] (\"#{text}\") found #{item.docidentifier[0].id}")
|
|
25
28
|
item
|
|
@@ -216,11 +219,19 @@ module RelatonBipm
|
|
|
216
219
|
# @param art [String]
|
|
217
220
|
# @param agent [Mechanize]
|
|
218
221
|
# @return [RelatonBipm::BipmBibliographicItem]
|
|
219
|
-
def get_article_from_issue(vol, ish, art, agent)
|
|
222
|
+
def get_article_from_issue(vol, ish, art, agent) # rubocop:disable Metrics/MethodLength
|
|
220
223
|
url = issue_url vol, ish
|
|
221
224
|
rsp = agent.get url
|
|
222
225
|
check_response rsp
|
|
223
|
-
|
|
226
|
+
link = rsp.at("//div[@class='indexer'][.='#{art}']/../div/a")
|
|
227
|
+
unless link
|
|
228
|
+
arts = rsp.xpath("//div[@class='indexer']").map(&:text)
|
|
229
|
+
warn "[relaton-bipm] Page #{art} not found in \"BIPM Metrologia #{vol} #{ish}\" issue."
|
|
230
|
+
warn "[relaton-bipm] Availabe pages in the issue are: (#{arts.join(', ')})"
|
|
231
|
+
return
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
get_article link[:href], vol, ish, agent
|
|
224
235
|
end
|
|
225
236
|
|
|
226
237
|
# @param path [String]
|
|
@@ -329,11 +340,13 @@ module RelatonBipm
|
|
|
329
340
|
#
|
|
330
341
|
def check_response(rsp) # rubocop:disable Metrics/AbcSize
|
|
331
342
|
if rsp.code == "302"
|
|
343
|
+
warn "[relaton-bipm] This source employs anti-DDoS measures that unfortunately affects automated requests."
|
|
344
|
+
warn "[relaton-bipm] Please visit this link in your browser to resolve the CAPTCHA, then retry: #{rsp.uri}"
|
|
332
345
|
warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
|
|
333
|
-
raise RelatonBib::RequestError, "
|
|
346
|
+
raise RelatonBib::RequestError, "cannot access #{rsp.uri}"
|
|
334
347
|
elsif rsp.code != "200"
|
|
335
348
|
warn "[read_bipm] can't acces #{rsp.uri} #{rsp.code}"
|
|
336
|
-
raise RelatonBib::RequestError, "
|
|
349
|
+
raise RelatonBib::RequestError, "cannot acces #{rsp.uri} #{rsp.code}"
|
|
337
350
|
end
|
|
338
351
|
end
|
|
339
352
|
end
|
|
@@ -57,17 +57,24 @@ module RelatonBipm
|
|
|
57
57
|
# Parse SI brochure and write them to YAML files
|
|
58
58
|
#
|
|
59
59
|
def parse_si_brochure # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
60
|
+
# puts "Parsing SI brochure..."
|
|
61
|
+
# puts "Ls #{Dir['*']}"
|
|
62
|
+
# puts "Ls #{Dir['bipm-si-brochure/*']}"
|
|
63
|
+
# puts "Ls #{Dir['bipm-si-brochure/site/*']}"
|
|
64
|
+
# puts "Ls #{Dir['bipm-si-brochure/site/documents/*']}"
|
|
60
65
|
Dir["bipm-si-brochure/site/documents/*.rxl"].each do |f|
|
|
66
|
+
puts "Parsing #{f}"
|
|
61
67
|
docstd = Nokogiri::XML File.read f
|
|
62
68
|
doc = docstd.at "/bibdata"
|
|
63
69
|
hash1 = RelatonBipm::XMLParser.from_xml(doc.to_xml).to_hash
|
|
70
|
+
fix_si_brochure_id hash1
|
|
64
71
|
hash1["fetched"] = Date.today.to_s
|
|
65
|
-
hash1["docid"].detect { |id| id["type"] == "BIPM" }["primary"] = true
|
|
66
72
|
outfile = File.join @output, File.basename(f).sub(/(?:-(?:en|fr))?\.rxl$/, ".yaml")
|
|
67
73
|
@index[[hash1["docnumber"] || File.basename(outfile, ".yaml")]] = outfile
|
|
68
74
|
hash = if File.exist? outfile
|
|
69
75
|
warn_duplicate = false
|
|
70
76
|
hash2 = YAML.load_file outfile
|
|
77
|
+
fix_si_brochure_id hash2
|
|
71
78
|
deep_merge hash1, hash2
|
|
72
79
|
else
|
|
73
80
|
warn_duplicate = true
|
|
@@ -75,9 +82,33 @@ module RelatonBipm
|
|
|
75
82
|
end
|
|
76
83
|
item = RelatonBipm::BipmBibliographicItem.from_hash(**hash)
|
|
77
84
|
write_file outfile, item, warn_duplicate: warn_duplicate
|
|
85
|
+
puts "Saved to #{outfile}"
|
|
78
86
|
end
|
|
79
87
|
end
|
|
80
88
|
|
|
89
|
+
#
|
|
90
|
+
# Update ID of SI brochure
|
|
91
|
+
#
|
|
92
|
+
# @param [Hash] hash hash of bibitem
|
|
93
|
+
#
|
|
94
|
+
# @return [void]
|
|
95
|
+
#
|
|
96
|
+
def fix_si_brochure_id(hash) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
97
|
+
did = hash["docid"].detect { |id| id["type"] == "BIPM" }
|
|
98
|
+
did["primary"] = true
|
|
99
|
+
return unless did["id"] == "BIPM Brochure"
|
|
100
|
+
|
|
101
|
+
isbn = hash["docid"].detect { |id| id["type"] == "ISBN" }
|
|
102
|
+
num = if isbn && isbn["id"] == "978-92-822-2272-0"
|
|
103
|
+
"SI Brochure"
|
|
104
|
+
else
|
|
105
|
+
"SI Brochure, Appendix 4"
|
|
106
|
+
end
|
|
107
|
+
hash["id"] = hash["id"].sub(/(?<=^BIPM)Brochure$/i, num.gsub(/[,\s]/, ""))
|
|
108
|
+
hash["docnumber"] = hash["docnumber"].sub(/^Brochure$/i, num)
|
|
109
|
+
did["id"] = did["id"].sub(/(?<=^BIPM\s)Brochure$/i, num)
|
|
110
|
+
end
|
|
111
|
+
|
|
81
112
|
#
|
|
82
113
|
# Deep merge two hashes
|
|
83
114
|
#
|
|
@@ -117,9 +148,9 @@ module RelatonBipm
|
|
|
117
148
|
def fetch_type(dir, body) # rubocop:disable Metrics/AbcSize
|
|
118
149
|
type = dir.split("/").last.split("-").first.sub(/s$/, "")
|
|
119
150
|
body_dir = File.join @output, body.downcase
|
|
120
|
-
|
|
151
|
+
FileUtils.mkdir_p body_dir
|
|
121
152
|
outdir = File.join body_dir, type.downcase
|
|
122
|
-
|
|
153
|
+
FileUtils.mkdir_p outdir
|
|
123
154
|
Dir[File.join(dir, "*.{yml,yaml}")].each { |en_file| fetch_meeting en_file, body, type, outdir }
|
|
124
155
|
end
|
|
125
156
|
|
|
@@ -228,7 +259,7 @@ module RelatonBipm
|
|
|
228
259
|
file += "-#{num_justed}" if num.size < 4
|
|
229
260
|
file += ".yaml"
|
|
230
261
|
out_dir = File.join args[:dir], r["type"].downcase
|
|
231
|
-
|
|
262
|
+
FileUtils.mkdir_p out_dir
|
|
232
263
|
path = File.join out_dir, file
|
|
233
264
|
write_file path, item
|
|
234
265
|
@index[["#{args[:body]} #{type} #{year}-#{num_justed}", "#{args[:body]} #{type} #{args[:num]}-#{num_justed}"]] = path
|
data/lib/relaton_bipm/index.rb
CHANGED
data/lib/relaton_bipm/version.rb
CHANGED
|
@@ -23,17 +23,6 @@ module RelatonBipm
|
|
|
23
23
|
BipmBibliographicItem.new(**item_hash)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
# @param item [Nokogiri::XML::Element]
|
|
27
|
-
# @return [Array<RelatonBib::FormattedString>]
|
|
28
|
-
def fetch_titles(item)
|
|
29
|
-
item.xpath("./title").map do |t|
|
|
30
|
-
RelatonBib::TypedTitleString.new(
|
|
31
|
-
content: t.text, language: t[:language], script: t[:script],
|
|
32
|
-
format: t[:format]
|
|
33
|
-
)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
26
|
def fetch_dates(item) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
38
27
|
item.xpath("./date").reduce([]) do |a, d|
|
|
39
28
|
type = d[:type].to_s.empty? ? "published" : d[:type]
|
data/relaton_bipm.gemspec
CHANGED
|
@@ -42,7 +42,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
|
42
42
|
|
|
43
43
|
spec.add_dependency "faraday", "~> 1.0"
|
|
44
44
|
spec.add_dependency "mechanize", "~> 2.8.0"
|
|
45
|
-
spec.add_dependency "relaton-bib", "~> 1.
|
|
45
|
+
spec.add_dependency "relaton-bib", "~> 1.13.0"
|
|
46
46
|
spec.add_dependency "rubyzip", "~> 2.3.0"
|
|
47
47
|
spec.add_dependency "serrano", "~> 1.0"
|
|
48
48
|
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.
|
|
4
|
+
version: 1.13.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: 2022-08-
|
|
11
|
+
date: 2022-08-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: byebug
|
|
@@ -142,14 +142,14 @@ dependencies:
|
|
|
142
142
|
requirements:
|
|
143
143
|
- - "~>"
|
|
144
144
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: 1.
|
|
145
|
+
version: 1.13.0
|
|
146
146
|
type: :runtime
|
|
147
147
|
prerelease: false
|
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
149
|
requirements:
|
|
150
150
|
- - "~>"
|
|
151
151
|
- !ruby/object:Gem::Version
|
|
152
|
-
version: 1.
|
|
152
|
+
version: 1.13.0
|
|
153
153
|
- !ruby/object:Gem::Dependency
|
|
154
154
|
name: rubyzip
|
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|