relaton-bipm 1.6.pre1 → 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +46 -0
- data/README.adoc +149 -0
- data/grammars/bipm.rng +188 -23
- data/grammars/isodoc.rng +14 -43
- data/lib/relaton_bipm.rb +2 -0
- data/lib/relaton_bipm/acronyms.yaml +57 -0
- data/lib/relaton_bipm/bipm_bibliographic_item.rb +20 -8
- data/lib/relaton_bipm/bipm_bibliography.rb +304 -23
- data/lib/relaton_bipm/committee.rb +60 -0
- data/lib/relaton_bipm/editorial_group.rb +8 -17
- data/lib/relaton_bipm/hash_converter.rb +33 -7
- data/lib/relaton_bipm/processor.rb +1 -2
- data/lib/relaton_bipm/version.rb +1 -1
- data/lib/relaton_bipm/workgroup.rb +46 -0
- data/lib/relaton_bipm/xml_parser.rb +26 -5
- data/relaton_bipm.gemspec +5 -3
- metadata +36 -35
- 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/isodoc.rng
CHANGED
@@ -24,6 +24,14 @@
|
|
24
24
|
<start>
|
25
25
|
<ref name="standard-document"/>
|
26
26
|
</start>
|
27
|
+
<define name="doctype">
|
28
|
+
<element name="doctype">
|
29
|
+
<optional>
|
30
|
+
<attribute name="abbreviation"/>
|
31
|
+
</optional>
|
32
|
+
<ref name="DocumentType"/>
|
33
|
+
</element>
|
34
|
+
</define>
|
27
35
|
<define name="hyperlink">
|
28
36
|
<element name="link">
|
29
37
|
<attribute name="target">
|
@@ -141,6 +149,11 @@
|
|
141
149
|
<data type="boolean"/>
|
142
150
|
</attribute>
|
143
151
|
</optional>
|
152
|
+
<optional>
|
153
|
+
<attribute name="key">
|
154
|
+
<data type="boolean"/>
|
155
|
+
</attribute>
|
156
|
+
</optional>
|
144
157
|
<oneOrMore>
|
145
158
|
<ref name="dt"/>
|
146
159
|
<ref name="dd"/>
|
@@ -1164,49 +1177,7 @@
|
|
1164
1177
|
</define>
|
1165
1178
|
<define name="annex">
|
1166
1179
|
<element name="annex">
|
1167
|
-
<
|
1168
|
-
<attribute name="id">
|
1169
|
-
<data type="ID"/>
|
1170
|
-
</attribute>
|
1171
|
-
</optional>
|
1172
|
-
<optional>
|
1173
|
-
<attribute name="language"/>
|
1174
|
-
</optional>
|
1175
|
-
<optional>
|
1176
|
-
<attribute name="script"/>
|
1177
|
-
</optional>
|
1178
|
-
<optional>
|
1179
|
-
<attribute name="inline-header">
|
1180
|
-
<data type="boolean"/>
|
1181
|
-
</attribute>
|
1182
|
-
</optional>
|
1183
|
-
<attribute name="obligation">
|
1184
|
-
<choice>
|
1185
|
-
<value>normative</value>
|
1186
|
-
<value>informative</value>
|
1187
|
-
</choice>
|
1188
|
-
</attribute>
|
1189
|
-
<optional>
|
1190
|
-
<ref name="section-title"/>
|
1191
|
-
</optional>
|
1192
|
-
<group>
|
1193
|
-
<group>
|
1194
|
-
<zeroOrMore>
|
1195
|
-
<ref name="BasicBlock"/>
|
1196
|
-
</zeroOrMore>
|
1197
|
-
<zeroOrMore>
|
1198
|
-
<ref name="note"/>
|
1199
|
-
</zeroOrMore>
|
1200
|
-
</group>
|
1201
|
-
<zeroOrMore>
|
1202
|
-
<choice>
|
1203
|
-
<ref name="annex-subsection"/>
|
1204
|
-
<ref name="terms"/>
|
1205
|
-
<ref name="definitions"/>
|
1206
|
-
<ref name="references"/>
|
1207
|
-
</choice>
|
1208
|
-
</zeroOrMore>
|
1209
|
-
</group>
|
1180
|
+
<ref name="Annex-Section"/>
|
1210
1181
|
</element>
|
1211
1182
|
</define>
|
1212
1183
|
<define name="terms">
|
data/lib/relaton_bipm.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "relaton_bib"
|
2
2
|
require "relaton_bipm/version"
|
3
3
|
require "relaton_bipm/editorial_group"
|
4
|
+
require "relaton_bipm/committee"
|
5
|
+
require "relaton_bipm/workgroup"
|
4
6
|
require "relaton_bipm/structured_identifier"
|
5
7
|
require "relaton_bipm/bibliographic_date"
|
6
8
|
require "relaton_bipm/document_relation"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
CCAUV:
|
2
|
+
fr: Comité consultatif de l’acoustique, des ultrasons et des vibrations
|
3
|
+
en: Consultative Committee for Acoustics, Ultrasound and Vibration
|
4
|
+
CCDS:
|
5
|
+
fr: Comité consultatif pour la définition de la seconde
|
6
|
+
en: Consultative Committee for the Definition of the Second
|
7
|
+
note: see CCTF
|
8
|
+
CCE:
|
9
|
+
fr: Comité consultatif d’électricité
|
10
|
+
en: Consultative Committee for Electricity
|
11
|
+
note: see CCEM
|
12
|
+
CCEM:
|
13
|
+
fr: Comité consultatif d’électricité et magnétisme
|
14
|
+
en: Consultative Committee for Electricity and Magnetism
|
15
|
+
note: formerly the CCE
|
16
|
+
CCL:
|
17
|
+
fr: Comité consultatif des longueurs
|
18
|
+
en: Consultative Committee for Length
|
19
|
+
CCM:
|
20
|
+
fr: Comité consultatif pour la masse et les grandeurs apparentées
|
21
|
+
en: Consultative Committee for Mass and Related Quantities
|
22
|
+
CCPR:
|
23
|
+
fr: Comité consultatif de photométrie et radiométrie
|
24
|
+
en: Consultative Committee for Photometry and Radiometry
|
25
|
+
CCQM:
|
26
|
+
fr: 'Comité consultatif pour la quantité de matière : métrologie en chimie et biologie'
|
27
|
+
en: 'Consultative Committee for Amount of Substance: Metrology in Chemistry and Biology'
|
28
|
+
CCRI:
|
29
|
+
fr: Comité consultatif des rayonnements ionisants
|
30
|
+
en: Consultative Committee for Ionizing Radiation
|
31
|
+
CCT:
|
32
|
+
fr: Comité consultatif de thermométrie
|
33
|
+
en: Consultative Committee for Thermometry
|
34
|
+
CCTF:
|
35
|
+
fr: Comité consultatif du temps et des fréquences
|
36
|
+
en: Consultative Committee for Time and Frequency
|
37
|
+
note: formerly the CCDS
|
38
|
+
CCU:
|
39
|
+
fr: Comité consultatif des unités
|
40
|
+
en: Consultative Committee for Units
|
41
|
+
CGPM:
|
42
|
+
fr: Conférence générale des poids et mesures
|
43
|
+
en: General Conference on Weights and Measures
|
44
|
+
CIPM:
|
45
|
+
fr: Comité international des poids et mesures
|
46
|
+
en: International Committee for Weights and Measures
|
47
|
+
BIPM:
|
48
|
+
en: Joint Committees of the BIPM and other international organizations
|
49
|
+
CCL-CCTF:
|
50
|
+
JCGM:
|
51
|
+
en: Joint Committee for Guides in Metrology
|
52
|
+
JCRB:
|
53
|
+
en: Joint Committee of the Regional Metrology Organizations and the BIPM
|
54
|
+
JCTLM:
|
55
|
+
en: Joint Committee for Traceability in Laboratory Medicine
|
56
|
+
INetQI:
|
57
|
+
en: International Network on Quality Infrastructure
|
@@ -13,20 +13,21 @@ module RelatonBipm
|
|
13
13
|
kg_h_c_deltanu kg_h m_c_deltanu m_c mol_NA s_deltanu
|
14
14
|
].freeze
|
15
15
|
|
16
|
-
# @return [RelatonBipm::CommentPeriod,
|
16
|
+
# @return [RelatonBipm::CommentPeriod, nil]
|
17
17
|
attr_reader :comment_period
|
18
18
|
|
19
|
-
# @return [String]
|
20
|
-
attr_reader :si_aspect
|
19
|
+
# @return [String, nil]
|
20
|
+
attr_reader :si_aspect, :meeting_note
|
21
21
|
|
22
22
|
# @param relation [Array<RelatonBipm::DocumentRelation>]
|
23
23
|
# @param editorialgroup [RelatonBipm::EditorialGroup]
|
24
|
-
# @param comment_period [RelatonBipm::CommentPeriod,
|
25
|
-
# @param si_aspect [String]
|
24
|
+
# @param comment_period [RelatonBipm::CommentPeriod, nil]
|
25
|
+
# @param si_aspect [String, nil]
|
26
|
+
# @param meeting_note [String, nil]
|
26
27
|
# @param structuredidentifier [RelatonBipm::StructuredIdentifier]
|
27
28
|
def initialize(**args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
28
|
-
if args[:docstatus] && !STATUSES.include?(args[:docstatus].stage)
|
29
|
-
warn "[relaton-bipm] Warning: invalid docstatus: #{args[:docstatus]}. "\
|
29
|
+
if args[:docstatus] && !STATUSES.include?(args[:docstatus].stage.value)
|
30
|
+
warn "[relaton-bipm] Warning: invalid docstatus: #{args[:docstatus].stage.value}. "\
|
30
31
|
"It should be one of: #{STATUSES}"
|
31
32
|
end
|
32
33
|
|
@@ -37,9 +38,17 @@ module RelatonBipm
|
|
37
38
|
|
38
39
|
@comment_period = args.delete :comment_period
|
39
40
|
@si_aspect = args.delete :si_aspect
|
41
|
+
@meeting_note = args[:meeting_note]
|
40
42
|
super
|
41
43
|
end
|
42
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
|
+
|
43
52
|
# @param opts [Hash]
|
44
53
|
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
45
54
|
# @option opts [Boolean] :bibdata
|
@@ -55,6 +64,7 @@ module RelatonBipm
|
|
55
64
|
editorialgroup&.to_xml b
|
56
65
|
comment_period&.to_xml b
|
57
66
|
b.send "si-aspect", si_aspect if si_aspect
|
67
|
+
b.send "meeting-note", meeting_note if meeting_note
|
58
68
|
structuredidentifier&.to_xml b
|
59
69
|
end
|
60
70
|
end
|
@@ -66,6 +76,7 @@ module RelatonBipm
|
|
66
76
|
hash = super
|
67
77
|
hash["comment_period"] = comment_period.to_hash if comment_period
|
68
78
|
hash["si_aspect"] = si_aspect if si_aspect
|
79
|
+
hash["meeting-note"] = meeting_note if meeting_note
|
69
80
|
hash
|
70
81
|
end
|
71
82
|
|
@@ -75,7 +86,8 @@ module RelatonBipm
|
|
75
86
|
pref = prefix.empty? ? prefix : prefix + "."
|
76
87
|
out = super
|
77
88
|
out += comment_period.to_asciibib prefix if comment_period
|
78
|
-
out += "#{pref}
|
89
|
+
out += "#{pref}si_aspect:: #{si_aspect}\n" if si_aspect
|
90
|
+
out += "#{pref}meeting_note:: #{meeting_note}\h" if meeting_note
|
79
91
|
out
|
80
92
|
end
|
81
93
|
end
|
@@ -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
|
+
url = URI IOP_DOMAIN + path
|
238
|
+
rsp = agent.get url
|
239
|
+
bib = rsp.link_with(text: "BibTeX").href
|
240
|
+
rsp = agent.get URI IOP_DOMAIN + 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)
|