relaton-bipm 1.9.0 → 1.10.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.
data/grammars/reqt.rng CHANGED
@@ -58,15 +58,23 @@
58
58
  <optional>
59
59
  <attribute name="type"/>
60
60
  </optional>
61
+ <optional>
62
+ <attribute name="tag"/>
63
+ </optional>
64
+ <optional>
65
+ <attribute name="multilingual-rendering">
66
+ <ref name="MultilingualRenderingType"/>
67
+ </attribute>
68
+ </optional>
61
69
  <optional>
62
70
  <ref name="reqtitle"/>
63
71
  </optional>
64
72
  <optional>
65
73
  <ref name="label"/>
66
74
  </optional>
67
- <optional>
75
+ <zeroOrMore>
68
76
  <ref name="subject"/>
69
- </optional>
77
+ </zeroOrMore>
70
78
  <zeroOrMore>
71
79
  <ref name="reqinherit"/>
72
80
  </zeroOrMore>
@@ -80,6 +88,7 @@
80
88
  <ref name="verification"/>
81
89
  <ref name="import"/>
82
90
  <ref name="description"/>
91
+ <ref name="component"/>
83
92
  </choice>
84
93
  </zeroOrMore>
85
94
  <optional>
@@ -100,17 +109,23 @@
100
109
  </define>
101
110
  <define name="label">
102
111
  <element name="label">
103
- <text/>
112
+ <oneOrMore>
113
+ <ref name="TextElement"/>
114
+ </oneOrMore>
104
115
  </element>
105
116
  </define>
106
117
  <define name="subject">
107
118
  <element name="subject">
108
- <text/>
119
+ <oneOrMore>
120
+ <ref name="TextElement"/>
121
+ </oneOrMore>
109
122
  </element>
110
123
  </define>
111
124
  <define name="reqinherit">
112
125
  <element name="inherit">
113
- <text/>
126
+ <oneOrMore>
127
+ <ref name="TextElement"/>
128
+ </oneOrMore>
114
129
  </element>
115
130
  </define>
116
131
  <define name="measurementtarget">
@@ -138,6 +153,12 @@
138
153
  <ref name="RequirementSubpart"/>
139
154
  </element>
140
155
  </define>
156
+ <define name="component">
157
+ <element name="component">
158
+ <attribute name="class"/>
159
+ <ref name="RequirementSubpart"/>
160
+ </element>
161
+ </define>
141
162
  <define name="reqt_references">
142
163
  <element name="references">
143
164
  <oneOrMore>
@@ -164,6 +185,14 @@
164
185
  <data type="boolean"/>
165
186
  </attribute>
166
187
  </optional>
188
+ <optional>
189
+ <attribute name="tag"/>
190
+ </optional>
191
+ <optional>
192
+ <attribute name="multilingual-rendering">
193
+ <ref name="MultilingualRenderingType"/>
194
+ </attribute>
195
+ </optional>
167
196
  <oneOrMore>
168
197
  <ref name="BasicBlock"/>
169
198
  </oneOrMore>
@@ -28,12 +28,12 @@ module RelatonBipm
28
28
  def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
29
29
  if args[:docstatus] && !STATUSES.include?(args[:docstatus].stage.value)
30
30
  warn "[relaton-bipm] Warning: invalid docstatus: #{args[:docstatus].stage.value}. "\
31
- "It should be one of: #{STATUSES}"
31
+ "It should be one of: #{STATUSES}"
32
32
  end
33
33
 
34
34
  if args[:si_aspect] && !SI_ASPECTS.include?(args[:si_aspect])
35
35
  warn "[relaton-bipm] Warning: invalid si_aspect: #{args[:si_aspect]}. "\
36
- "It should be one of: #{SI_ASPECTS}"
36
+ "It should be one of: #{SI_ASPECTS}"
37
37
  end
38
38
 
39
39
  @comment_period = args.delete :comment_period
@@ -24,8 +24,9 @@ module RelatonBipm
24
24
  def magent # rubocop:disable Metrics/MethodLength
25
25
  a = Mechanize.new
26
26
  a.request_headers = {
27
- "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,"\
28
- "*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
27
+ "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,"\
28
+ "image/avif,image/webp,image/apng,"\
29
+ "*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
29
30
  "Accept-Encoding" => "gzip, deflate, br",
30
31
  "Accept-Language" => "en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7",
31
32
  "Cache-Control" => "max-age=0",
@@ -39,8 +40,9 @@ module RelatonBipm
39
40
  # @param agent [Mechanize]
40
41
  # @return [RelatonBipm::BipmBibliographicItem]
41
42
  def get_bipm(ref, agent)
42
- url = "#{GH_ENDPOINT}#{ref.downcase.split.join '-'}.yaml"
43
+ url = "#{GH_ENDPOINT}#{ref.upcase.split.join '-'}.yaml"
43
44
  resp = agent.get url
45
+ check_response resp
44
46
  return unless resp.code == "200"
45
47
 
46
48
  bib_hash = HashConverter.hash_to_bib YAML.safe_load(resp.body, [Date])
@@ -66,6 +68,7 @@ module RelatonBipm
66
68
  def get_journal(agent)
67
69
  url = "#{IOP_DOMAIN}/journal/0026-1394"
68
70
  rsp = agent.get url
71
+ check_response rsp
69
72
  rel = rsp.xpath('//select[@id="allVolumesSelector"]/option').map do |v|
70
73
  { type: "partOf", bibitem: journal_rel(v) }
71
74
  end
@@ -87,6 +90,7 @@ module RelatonBipm
87
90
  def get_volume(vol, agent)
88
91
  url = "#{IOP_DOMAIN}/volume/0026-1394/#{vol}"
89
92
  rsp = agent.get url
93
+ check_response rsp
90
94
  rel = rsp.xpath('//li[@itemprop="hasPart"]').map do |i|
91
95
  { type: "partOf", bibitem: volume_rel(i, vol) }
92
96
  end
@@ -115,9 +119,10 @@ module RelatonBipm
115
119
  # @param ish [String]
116
120
  # @param agent [Mechanize]
117
121
  # @return [RelatonBipm::BipmBibliographicItem]
118
- def get_issue(vol, ish, agent) # rubocop:disable Metrics/AbcSize
122
+ def get_issue(vol, ish, agent) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
119
123
  url = issue_url vol, ish
120
124
  rsp = agent.get url
125
+ check_response rsp
121
126
  rel = rsp.xpath('//div[@class="art-list-item-body"]').map do |a|
122
127
  { type: "partOf", bibitem: issue_rel(a, vol, ish) }
123
128
  end
@@ -187,7 +192,7 @@ module RelatonBipm
187
192
  # @return [RelatonBib::DocumentIdentifier]
188
193
  def doc_id(args)
189
194
  id = args.clone.unshift "Metrologia"
190
- RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id.join(" "))
195
+ RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id.join(" "), primary: true)
191
196
  end
192
197
 
193
198
  # @param vol [String]
@@ -198,6 +203,7 @@ module RelatonBipm
198
203
  def get_article_from_issue(vol, ish, art, agent)
199
204
  url = issue_url vol, ish
200
205
  rsp = agent.get url
206
+ check_response rsp
201
207
  get_article rsp.at("//div[@class='indexer'][.='#{art}']/../div/a")[:href], vol, ish, agent
202
208
  end
203
209
 
@@ -208,9 +214,11 @@ module RelatonBipm
208
214
  # @return [RelatonBipm::BipmBibliographicItem]
209
215
  def get_article(path, vol, ish, agent) # rubocop:disable Metrics/AbcSize
210
216
  rsp = agent.get path
217
+ check_response rsp
211
218
  url = rsp.uri
212
219
  bib = rsp.link_with(text: "BibTeX").href
213
220
  rsp = agent.get bib
221
+ check_response rsp
214
222
  bt = BibTeX.parse(rsp.body).first
215
223
  bibitem(docid: btdocid(bt), title: titles(bt.title.to_s), abstract: btabstract(bt), doctype: bt.type.to_s,
216
224
  link: btlink(bt, url), date: btdate(bt), contributor: btcontrib(bt), series: series,
@@ -292,6 +300,26 @@ module RelatonBipm
292
300
  def get(ref, year = nil, opts = {})
293
301
  search(ref, year, opts)
294
302
  end
303
+
304
+ private
305
+
306
+ #
307
+ # Check HTTP response. Warn and rise error if response is not 200
308
+ # or redirect to CAPTCHA.
309
+ #
310
+ # @param [Mechanize] rsp response
311
+ #
312
+ # @raise [RelatonBib::RequestError] if response is not 200
313
+ #
314
+ def check_response(rsp) # rubocop:disable Metrics/AbcSize
315
+ if rsp.code == "302"
316
+ warn "[relaton-bipm] #{rsp.uri} is redirected to #{rsp.header['location']}"
317
+ raise RelatonBib::RequestError, "redirected to #{rsp.header['location']}"
318
+ elsif rsp.code != "200"
319
+ warn "[read_bipm] can't acces #{rsp.uri} #{rsp.code}"
320
+ raise RelatonBib::RequestError, "can't acces #{rsp.uri} #{rsp.code}"
321
+ end
322
+ end
295
323
  end
296
324
  end
297
325
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonBipm
2
- VERSION = "1.9.0".freeze
2
+ VERSION = "1.10.2".freeze
3
3
  end
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.9.0"
47
+ spec.add_dependency "relaton-bib", "~> 1.10.1"
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.9.0
4
+ version: 1.10.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: 2021-08-26 00:00:00.000000000 Z
11
+ date: 2022-02-10 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.9.0
131
+ version: 1.10.1
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.9.0
138
+ version: 1.10.1
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: serrano
141
141
  requirement: !ruby/object:Gem::Requirement