relaton-bipm 1.13.1 → 1.13.4

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: edb89c4c5c98e541ba6c2b6dceb5e3c0133679d3058c88a28a873ef24a4b132d
4
- data.tar.gz: f73db142b9080babed9748cb846e803dd2b8fbe76764d644ce072f2d614be704
3
+ metadata.gz: 163a9f60eeb667aff478312eb3325fa8d89ac00f4ed11dda2d24be353c7dee38
4
+ data.tar.gz: 5cc2a287138fe56e118ec4d3ef10b13d2da5568e69f186c9d303fa99fbe33b69
5
5
  SHA512:
6
- metadata.gz: 9252968e4aafe5721c843620e3515046f5360f6e1b492f341fe951314ed7de7894941052959a6c9c4a0bda18eba4cdbac47857fa58a4c0065199540128215253
7
- data.tar.gz: 434e30bc8487085bf50d69b3be05443e53e235e813ba0a14937531a46b635a2eaa6fd919db4b1d21a2f96943c97a981b7704409963c8b77dd14f540b384dacc7
6
+ metadata.gz: e585b21ae150bda7dc70203d696f4bfd9e9903a3d0b7e66b1f73b0b86312a59c171b35ab0cfe1b9ab3bcf9bce6a02f496354d5df0c95d0aab4e1258e89936e77
7
+ data.tar.gz: 425b7ff50a80c6e6971c1bccc42330f5785cdad5afff6632a08f4eec1271b7416514c9ed5c4a5468c15790d13138c43fe27e4dde03c1c688166bcaec6fc1da4f
@@ -0,0 +1,22 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: release
4
+
5
+ on:
6
+ workflow_dispatch:
7
+ inputs:
8
+ next_version:
9
+ description: |
10
+ Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
+ required: true
12
+ default: 'skip'
13
+ push:
14
+ tags: [ v* ]
15
+
16
+ jobs:
17
+ release:
18
+ uses: relaton/support/.github/workflows/release.yml@master
19
+ with:
20
+ next_version: ${{ github.event.inputs.next_version }}
21
+ secrets:
22
+ rubygems-api-key: ${{ secrets.RELATON_CI_RUBYGEMS_API_KEY }}
data/README.adoc CHANGED
@@ -58,6 +58,7 @@ Allowed document names are:
58
58
  - SI MEP Mol1
59
59
  - SI MEP S1
60
60
  - SI Brochure
61
+ - SI Brochure, Appendix 4
61
62
 
62
63
  ==== Reference structire for Metrologia documents
63
64
 
@@ -239,7 +239,7 @@ module RelatonBipm
239
239
  # @param ish [String]
240
240
  # @param agent [Mechanize]
241
241
  # @return [RelatonBipm::BipmBibliographicItem]
242
- def get_article(path, vol, ish, agent) # rubocop:disable Metrics/AbcSize
242
+ def get_article(path, vol, ish, agent) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
243
243
  rsp = agent.get path
244
244
  check_response rsp
245
245
  url = rsp.uri
@@ -247,16 +247,19 @@ module RelatonBipm
247
247
  rsp = agent.get bib
248
248
  check_response rsp
249
249
  bt = BibTeX.parse(rsp.body).first
250
- bibitem(docid: btdocid(bt), title: titles(bt.title.to_s), abstract: btabstract(bt), doctype: bt.type.to_s,
251
- link: btlink(bt, url), date: btdate(bt), contributor: btcontrib(bt), series: series,
252
- extent: btextent(vol, ish, bt))
250
+ bibitem(
251
+ docid: btdocid(bt), title: titles(bt.title.to_s), date: btdate(bt),
252
+ abstract: btabstract(bt), doctype: bt.type.to_s, series: series,
253
+ link: btlink(bt, url), contributor: btcontrib(bt),
254
+ extent: btextent(vol, ish, bt.pages.to_s)
255
+ )
253
256
  end
254
257
 
255
258
  # @param args [Hash]
256
259
  # @return [RelatonBipm::BipmBibliographicItem]
257
260
  def bibitem(**args)
258
261
  BipmBibliographicItem.new(
259
- fetched: Date.today.to_s, type: "standard", language: ["en"], script: ["Latn"], **args,
262
+ fetched: Date.today.to_s, type: "article", language: ["en"], script: ["Latn"], **args,
260
263
  )
261
264
  end
262
265
 
@@ -269,7 +272,10 @@ module RelatonBipm
269
272
  # @return [Array<RelatonBib::DocumentIdentifier>]
270
273
  def btdocid(bibtex)
271
274
  id = "#{bibtex.journal} #{bibtex.volume} #{bibtex.number} #{bibtex.pages.match(/^\d+/)}"
272
- [RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id)]
275
+ [
276
+ RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id, primary: true),
277
+ RelatonBib::DocumentIdentifier.new(type: "DOI", id: bibtex.doi),
278
+ ]
273
279
  end
274
280
 
275
281
  # @param bibtex [BibTeX::Entry]
@@ -309,14 +315,17 @@ module RelatonBipm
309
315
  ]
310
316
  end
311
317
 
312
- # @param vol [String]
313
- # @param ish [String]
314
- # @param bibtex [BibTeX::Entry]
318
+ #
319
+ # @param vol [String] volume
320
+ # @param ish [String] issue
321
+ # @param pgs [String] pages
322
+ #
315
323
  # @return [Array<RelatonBib::BibItemLocality>]
316
- def btextent(vol, ish = nil, bibtex = nil)
317
- ext = [RelatonBib::BibItemLocality.new("volume", vol)]
318
- ext << RelatonBib::BibItemLocality.new("issue", ish) if ish
319
- ext << RelatonBib::BibItemLocality.new("page", *bibtex.pages.split("--")) if bibtex
324
+ #
325
+ def btextent(vol, ish = nil, pgs = nil)
326
+ ext = [RelatonBib::Locality.new("volume", vol)]
327
+ ext << RelatonBib::Locality.new("issue", ish) if ish
328
+ ext << RelatonBib::Locality.new("page", *pgs.split("--")) if pgs
320
329
  ext
321
330
  end
322
331
 
@@ -342,7 +351,7 @@ module RelatonBipm
342
351
  if rsp.code == "302"
343
352
  warn "[relaton-bipm] This source employs anti-DDoS measures that unfortunately affects automated requests."
344
353
  warn "[relaton-bipm] Please visit this link in your browser to resolve the CAPTCHA, then retry: #{rsp.uri}"
345
- warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
354
+ # warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
346
355
  raise RelatonBib::RequestError, "cannot access #{rsp.uri}"
347
356
  elsif rsp.code != "200"
348
357
  warn "[read_bipm] can't acces #{rsp.uri} #{rsp.code}"
@@ -63,8 +63,6 @@ module RelatonBipm
63
63
  # puts "Ls #{Dir['bipm-si-brochure/site/*']}"
64
64
  # puts "Ls #{Dir['bipm-si-brochure/site/documents/*']}"
65
65
  Dir["bipm-si-brochure/site/documents/*.rxl"].each do |f|
66
- next if f.include?("sib-a4")
67
-
68
66
  puts "Parsing #{f}"
69
67
  docstd = Nokogiri::XML File.read f
70
68
  doc = docstd.at "/bibdata"
@@ -88,12 +86,27 @@ module RelatonBipm
88
86
  end
89
87
  end
90
88
 
91
- def fix_si_brochure_id(hash)
92
- hash["id"] = hash["id"].sub(/^BIPMBrochure$/, "BIPMSIBrochure")
93
- hash["docnumber"] = hash["docnumber"].sub(/^Brochure$/i, "SI Brochure")
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
94
97
  did = hash["docid"].detect { |id| id["type"] == "BIPM" }
95
98
  did["primary"] = true
96
- did["id"] = did["id"].sub(/^BIPM Brochure$/, "BIPM SI Brochure")
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)
97
110
  end
98
111
 
99
112
  #
@@ -205,7 +218,10 @@ module RelatonBipm
205
218
  #
206
219
  def fetch_resolution(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
207
220
  args[:en]["resolutions"].each.with_index do |r, i| # rubocop:disable Metrics/BlockLength
208
- hash = { fetched: Date.today.to_s, title: [], doctype: r["type"] }
221
+ hash = {
222
+ type: "proceedings", fetched: Date.today.to_s, title: [],
223
+ doctype: r["type"], place: [RelatonBib::Place.new(city: "Paris")]
224
+ }
209
225
  hash[:title] << title(r["title"], "en") if r["title"]
210
226
  fr_resolution = args[:fr]["resolutions"].fetch(i, nil)
211
227
  if fr_resolution
@@ -287,7 +303,8 @@ module RelatonBipm
287
303
  # @return [Hash] Hash of BIPM meeting/resolution
288
304
  #
289
305
  def bibitem(**args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
290
- hash = { title: [], doctype: args[:type], fetched: Date.today.to_s }
306
+ hash = { title: [], type: "proceedings", doctype: args[:type],
307
+ fetched: Date.today.to_s, place: [RelatonBib::Place.new(city: "Paris")] }
291
308
  hash[:title] << title(args[:en]["title"], "en") if args[:en]["title"]
292
309
  hash[:title] << title(args[:fr]["title"], "fr") if args[:fr]["title"]
293
310
  hash[:date] = [{ type: "published", on: args[:en]["date"] }]
@@ -1,3 +1,3 @@
1
1
  module RelatonBipm
2
- VERSION = "1.13.1".freeze
2
+ VERSION = "1.13.4".freeze
3
3
  end
@@ -23,29 +23,18 @@ 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
- def fetch_dates(item) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
38
- item.xpath("./date").reduce([]) do |a, d|
39
- type = d[:type].to_s.empty? ? "published" : d[:type]
40
- if (on = d.at("on"))
41
- a << BibliographicDate.new(type: type, on: on.text,
42
- to: d.at("to")&.text)
43
- elsif (from = d.at("from"))
44
- a << BibliographicDate.new(type: type, from: from.text,
45
- to: d.at("to")&.text)
46
- end
47
- end
48
- end
26
+ # def fetch_dates(item) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
27
+ # item.xpath("./date").reduce([]) do |a, d|
28
+ # type = d[:type].to_s.empty? ? "published" : d[:type]
29
+ # if (on = d.at("on"))
30
+ # a << BibliographicDate.new(type: type, on: on.text,
31
+ # to: d.at("to")&.text)
32
+ # elsif (from = d.at("from"))
33
+ # a << BibliographicDate.new(type: type, from: from.text,
34
+ # to: d.at("to")&.text)
35
+ # end
36
+ # end
37
+ # end
49
38
 
50
39
  # @param item [Nokogiri::XML::Element]
51
40
  # @param klass [RelatonBipm::DocumentRelation.class]
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.13.1
4
+ version: 1.13.4
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-31 00:00:00.000000000 Z
11
+ date: 2022-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -187,6 +187,7 @@ extensions: []
187
187
  extra_rdoc_files: []
188
188
  files:
189
189
  - ".github/workflows/rake.yml"
190
+ - ".github/workflows/release.yml"
190
191
  - ".gitignore"
191
192
  - ".rspec"
192
193
  - ".rubocop.yml"