relaton-bipm 1.8.2 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -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,17 +21,18 @@ 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
- "Accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,"\
55
- "*/*;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",
56
30
  "Accept-Encoding" => "gzip, deflate, br",
57
31
  "Accept-Language" => "en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7",
58
32
  "Cache-Control" => "max-age=0",
59
33
  "Upgrade-Insecure-Requests" => "1",
60
- "User-Agent" => USERAGENTS.shuffle.first,
61
34
  }
35
+ a.user_agent_alias = Mechanize::AGENT_ALIASES.map(&:first).shuffle.first
62
36
  a
63
37
  end
64
38
 
@@ -66,12 +40,12 @@ module RelatonBipm
66
40
  # @param agent [Mechanize]
67
41
  # @return [RelatonBipm::BipmBibliographicItem]
68
42
  def get_bipm(ref, agent)
69
- url = "#{GH_ENDPOINT}#{ref.downcase.split(' ').join '-'}.yaml"
43
+ url = "#{GH_ENDPOINT}#{ref.upcase.split.join '-'}.yaml"
70
44
  resp = agent.get url
71
45
  return unless resp.code == "200"
72
46
 
73
47
  bib_hash = HashConverter.hash_to_bib YAML.safe_load(resp.body, [Date])
74
- BipmBibliographicItem.new **bib_hash
48
+ BipmBibliographicItem.new(**bib_hash)
75
49
  end
76
50
 
77
51
  # @param ref [String]
@@ -79,7 +53,7 @@ module RelatonBipm
79
53
  # @return [RelatonBipm::BipmBibliographicItem]
80
54
  def get_metrologia(ref, agent)
81
55
  agent.redirect_ok = false
82
- ref_arr = ref.split(" ")
56
+ ref_arr = ref.split
83
57
  case ref_arr.size
84
58
  when 1 then get_journal agent
85
59
  when 2 then get_volume ref_arr[1], agent
@@ -91,7 +65,7 @@ module RelatonBipm
91
65
  # @param agent [Mechanize]
92
66
  # @return [RelatonBipm::BipmBibliographicItem]
93
67
  def get_journal(agent)
94
- url = IOP_DOMAIN + "/journal/0026-1394"
68
+ url = "#{IOP_DOMAIN}/journal/0026-1394"
95
69
  rsp = agent.get url
96
70
  rel = rsp.xpath('//select[@id="allVolumesSelector"]/option').map do |v|
97
71
  { type: "partOf", bibitem: journal_rel(v) }
@@ -129,7 +103,7 @@ module RelatonBipm
129
103
  docid = doc_id [vol, ish]
130
104
  t = elm.at "p"
131
105
  title_fref = t ? { title: titles(t.text) } : { formattedref: fref(docid.id) }
132
- BipmBibliographicItem.new **title_fref, docid: [docid], link: blink(url)
106
+ BipmBibliographicItem.new(**title_fref, docid: [docid], link: blink(url))
133
107
  end
134
108
 
135
109
  # @param title [String]
@@ -214,7 +188,7 @@ module RelatonBipm
214
188
  # @return [RelatonBib::DocumentIdentifier]
215
189
  def doc_id(args)
216
190
  id = args.clone.unshift "Metrologia"
217
- RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id.join(" "))
191
+ RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id.join(" "), primary: true)
218
192
  end
219
193
 
220
194
  # @param vol [String]
@@ -248,7 +222,7 @@ module RelatonBipm
248
222
  # @return [RelatonBipm::BipmBibliographicItem]
249
223
  def bibitem(**args)
250
224
  BipmBibliographicItem.new(
251
- fetched: Date.today.to_s, type: "standard", language: ["en"], script: ["Latn"], **args
225
+ fetched: Date.today.to_s, type: "standard", language: ["en"], script: ["Latn"], **args,
252
226
  )
253
227
  end
254
228
 
@@ -291,7 +265,7 @@ module RelatonBipm
291
265
  # @return [Array<Hash>]
292
266
  def btcontrib(bibtex)
293
267
  surname, initial = bibtex.author.split ", "
294
- initial = initial.split(" ").map { |i| RelatonBib::LocalizedString.new i, "en", "Latn" }
268
+ initial = initial.split.map { |i| RelatonBib::LocalizedString.new i, "en", "Latn" }
295
269
  surname = RelatonBib::LocalizedString.new surname, "en", "Latn"
296
270
  name = RelatonBib::FullName.new surname: surname, initial: initial
297
271
  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.10.1".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.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.8.2
4
+ version: 1.10.1
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: 2022-02-09 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.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.8.0
138
+ version: 1.10.1
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: serrano
141
141
  requirement: !ruby/object:Gem::Requirement