relaton-bipm 1.8.2 → 1.9.0

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: 3f50f16e84fc01b3abbf19cac52ba2ebb265e5bb9dee2d5bc3b9838cc9246842
4
- data.tar.gz: 96358aff1452e3bcd2577b1f7e812c840b6a868348c7c4e813018761d07158b5
3
+ metadata.gz: a37dd98a306be1bde644dfe27bc307910628ec86f85a28c217ae2c23557a803b
4
+ data.tar.gz: a1d913261195a1ea7000610575be81e01c0b17b41041f6793e36612e5aa0e7ee
5
5
  SHA512:
6
- metadata.gz: 16d31cad3f3ebc75b1e0e0d36dded2b348c9c8e66f33ac06f512cb2dab120a98f5104b784d5269a8294fd222679861cc9dab71ec34be5ff94b859771bd5efc6b
7
- data.tar.gz: 232e89f4a68d18ebcfaba7ecf52a17a7a06950e42e65fdc50cb95dcf29476176f82d62ad7e635939e2ba6f9ff3525f2ff263db20660f0876d02fcd46458a6913
6
+ metadata.gz: b7ed6f8ffa91da6c628398f1b17e840c674367a44d25be5034b2a3faa9f118a28f52a9a5c77d4106fec0a00ffa11473cbb8e7c7e9b87e22d6c7698c549dbe8ca
7
+ data.tar.gz: 12995c75ce50f208205f88450bb24d7d1f9e40f7cb1b17485d96fc7b6f86519538231d53ba9faf34447304a854999da6df2fd09a0b34545be782af879217e85d
@@ -16,19 +16,9 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '2.7', '2.6', '2.5' ]
19
+ ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
- include:
23
- - ruby: '3.0'
24
- os: 'ubuntu-latest'
25
- experimental: true
26
- - ruby: '3.0'
27
- os: 'windows-latest'
28
- experimental: true
29
- - ruby: '3.0'
30
- os: 'macos-latest'
31
- experimental: true
32
22
  steps:
33
23
  - uses: actions/checkout@v2
34
24
  with:
data/grammars/biblio.rng CHANGED
@@ -787,6 +787,7 @@
787
787
  <value>adapted</value>
788
788
  <value>vote-started</value>
789
789
  <value>vote-ended</value>
790
+ <value>announced</value>
790
791
  </choice>
791
792
  </define>
792
793
  <define name="bdate">
data/grammars/bipm.rng CHANGED
@@ -245,6 +245,9 @@
245
245
  <optional>
246
246
  <ref name="doctype"/>
247
247
  </optional>
248
+ <optional>
249
+ <ref name="docsubtype"/>
250
+ </optional>
248
251
  <ref name="editorialgroup"/>
249
252
  <optional>
250
253
  <ref name="comment-period"/>
data/grammars/isodoc.rng CHANGED
@@ -45,6 +45,11 @@
45
45
  <optional>
46
46
  <attribute name="alt"/>
47
47
  </optional>
48
+ <optional>
49
+ <attribute name="updatetype">
50
+ <data type="boolean"/>
51
+ </attribute>
52
+ </optional>
48
53
  <text/>
49
54
  </element>
50
55
  </define>
@@ -199,6 +204,18 @@
199
204
  </zeroOrMore>
200
205
  </element>
201
206
  </define>
207
+ <define name="dt">
208
+ <element name="dt">
209
+ <optional>
210
+ <attribute name="id">
211
+ <data type="ID"/>
212
+ </attribute>
213
+ </optional>
214
+ <zeroOrMore>
215
+ <ref name="TextElement"/>
216
+ </zeroOrMore>
217
+ </element>
218
+ </define>
202
219
  <define name="example">
203
220
  <element name="example">
204
221
  <attribute name="id">
@@ -543,6 +560,9 @@
543
560
  </define>
544
561
  <define name="BibDataExtensionType">
545
562
  <ref name="doctype"/>
563
+ <optional>
564
+ <ref name="docsubtype"/>
565
+ </optional>
546
566
  <optional>
547
567
  <ref name="editorialgroup"/>
548
568
  </optional>
@@ -890,6 +910,14 @@
890
910
  </define>
891
911
  </include>
892
912
  <!-- end overrides -->
913
+ <define name="docsubtype">
914
+ <element name="subdoctype">
915
+ <ref name="DocumentSubtype"/>
916
+ </element>
917
+ </define>
918
+ <define name="DocumentSubtype">
919
+ <text/>
920
+ </define>
893
921
  <define name="colgroup">
894
922
  <element name="colgroup">
895
923
  <oneOrMore>
@@ -939,7 +967,34 @@
939
967
  <define name="concept">
940
968
  <element name="concept">
941
969
  <optional>
942
- <attribute name="term"/>
970
+ <attribute name="ital">
971
+ <data type="boolean"/>
972
+ </attribute>
973
+ </optional>
974
+ <optional>
975
+ <attribute name="ref">
976
+ <data type="boolean"/>
977
+ </attribute>
978
+ </optional>
979
+ <optional>
980
+ <element name="refterm">
981
+ <zeroOrMore>
982
+ <choice>
983
+ <ref name="PureTextElement"/>
984
+ <ref name="stem"/>
985
+ </choice>
986
+ </zeroOrMore>
987
+ </element>
988
+ </optional>
989
+ <optional>
990
+ <element name="renderterm">
991
+ <zeroOrMore>
992
+ <choice>
993
+ <ref name="PureTextElement"/>
994
+ <ref name="stem"/>
995
+ </choice>
996
+ </zeroOrMore>
997
+ </element>
943
998
  </optional>
944
999
  <choice>
945
1000
  <ref name="eref"/>
@@ -965,6 +1020,9 @@
965
1020
  </attribute>
966
1021
  <attribute name="name"/>
967
1022
  <attribute name="action"/>
1023
+ <optional>
1024
+ <attribute name="class"/>
1025
+ </optional>
968
1026
  <zeroOrMore>
969
1027
  <choice>
970
1028
  <ref name="TextElement"/>
@@ -1191,13 +1249,17 @@
1191
1249
  </define>
1192
1250
  <define name="IsoWorkgroup">
1193
1251
  <optional>
1194
- <attribute name="number">
1195
- <data type="int"/>
1196
- </attribute>
1252
+ <attribute name="number"/>
1197
1253
  </optional>
1198
1254
  <optional>
1199
1255
  <attribute name="type"/>
1200
1256
  </optional>
1257
+ <optional>
1258
+ <attribute name="identifier"/>
1259
+ </optional>
1260
+ <optional>
1261
+ <attribute name="prefix"/>
1262
+ </optional>
1201
1263
  <text/>
1202
1264
  </define>
1203
1265
  <define name="ics">
@@ -1459,26 +1521,26 @@
1459
1521
  <optional>
1460
1522
  <ref name="section-title"/>
1461
1523
  </optional>
1462
- <group>
1524
+ <choice>
1463
1525
  <choice>
1464
1526
  <group>
1465
- <zeroOrMore>
1527
+ <oneOrMore>
1466
1528
  <ref name="BasicBlock"/>
1467
- </zeroOrMore>
1529
+ </oneOrMore>
1468
1530
  <zeroOrMore>
1469
1531
  <ref name="note"/>
1470
1532
  </zeroOrMore>
1471
1533
  </group>
1472
1534
  <ref name="amend"/>
1473
1535
  </choice>
1474
- <zeroOrMore>
1536
+ <oneOrMore>
1475
1537
  <choice>
1476
1538
  <ref name="clause-subsection"/>
1477
1539
  <ref name="terms"/>
1478
1540
  <ref name="definitions"/>
1479
1541
  </choice>
1480
- </zeroOrMore>
1481
- </group>
1542
+ </oneOrMore>
1543
+ </choice>
1482
1544
  </define>
1483
1545
  <define name="Annex-Section">
1484
1546
  <optional>
@@ -46,7 +46,7 @@ module RelatonBipm
46
46
  # @return [RelatonBipm::BipmBibliographicItem]
47
47
  def self.from_hash(hash)
48
48
  item_hash = ::RelatonBipm::HashConverter.hash_to_bib(hash)
49
- new **item_hash
49
+ new(**item_hash)
50
50
  end
51
51
 
52
52
  # @param opts [Hash]
@@ -83,7 +83,7 @@ module RelatonBipm
83
83
  # @param prefix [String]
84
84
  # @return [String]
85
85
  def to_asciibib(prefix = "")
86
- pref = prefix.empty? ? prefix : prefix + "."
86
+ pref = prefix.empty? ? prefix : "#{prefix}."
87
87
  out = super
88
88
  out += comment_period.to_asciibib prefix if comment_period
89
89
  out += "#{pref}si_aspect:: #{si_aspect}\n" if si_aspect
@@ -4,38 +4,11 @@ module RelatonBipm
4
4
  class BipmBibliography
5
5
  GH_ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-bipm/master/data/".freeze
6
6
  IOP_DOMAIN = "https://iopscience.iop.org".freeze
7
- USERAGENTS = [
8
- "Mozilla/5.0 CK={} (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
9
- "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36",
10
- "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)",
11
- "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)",
12
- "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
13
- "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; KTXN)",
14
- "Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1",
15
- "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",
16
- "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0",
17
- "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1",
18
- "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36",
19
- "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)",
20
- "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36",
21
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko)",
22
- "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko",
23
- "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",
24
- "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
25
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko)",
26
- "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)",
27
- "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko",
28
- "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)",
29
- "Mozilla/5.0 (Linux; U; Android 2.2) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
30
- "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36",
31
- "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.83 Safari/537.1",
32
- "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)",
33
- ].freeze
34
7
 
35
8
  class << self
36
9
  # @param text [String]
37
10
  # @return [RelatonBipm::BipmBibliographicItem]
38
- def search(text, _year = nil, _opts = {})
11
+ def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize
39
12
  warn "[relaton-bipm] (\"#{text}\") fetching..."
40
13
  ref = text.sub(/^BIPM\s/, "")
41
14
  item = ref.match?(/^Metrologia/i) ? get_metrologia(ref, magent) : get_bipm(ref, magent)
@@ -48,7 +21,7 @@ module RelatonBipm
48
21
  end
49
22
 
50
23
  # @return [Mechanize]
51
- def magent
24
+ def magent # rubocop:disable Metrics/MethodLength
52
25
  a = Mechanize.new
53
26
  a.request_headers = {
54
27
  "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,"\
@@ -57,8 +30,8 @@ module RelatonBipm
57
30
  "Accept-Language" => "en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7",
58
31
  "Cache-Control" => "max-age=0",
59
32
  "Upgrade-Insecure-Requests" => "1",
60
- "User-Agent" => USERAGENTS.shuffle.first,
61
33
  }
34
+ a.user_agent_alias = Mechanize::AGENT_ALIASES.map(&:first).shuffle.first
62
35
  a
63
36
  end
64
37
 
@@ -66,12 +39,12 @@ module RelatonBipm
66
39
  # @param agent [Mechanize]
67
40
  # @return [RelatonBipm::BipmBibliographicItem]
68
41
  def get_bipm(ref, agent)
69
- url = "#{GH_ENDPOINT}#{ref.downcase.split(' ').join '-'}.yaml"
42
+ url = "#{GH_ENDPOINT}#{ref.downcase.split.join '-'}.yaml"
70
43
  resp = agent.get url
71
44
  return unless resp.code == "200"
72
45
 
73
46
  bib_hash = HashConverter.hash_to_bib YAML.safe_load(resp.body, [Date])
74
- BipmBibliographicItem.new **bib_hash
47
+ BipmBibliographicItem.new(**bib_hash)
75
48
  end
76
49
 
77
50
  # @param ref [String]
@@ -79,7 +52,7 @@ module RelatonBipm
79
52
  # @return [RelatonBipm::BipmBibliographicItem]
80
53
  def get_metrologia(ref, agent)
81
54
  agent.redirect_ok = false
82
- ref_arr = ref.split(" ")
55
+ ref_arr = ref.split
83
56
  case ref_arr.size
84
57
  when 1 then get_journal agent
85
58
  when 2 then get_volume ref_arr[1], agent
@@ -91,7 +64,7 @@ module RelatonBipm
91
64
  # @param agent [Mechanize]
92
65
  # @return [RelatonBipm::BipmBibliographicItem]
93
66
  def get_journal(agent)
94
- url = IOP_DOMAIN + "/journal/0026-1394"
67
+ url = "#{IOP_DOMAIN}/journal/0026-1394"
95
68
  rsp = agent.get url
96
69
  rel = rsp.xpath('//select[@id="allVolumesSelector"]/option').map do |v|
97
70
  { type: "partOf", bibitem: journal_rel(v) }
@@ -129,7 +102,7 @@ module RelatonBipm
129
102
  docid = doc_id [vol, ish]
130
103
  t = elm.at "p"
131
104
  title_fref = t ? { title: titles(t.text) } : { formattedref: fref(docid.id) }
132
- BipmBibliographicItem.new **title_fref, docid: [docid], link: blink(url)
105
+ BipmBibliographicItem.new(**title_fref, docid: [docid], link: blink(url))
133
106
  end
134
107
 
135
108
  # @param title [String]
@@ -248,7 +221,7 @@ module RelatonBipm
248
221
  # @return [RelatonBipm::BipmBibliographicItem]
249
222
  def bibitem(**args)
250
223
  BipmBibliographicItem.new(
251
- fetched: Date.today.to_s, type: "standard", language: ["en"], script: ["Latn"], **args
224
+ fetched: Date.today.to_s, type: "standard", language: ["en"], script: ["Latn"], **args,
252
225
  )
253
226
  end
254
227
 
@@ -291,7 +264,7 @@ module RelatonBipm
291
264
  # @return [Array<Hash>]
292
265
  def btcontrib(bibtex)
293
266
  surname, initial = bibtex.author.split ", "
294
- initial = initial.split(" ").map { |i| RelatonBib::LocalizedString.new i, "en", "Latn" }
267
+ initial = initial.split.map { |i| RelatonBib::LocalizedString.new i, "en", "Latn" }
295
268
  surname = RelatonBib::LocalizedString.new surname, "en", "Latn"
296
269
  name = RelatonBib::FullName.new surname: surname, initial: initial
297
270
  author = RelatonBib::Person.new name: name
@@ -31,7 +31,7 @@ module RelatonBipm
31
31
  # @param prefix [String]
32
32
  # @return [String]
33
33
  def to_asciibib(prefix)
34
- pref = prefix.empty? ? prefix : prefix + "."
34
+ pref = prefix.empty? ? prefix : "#{prefix}."
35
35
  pref += "commentperiod"
36
36
  out = "#{pref}.from:: #{from}\n"
37
37
  out += "#{pref}.to:: #{to}\n" if to
@@ -28,7 +28,7 @@ module RelatonBipm
28
28
  # @param count [Integer]
29
29
  # @return [String]
30
30
  def to_asciibib(prefix, count = 1)
31
- pref = prefix.empty? ? prefix : prefix + "."
31
+ pref = prefix.empty? ? prefix : "#{prefix}."
32
32
  pref += "committee"
33
33
  out = count > 1 ? "#{pref}::\n" : ""
34
34
  out += "#{pref}.acronym:: #{acronym}\n"
@@ -39,8 +39,9 @@ module RelatonBipm
39
39
  def to_hash
40
40
  hash = { "acronym" => acronym }
41
41
  cnt = content.to_hash
42
- if cnt.is_a? Array then hash["variants"] = cnt
43
- elsif cnt.is_a? Hash then hash.merge! cnt
42
+ case cnt
43
+ when Array then hash["variants"] = cnt
44
+ when Hash then hash.merge! cnt
44
45
  else hash["content"] = cnt
45
46
  end
46
47
  hash
@@ -23,7 +23,7 @@ module RelatonBipm
23
23
  # @param prefix [String]
24
24
  # @return [String]
25
25
  def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize
26
- pref = prefix.empty? ? prefix : prefix + "."
26
+ pref = prefix.empty? ? prefix : "#{prefix}."
27
27
  pref += "editorialgroup"
28
28
  out = ""
29
29
  committee.each { |c| out += c.to_asciibib pref, committee.size }
@@ -23,14 +23,13 @@ module RelatonBipm
23
23
  # @param item_hash [Hash]
24
24
  # @return [RelatonBib::BibliographicItem]
25
25
  def bib_item(item_hash)
26
- BipmBibliographicItem.new **item_hash
26
+ BipmBibliographicItem.new(**item_hash)
27
27
  end
28
28
 
29
29
  # @param ret [Hash]
30
30
  def title_hash_to_bib(ret)
31
- ret[:title] &&= array(ret[:title]).reduce(
32
- RelatonBib::TypedTitleStringCollection.new
33
- ) do |m, t|
31
+ ret[:title] &&= array(ret[:title])
32
+ .reduce(RelatonBib::TypedTitleStringCollection.new) do |m, t|
34
33
  m << if t.is_a? Hash
35
34
  RelatonBib::TypedTitleString.new(**t)
36
35
  else
@@ -55,16 +54,14 @@ module RelatonBipm
55
54
  # @param ret [Hash]
56
55
  def dates_hash_to_bib(ret)
57
56
  super
58
- ret[:date] &&= ret[:date].map do |d|
59
- BibliographicDate.new **d
60
- end
57
+ ret[:date] &&= ret[:date].map { |d| BibliographicDate.new(**d) }
61
58
  end
62
59
 
63
60
  # @param ret [Hash]
64
61
  def relations_hash_to_bib(ret)
65
62
  super
66
63
  ret[:relation] &&= ret[:relation].map do |r|
67
- RelatonBipm::DocumentRelation.new **r
64
+ RelatonBipm::DocumentRelation.new(**r)
68
65
  end
69
66
  end
70
67
 
@@ -77,7 +74,7 @@ module RelatonBipm
77
74
  content = RelatonBib::LocalizedString.new vars
78
75
  Committee.new acronym: c[:acronym], content: content
79
76
  else
80
- Committee.new **c
77
+ Committee.new(**c)
81
78
  end
82
79
  end
83
80
  wg = array(ret[:editorialgroup][:workgroup]).map do |w|
@@ -100,7 +97,7 @@ module RelatonBipm
100
97
  # @param ret [Hash]
101
98
  def structuredidentifier_hash_to_bib(ret)
102
99
  ret[:structuredidentifier] &&= StructuredIdentifier.new(
103
- **ret[:structuredidentifier]
100
+ **ret[:structuredidentifier],
104
101
  )
105
102
  end
106
103
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonBipm
2
- VERSION = "1.8.2".freeze
2
+ VERSION = "1.9.0".freeze
3
3
  end
@@ -20,7 +20,7 @@ module RelatonBipm
20
20
  # @param item_hash [Hash]
21
21
  # @return [RelatonBipm::BipmBibliographicItem]
22
22
  def bib_item(item_hash)
23
- BipmBibliographicItem.new **item_hash
23
+ BipmBibliographicItem.new(**item_hash)
24
24
  end
25
25
 
26
26
  # @param item [Nokogiri::XML::Element]
data/relaton_bipm.gemspec CHANGED
@@ -44,6 +44,6 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
44
44
  spec.add_development_dependency "webmock"
45
45
 
46
46
  spec.add_dependency "mechanize", "~> 2.8.0"
47
- spec.add_dependency "relaton-bib", "~> 1.8.0"
47
+ spec.add_dependency "relaton-bib", "~> 1.9.0"
48
48
  spec.add_dependency "serrano", "~> 1.0"
49
49
  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.8.2
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-01 00:00:00.000000000 Z
11
+ date: 2021-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.8.0
131
+ version: 1.9.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.8.0
138
+ version: 1.9.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: serrano
141
141
  requirement: !ruby/object:Gem::Requirement