relaton-bipm 1.7.0 → 1.8.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/.github/workflows/rake.yml +46 -0
- data/.rubocop.yml +1 -1
- data/Gemfile +1 -1
- data/README.adoc +149 -0
- data/grammars/basicdoc.rng +165 -20
- data/grammars/biblio.rng +4 -6
- data/grammars/bipm.rng +14 -1
- data/grammars/isodoc.rng +460 -6
- data/grammars/reqt.rng +31 -2
- data/lib/relaton_bipm/bipm_bibliographic_item.rb +8 -1
- data/lib/relaton_bipm/bipm_bibliography.rb +304 -23
- data/lib/relaton_bipm/hash_converter.rb +8 -8
- data/lib/relaton_bipm/processor.rb +1 -2
- data/lib/relaton_bipm/version.rb +1 -1
- data/lib/relaton_bipm/xml_parser.rb +1 -1
- data/relaton_bipm.gemspec +7 -5
- metadata +29 -45
- data/.github/workflows/macos.yml +0 -34
- data/.github/workflows/ubuntu.yml +0 -32
- data/.github/workflows/windows.yml +0 -35
- data/README.md +0 -40
data/grammars/reqt.rng
CHANGED
@@ -30,15 +30,34 @@
|
|
30
30
|
<data type="boolean"/>
|
31
31
|
</attribute>
|
32
32
|
</optional>
|
33
|
+
<optional>
|
34
|
+
<attribute name="number"/>
|
35
|
+
</optional>
|
33
36
|
<optional>
|
34
37
|
<attribute name="subsequence"/>
|
35
38
|
</optional>
|
39
|
+
<optional>
|
40
|
+
<attribute name="keep-with-next">
|
41
|
+
<data type="boolean"/>
|
42
|
+
</attribute>
|
43
|
+
</optional>
|
44
|
+
<optional>
|
45
|
+
<attribute name="keep-lines-together">
|
46
|
+
<data type="boolean"/>
|
47
|
+
</attribute>
|
48
|
+
</optional>
|
36
49
|
<attribute name="id">
|
37
50
|
<data type="ID"/>
|
38
51
|
</attribute>
|
39
52
|
<optional>
|
40
53
|
<attribute name="filename"/>
|
41
54
|
</optional>
|
55
|
+
<optional>
|
56
|
+
<attribute name="model"/>
|
57
|
+
</optional>
|
58
|
+
<optional>
|
59
|
+
<attribute name="type"/>
|
60
|
+
</optional>
|
42
61
|
<optional>
|
43
62
|
<ref name="reqtitle"/>
|
44
63
|
</optional>
|
@@ -48,9 +67,9 @@
|
|
48
67
|
<optional>
|
49
68
|
<ref name="subject"/>
|
50
69
|
</optional>
|
51
|
-
<
|
70
|
+
<zeroOrMore>
|
52
71
|
<ref name="reqinherit"/>
|
53
|
-
</
|
72
|
+
</zeroOrMore>
|
54
73
|
<zeroOrMore>
|
55
74
|
<ref name="classification"/>
|
56
75
|
</zeroOrMore>
|
@@ -135,6 +154,16 @@
|
|
135
154
|
<data type="boolean"/>
|
136
155
|
</attribute>
|
137
156
|
</optional>
|
157
|
+
<optional>
|
158
|
+
<attribute name="keep-with-next">
|
159
|
+
<data type="boolean"/>
|
160
|
+
</attribute>
|
161
|
+
</optional>
|
162
|
+
<optional>
|
163
|
+
<attribute name="keep-lines-together">
|
164
|
+
<data type="boolean"/>
|
165
|
+
</attribute>
|
166
|
+
</optional>
|
138
167
|
<oneOrMore>
|
139
168
|
<ref name="BasicBlock"/>
|
140
169
|
</oneOrMore>
|
@@ -27,7 +27,7 @@ module RelatonBipm
|
|
27
27
|
# @param structuredidentifier [RelatonBipm::StructuredIdentifier]
|
28
28
|
def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
29
29
|
if args[:docstatus] && !STATUSES.include?(args[:docstatus].stage.value)
|
30
|
-
warn "[relaton-bipm] Warning: invalid docstatus: #{args[:docstatus]}. "\
|
30
|
+
warn "[relaton-bipm] Warning: invalid docstatus: #{args[:docstatus].stage.value}. "\
|
31
31
|
"It should be one of: #{STATUSES}"
|
32
32
|
end
|
33
33
|
|
@@ -42,6 +42,13 @@ module RelatonBipm
|
|
42
42
|
super
|
43
43
|
end
|
44
44
|
|
45
|
+
# @param hash [Hash]
|
46
|
+
# @return [RelatonBipm::BipmBibliographicItem]
|
47
|
+
def self.from_hash(hash)
|
48
|
+
item_hash = ::RelatonBipm::HashConverter.hash_to_bib(hash)
|
49
|
+
new **item_hash
|
50
|
+
end
|
51
|
+
|
45
52
|
# @param opts [Hash]
|
46
53
|
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
47
54
|
# @option opts [Boolean] :bibdata
|
@@ -1,39 +1,320 @@
|
|
1
|
-
require "
|
1
|
+
require "mechanize"
|
2
2
|
|
3
3
|
module RelatonBipm
|
4
4
|
class BipmBibliography
|
5
|
-
|
6
|
-
|
5
|
+
GH_ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-bipm/master/data/".freeze
|
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
|
7
34
|
|
8
35
|
class << self
|
9
36
|
# @param text [String]
|
10
37
|
# @return [RelatonBipm::BipmBibliographicItem]
|
11
|
-
def search(text, _year = nil, _opts = {})
|
38
|
+
def search(text, _year = nil, _opts = {})
|
12
39
|
warn "[relaton-bipm] (\"#{text}\") fetching..."
|
13
|
-
ref = text.sub(/^BIPM\s/, "")
|
14
|
-
|
15
|
-
|
16
|
-
return unless resp.code == "200"
|
40
|
+
ref = text.sub(/^BIPM\s/, "")
|
41
|
+
item = ref.match?(/^Metrologia/i) ? get_metrologia(ref, magent) : get_bipm(ref, magent)
|
42
|
+
return unless item
|
17
43
|
|
18
|
-
|
19
|
-
item = BipmBibliographicItem.new hash
|
20
|
-
warn "[relaton-bipm] (\"#{text}\") found #{item.docidentifier.first.id}"
|
44
|
+
warn("[relaton-bipm] (\"#{text}\") found #{item.docidentifier[0].id}")
|
21
45
|
item
|
22
|
-
rescue
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
46
|
+
rescue Mechanize::ResponseCodeError => e
|
47
|
+
raise RelatonBib::RequestError, e.message unless e.response_code == "404"
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [Mechanize]
|
51
|
+
def magent
|
52
|
+
a = Mechanize.new
|
53
|
+
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",
|
56
|
+
"Accept-Encoding" => "gzip, deflate, br",
|
57
|
+
"Accept-Language" => "en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7",
|
58
|
+
"Cache-Control" => "max-age=0",
|
59
|
+
"Upgrade-Insecure-Requests" => "1",
|
60
|
+
"User-Agent" => USERAGENTS.shuffle.first,
|
61
|
+
}
|
62
|
+
a
|
63
|
+
end
|
64
|
+
|
65
|
+
# @param ref [String]
|
66
|
+
# @param agent [Mechanize]
|
67
|
+
# @return [RelatonBipm::BipmBibliographicItem]
|
68
|
+
def get_bipm(ref, agent)
|
69
|
+
url = "#{GH_ENDPOINT}#{ref.downcase.split(' ').join '-'}.yaml"
|
70
|
+
resp = agent.get url
|
71
|
+
return unless resp.code == "200"
|
72
|
+
|
73
|
+
bib_hash = HashConverter.hash_to_bib YAML.safe_load(resp.body, [Date])
|
74
|
+
BipmBibliographicItem.new **bib_hash
|
75
|
+
end
|
76
|
+
|
77
|
+
# @param ref [String]
|
78
|
+
# @param agent [Mechanize]
|
79
|
+
# @return [RelatonBipm::BipmBibliographicItem]
|
80
|
+
def get_metrologia(ref, agent)
|
81
|
+
agent.redirect_ok = false
|
82
|
+
ref_arr = ref.split(" ")
|
83
|
+
case ref_arr.size
|
84
|
+
when 1 then get_journal agent
|
85
|
+
when 2 then get_volume ref_arr[1], agent
|
86
|
+
when 3 then get_issue(*ref_arr[1..2], agent)
|
87
|
+
when 4 then get_article_from_issue(*ref_arr[1..3], agent)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# @param agent [Mechanize]
|
92
|
+
# @return [RelatonBipm::BipmBibliographicItem]
|
93
|
+
def get_journal(agent)
|
94
|
+
url = IOP_DOMAIN + "/journal/0026-1394"
|
95
|
+
rsp = agent.get url
|
96
|
+
rel = rsp.xpath('//select[@id="allVolumesSelector"]/option').map do |v|
|
97
|
+
{ type: "partOf", bibitem: journal_rel(v) }
|
98
|
+
end
|
99
|
+
did = doc_id []
|
100
|
+
bibitem(formattedref: fref(did.id), docid: [did], link: blink(url), relation: rel)
|
101
|
+
end
|
102
|
+
|
103
|
+
# @param elm [Nokogiri::XML::Element]
|
104
|
+
def journal_rel(elm)
|
105
|
+
vol = elm[:value].split("/").last
|
106
|
+
did = doc_id [vol]
|
107
|
+
url = IOP_DOMAIN + elm[:value]
|
108
|
+
BipmBibliographicItem.new(formattedref: fref(did.id), docid: [did], link: blink(url))
|
109
|
+
end
|
110
|
+
|
111
|
+
# @param vol [String]
|
112
|
+
# @param agent [Mechanize]
|
113
|
+
# @return [RelatonBipm::BipmBibliographicItem]
|
114
|
+
def get_volume(vol, agent)
|
115
|
+
url = "#{IOP_DOMAIN}/volume/0026-1394/#{vol}"
|
116
|
+
rsp = agent.get url
|
117
|
+
rel = rsp.xpath('//li[@itemprop="hasPart"]').map do |i|
|
118
|
+
{ type: "partOf", bibitem: volume_rel(i, vol) }
|
119
|
+
end
|
120
|
+
did = doc_id [vol]
|
121
|
+
bibitem(formattedref: fref(did.id), docid: [did], link: blink(url), date: bdate(rsp), relation: rel,
|
122
|
+
extent: btextent(vol), series: series)
|
123
|
+
end
|
124
|
+
|
125
|
+
def volume_rel(elm, vol) # rubocop:disable Metrics/AbcSize
|
126
|
+
a = elm.at 'a[@itemprop="issueNumber"]'
|
127
|
+
ish = a[:href].split("/").last
|
128
|
+
url = IOP_DOMAIN + a[:href]
|
129
|
+
docid = doc_id [vol, ish]
|
130
|
+
t = elm.at "p"
|
131
|
+
title_fref = t ? { title: titles(t.text) } : { formattedref: fref(docid.id) }
|
132
|
+
BipmBibliographicItem.new **title_fref, docid: [docid], link: blink(url)
|
133
|
+
end
|
134
|
+
|
135
|
+
# @param title [String]
|
136
|
+
# @return [RelatonBib::TypedTitleStringCollection]
|
137
|
+
def titles(title)
|
138
|
+
RelatonBib::TypedTitleString.from_string title, "en", "Latn"
|
139
|
+
end
|
140
|
+
|
141
|
+
# @param vol [String]
|
142
|
+
# @param ish [String]
|
143
|
+
# @param agent [Mechanize]
|
144
|
+
# @return [RelatonBipm::BipmBibliographicItem]
|
145
|
+
def get_issue(vol, ish, agent) # rubocop:disable Metrics/AbcSize
|
146
|
+
url = issue_url vol, ish
|
147
|
+
rsp = agent.get url
|
148
|
+
rel = rsp.xpath('//div[@class="art-list-item-body"]').map do |a|
|
149
|
+
{ type: "partOf", bibitem: issue_rel(a, vol, ish) }
|
150
|
+
end
|
151
|
+
did = doc_id [vol, ish]
|
152
|
+
title_fref = { title: issue_title(rsp) }
|
153
|
+
title_fref[:formattedref] = fref did.id unless title_fref[:title].any?
|
154
|
+
bibitem(**title_fref, link: blink(url), relation: rel, docid: [did],
|
155
|
+
date: bdate(rsp), extent: btextent(vol, ish), series: series)
|
156
|
+
end
|
157
|
+
|
158
|
+
# @param ref [String]
|
159
|
+
# @return [RelatonBib::FormattedRef]
|
160
|
+
def fref(ref)
|
161
|
+
RelatonBib::FormattedRef.new content: ref, language: "en", script: "Latn"
|
162
|
+
end
|
163
|
+
|
164
|
+
# @param rsp [Mechanize::Page]
|
165
|
+
# @return [RelatonBib::TypedTitleStringCollection]
|
166
|
+
def issue_title(rsp)
|
167
|
+
t = rsp.at('//div[@id="wd-jnl-issue-title"]/h4')
|
168
|
+
return RelatonBib::TypedTitleStringCollection.new [] unless t
|
169
|
+
|
170
|
+
titles(t.text)
|
171
|
+
end
|
172
|
+
|
173
|
+
# @oaran vol [String]
|
174
|
+
# @param ish [String]
|
175
|
+
# @return [String]
|
176
|
+
def issue_url(vol, ish)
|
177
|
+
"#{IOP_DOMAIN}/issue/0026-1394/#{vol}/#{ish}"
|
178
|
+
end
|
179
|
+
|
180
|
+
# @param elm [Nokogiri::XML::Element]
|
181
|
+
# @param vol [String]
|
182
|
+
# @param ish [String]
|
183
|
+
# @return [RelatonBipm::BipmBibliographicItem]
|
184
|
+
def issue_rel(elm, vol, ish)
|
185
|
+
art = elm.at('div[@class="indexer"]').text
|
186
|
+
ref = elm.at('div/a[@class="art-list-item-title"]')
|
187
|
+
title = titles ref.text.strip
|
188
|
+
docid = doc_id [vol, ish, art]
|
189
|
+
link = blink IOP_DOMAIN + ref[:href]
|
190
|
+
BipmBibliographicItem.new(title: title, docid: [docid], link: link)
|
191
|
+
end
|
192
|
+
|
193
|
+
# @param content [RelatonBib::TypedTitleString]
|
194
|
+
# @return [RelatonBib::TypedTitleString]
|
195
|
+
def btitle(content)
|
196
|
+
RelatonBib::TypedTitleString.new type: "main", content: content, language: "en", script: "Latn"
|
197
|
+
end
|
198
|
+
|
199
|
+
# @param url [String]
|
200
|
+
# @return [String]
|
201
|
+
def blink(url)
|
202
|
+
[RelatonBib::TypedUri.new(type: "src", content: url)]
|
203
|
+
end
|
204
|
+
|
205
|
+
# @param rsp [Mechanize::Page]
|
206
|
+
# @return [Array<RelatonBib::BibliographicDate>]
|
207
|
+
def bdate(rsp)
|
208
|
+
date = rsp.at('//p[@itemprop="issueNumber"]|//h2[@itemprop="volumeNumber"]').text.split(", ").last
|
209
|
+
on = date.match?(/^\d{4}$/) ? date : Date.parse(date).strftime("%Y-%m")
|
210
|
+
[RelatonBib::BibliographicDate.new(type: "published", on: on)]
|
211
|
+
end
|
212
|
+
|
213
|
+
# @param args [Array<String>]
|
214
|
+
# @return [RelatonBib::DocumentIdentifier]
|
215
|
+
def doc_id(args)
|
216
|
+
id = args.clone.unshift "Metrologia"
|
217
|
+
RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id.join(" "))
|
218
|
+
end
|
219
|
+
|
220
|
+
# @param vol [String]
|
221
|
+
# @param ish [String]
|
222
|
+
# @param art [String]
|
223
|
+
# @param agent [Mechanize]
|
224
|
+
# @return [RelatonBipm::BipmBibliographicItem]
|
225
|
+
def get_article_from_issue(vol, ish, art, agent)
|
226
|
+
url = issue_url vol, ish
|
227
|
+
rsp = agent.get url
|
228
|
+
get_article rsp.at("//div[@class='indexer'][.='#{art}']/../div/a")[:href], vol, ish, agent
|
229
|
+
end
|
230
|
+
|
231
|
+
# @param path [String]
|
232
|
+
# @param vol [String]
|
233
|
+
# @param ish [String]
|
234
|
+
# @param agent [Mechanize]
|
235
|
+
# @return [RelatonBipm::BipmBibliographicItem]
|
236
|
+
def get_article(path, vol, ish, agent) # rubocop:disable Metrics/AbcSize
|
237
|
+
rsp = agent.get path
|
238
|
+
url = rsp.uri
|
239
|
+
bib = rsp.link_with(text: "BibTeX").href
|
240
|
+
rsp = agent.get bib
|
241
|
+
bt = BibTeX.parse(rsp.body).first
|
242
|
+
bibitem(docid: btdocid(bt), title: titles(bt.title.to_s), abstract: btabstract(bt), doctype: bt.type.to_s,
|
243
|
+
link: btlink(bt, url), date: btdate(bt), contributor: btcontrib(bt), series: series,
|
244
|
+
extent: btextent(vol, ish, bt))
|
245
|
+
end
|
246
|
+
|
247
|
+
# @param args [Hash]
|
248
|
+
# @return [RelatonBipm::BipmBibliographicItem]
|
249
|
+
def bibitem(**args)
|
250
|
+
BipmBibliographicItem.new(
|
251
|
+
fetched: Date.today.to_s, type: "standard", language: ["en"], script: ["Latn"], **args
|
252
|
+
)
|
253
|
+
end
|
254
|
+
|
255
|
+
# @return [Array<RelatonBib::Series>]
|
256
|
+
def series
|
257
|
+
[RelatonBib::Series.new(title: btitle("Metrologia"))]
|
258
|
+
end
|
259
|
+
|
260
|
+
# @param bibtex [BibTeX::Entry]
|
261
|
+
# @return [Array<RelatonBib::DocumentIdentifier>]
|
262
|
+
def btdocid(bibtex)
|
263
|
+
id = "#{bibtex.journal} #{bibtex.volume} #{bibtex.number} #{bibtex.pages.match(/^\d+/)}"
|
264
|
+
[RelatonBib::DocumentIdentifier.new(type: "BIPM", id: id)]
|
265
|
+
end
|
266
|
+
|
267
|
+
# @param bibtex [BibTeX::Entry]
|
268
|
+
# @return [Array<RelatonBib::FormattedString>]
|
269
|
+
def btabstract(bibtex)
|
270
|
+
[RelatonBib::FormattedString.new(content: bibtex.abstract.to_s, language: "en", script: "Latn")]
|
271
|
+
end
|
272
|
+
|
273
|
+
# @param bibtex [BibTeX::Entry]
|
274
|
+
# @param ref [URI]
|
275
|
+
# @return [Array<RelatonBib::TypedUri>]
|
276
|
+
def btlink(bibtex, ref)
|
277
|
+
[
|
278
|
+
RelatonBib::TypedUri.new(type: "src", content: ref.to_s),
|
279
|
+
RelatonBib::TypedUri.new(type: "doi", content: bibtex.url.to_s),
|
280
|
+
]
|
281
|
+
end
|
282
|
+
|
283
|
+
# @param bibtex [BibTeX::Entry]
|
284
|
+
# @return [Array<RelatonBib::BibliographicDate>]
|
285
|
+
def btdate(bibtex)
|
286
|
+
on = Date.new(bibtex.year.to_i, bibtex.month_numeric)
|
287
|
+
[RelatonBib::BibliographicDate.new(type: "published", on: on)]
|
288
|
+
end
|
289
|
+
|
290
|
+
# @param bibtex [BibTeX::Entry]
|
291
|
+
# @return [Array<Hash>]
|
292
|
+
def btcontrib(bibtex)
|
293
|
+
surname, initial = bibtex.author.split ", "
|
294
|
+
initial = initial.split(" ").map { |i| RelatonBib::LocalizedString.new i, "en", "Latn" }
|
295
|
+
surname = RelatonBib::LocalizedString.new surname, "en", "Latn"
|
296
|
+
name = RelatonBib::FullName.new surname: surname, initial: initial
|
297
|
+
author = RelatonBib::Person.new name: name
|
298
|
+
[
|
299
|
+
{ entity: { name: bibtex.publisher.to_s }, role: [{ type: "publisher" }] },
|
300
|
+
{ entity: author, role: [{ type: "author" }] },
|
301
|
+
]
|
302
|
+
end
|
303
|
+
|
304
|
+
# @param vol [String]
|
305
|
+
# @param ish [String]
|
306
|
+
# @param bibtex [BibTeX::Entry]
|
307
|
+
# @return [Array<RelatonBib::BibItemLocality>]
|
308
|
+
def btextent(vol, ish = nil, bibtex = nil)
|
309
|
+
ext = [RelatonBib::BibItemLocality.new("volume", vol)]
|
310
|
+
ext << RelatonBib::BibItemLocality.new("issue", ish) if ish
|
311
|
+
ext << RelatonBib::BibItemLocality.new("page", *bibtex.pages.split("--")) if bibtex
|
312
|
+
ext
|
27
313
|
end
|
28
314
|
|
29
315
|
# @param ref [String] the BIPM standard Code to look up (e..g "BIPM B-11")
|
30
|
-
# @param year [String]
|
31
|
-
#
|
32
|
-
# @param opts [Hash] options
|
33
|
-
# @option opts [TrueClass, FalseClass] :all_parts restricted to all parts
|
34
|
-
# if all-parts reference is required
|
35
|
-
# @option opts [TrueClass, FalseClass] :bibdata
|
36
|
-
#
|
316
|
+
# @param year [String] not used
|
317
|
+
# @param opts [Hash] not used
|
37
318
|
# @return [RelatonBipm::BipmBibliographicItem]
|
38
319
|
def get(ref, year = nil, opts = {})
|
39
320
|
search(ref, year, opts)
|
@@ -23,7 +23,7 @@ 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]
|
@@ -32,7 +32,7 @@ module RelatonBipm
|
|
32
32
|
RelatonBib::TypedTitleStringCollection.new
|
33
33
|
) do |m, t|
|
34
34
|
m << if t.is_a? Hash
|
35
|
-
RelatonBib::TypedTitleString.new(t)
|
35
|
+
RelatonBib::TypedTitleString.new(**t)
|
36
36
|
else
|
37
37
|
RelatonBib::TypedTitleString.new(content: t)
|
38
38
|
end
|
@@ -41,7 +41,7 @@ module RelatonBipm
|
|
41
41
|
|
42
42
|
# @param ret [Hash]
|
43
43
|
def commentperiod_hash_to_bib(ret)
|
44
|
-
ret[:comment_period] &&= CommentPeriond.new(ret[:comment_period])
|
44
|
+
ret[:comment_period] &&= CommentPeriond.new(**ret[:comment_period])
|
45
45
|
end
|
46
46
|
|
47
47
|
# @param ret [Hash]
|
@@ -56,7 +56,7 @@ module RelatonBipm
|
|
56
56
|
def dates_hash_to_bib(ret)
|
57
57
|
super
|
58
58
|
ret[:date] &&= ret[:date].map do |d|
|
59
|
-
BibliographicDate.new d
|
59
|
+
BibliographicDate.new **d
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -64,12 +64,12 @@ module RelatonBipm
|
|
64
64
|
def relations_hash_to_bib(ret)
|
65
65
|
super
|
66
66
|
ret[:relation] &&= ret[:relation].map do |r|
|
67
|
-
RelatonBipm::DocumentRelation.new r
|
67
|
+
RelatonBipm::DocumentRelation.new **r
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
# @param ret [Hash]
|
72
|
-
def editorialgroup_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize
|
72
|
+
def editorialgroup_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
73
73
|
return unless ret[:editorialgroup]
|
74
74
|
|
75
75
|
cmt = ret[:editorialgroup][:committee].map do |c|
|
@@ -77,11 +77,11 @@ module RelatonBipm
|
|
77
77
|
content = RelatonBib::LocalizedString.new vars
|
78
78
|
Committee.new acronym: c[:acronym], content: content
|
79
79
|
else
|
80
|
-
Committee.new c
|
80
|
+
Committee.new **c
|
81
81
|
end
|
82
82
|
end
|
83
83
|
wg = array(ret[:editorialgroup][:workgroup]).map do |w|
|
84
|
-
w.is_a?(Hash) ? WorkGroup.new(w) : WorkGroup.new(content: w)
|
84
|
+
w.is_a?(Hash) ? WorkGroup.new(**w) : WorkGroup.new(content: w)
|
85
85
|
end
|
86
86
|
ret[:editorialgroup] = EditorialGroup.new committee: cmt, workgroup: wg
|
87
87
|
end
|