relaton-iec 1.10.0 → 1.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/grammars/biblio.rng +5 -3
- data/lib/relaton_iec/scrapper.rb +18 -17
- data/lib/relaton_iec/version.rb +1 -1
- data/relaton_iec.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e449c90e5d42349f83529a764d1eb502658dae2dd993e2597f2051c0ac14b9e
|
4
|
+
data.tar.gz: 5cfa9fb5734c5467f22de8bd6629c02d60b7f0f3ac13fb06892530519eaa3af3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4c2d5a7969cd29d8cf4311d636bf5ff8f1567acf5e11d003e2b1bfee8dc35df79a9bcfe5d3a9d738eccfb2b8fbb604c00b408873226c7f21734a3fc1b9dfa5b
|
7
|
+
data.tar.gz: ed09a6035d0f056097f8cf4c0f34f7b0af1d44723e968114f1090652f2aa3ae8aa73ac1f1864f2b45a1ea0ae7696b5082fe18419af286be1a5245c7fcdc82ae9
|
data/grammars/biblio.rng
CHANGED
@@ -209,9 +209,6 @@
|
|
209
209
|
<zeroOrMore>
|
210
210
|
<ref name="contact"/>
|
211
211
|
</zeroOrMore>
|
212
|
-
<zeroOrMore>
|
213
|
-
<ref name="uri"/>
|
214
|
-
</zeroOrMore>
|
215
212
|
</element>
|
216
213
|
</define>
|
217
214
|
<define name="fullname">
|
@@ -828,6 +825,11 @@
|
|
828
825
|
<optional>
|
829
826
|
<attribute name="scope"/>
|
830
827
|
</optional>
|
828
|
+
<optional>
|
829
|
+
<attribute name="primary">
|
830
|
+
<data type="boolean"/>
|
831
|
+
</attribute>
|
832
|
+
</optional>
|
831
833
|
<text/>
|
832
834
|
</element>
|
833
835
|
</define>
|
data/lib/relaton_iec/scrapper.rb
CHANGED
@@ -9,6 +9,11 @@ module RelatonIec
|
|
9
9
|
# Scrapper.
|
10
10
|
module Scrapper
|
11
11
|
DOMAIN = "https://webstore.iec.ch"
|
12
|
+
ABBREVS = {
|
13
|
+
"ISO" => ["International Organization for Standardization", "www.iso.org"],
|
14
|
+
"IEC" => ["International Electrotechnical Commission", "www.iec.ch"],
|
15
|
+
"CISPR" => ["International special committee on radio interference", "www.iec.ch"],
|
16
|
+
}.freeze
|
12
17
|
|
13
18
|
TYPES = {
|
14
19
|
"ISO" => "international-standard",
|
@@ -36,7 +41,7 @@ module RelatonIec
|
|
36
41
|
|
37
42
|
# Fetch edition.
|
38
43
|
edition = doc.at(
|
39
|
-
"//th[contains(., 'Edition')]/following-sibling::td/span"
|
44
|
+
"//th[contains(., 'Edition')]/following-sibling::td/span",
|
40
45
|
).text
|
41
46
|
|
42
47
|
status, relations = fetch_status_relations hit_data[:url]
|
@@ -59,7 +64,7 @@ module RelatonIec
|
|
59
64
|
copyright: fetch_copyright(hit_data[:code], doc),
|
60
65
|
link: fetch_link(doc, hit_data[:url]),
|
61
66
|
relation: relations,
|
62
|
-
place: ["Geneva"]
|
67
|
+
place: ["Geneva"],
|
63
68
|
)
|
64
69
|
end
|
65
70
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
@@ -71,7 +76,7 @@ module RelatonIec
|
|
71
76
|
def fetch_docid(hit)
|
72
77
|
urn = RelatonIec.code_to_urn hit[:code], "en"
|
73
78
|
[
|
74
|
-
RelatonBib::DocumentIdentifier.new(id: hit[:code], type: "IEC"),
|
79
|
+
RelatonBib::DocumentIdentifier.new(id: hit[:code], type: "IEC", primary: true),
|
75
80
|
RelatonBib::DocumentIdentifier.new(id: urn, type: "URN"),
|
76
81
|
]
|
77
82
|
end
|
@@ -121,12 +126,12 @@ module RelatonIec
|
|
121
126
|
item_ref = doc.at("//span[@itemprop='productID']")
|
122
127
|
unless item_ref
|
123
128
|
return RelatonIsoBib::StructuredIdentifier.new(
|
124
|
-
project_number: "?", part_number: "", prefix: nil, id: "?"
|
129
|
+
project_number: "?", part_number: "", prefix: nil, id: "?",
|
125
130
|
)
|
126
131
|
end
|
127
132
|
|
128
133
|
m = item_ref.text.match(
|
129
|
-
/(?<=\s)(?<project>\d+)-?(?<part>(?<=-)\d+|)-?(?<subpart>(?<=-)\d+|)
|
134
|
+
/(?<=\s)(?<project>\d+)-?(?<part>(?<=-)\d+|)-?(?<subpart>(?<=-)\d+|)/,
|
130
135
|
)
|
131
136
|
RelatonIsoBib::StructuredIdentifier.new(
|
132
137
|
project_number: m[:project],
|
@@ -134,7 +139,7 @@ module RelatonIec
|
|
134
139
|
subpart_number: m[:subpart],
|
135
140
|
prefix: nil,
|
136
141
|
type: "IEC",
|
137
|
-
id: item_ref.text
|
142
|
+
id: item_ref.text,
|
138
143
|
)
|
139
144
|
end
|
140
145
|
|
@@ -190,7 +195,7 @@ module RelatonIec
|
|
190
195
|
else r_type
|
191
196
|
end
|
192
197
|
fref = RelatonBib::FormattedRef.new(
|
193
|
-
content: r.at("FULL_NAME").text, format: "text/plain"
|
198
|
+
content: r.at("FULL_NAME").text, format: "text/plain",
|
194
199
|
)
|
195
200
|
bibitem = IecBibliographicItem.new(formattedref: fref)
|
196
201
|
{ type: type, bibitem: bibitem }
|
@@ -199,8 +204,8 @@ module RelatonIec
|
|
199
204
|
|
200
205
|
def fetch_status_relations(url)
|
201
206
|
pubid = url.match(/\d+$/).to_s
|
202
|
-
uri = URI DOMAIN
|
203
|
-
|
207
|
+
uri = URI "#{DOMAIN}/webstore/webstore.nsf/AjaxRequestXML?"\
|
208
|
+
"Openagent&url=#{pubid}"
|
204
209
|
resp = Net::HTTP.get_response uri
|
205
210
|
doc = Nokogiri::XML resp.body
|
206
211
|
status = fetch_status doc
|
@@ -214,7 +219,7 @@ module RelatonIec
|
|
214
219
|
# @return [String]
|
215
220
|
def fetch_type(doc)
|
216
221
|
doc.at(
|
217
|
-
'//th[contains(., "Publication type")]/following-sibling::td/span'
|
222
|
+
'//th[contains(., "Publication type")]/following-sibling::td/span',
|
218
223
|
).text.downcase.tr " ", "-"
|
219
224
|
end
|
220
225
|
|
@@ -253,9 +258,9 @@ module RelatonIec
|
|
253
258
|
# @return [Array<Hash>]
|
254
259
|
def fetch_ics(doc)
|
255
260
|
doc.xpath(
|
256
|
-
'//th[contains(text(), "ICS")]/following-sibling::td/a'
|
261
|
+
'//th[contains(text(), "ICS")]/following-sibling::td/a',
|
257
262
|
).map do |i|
|
258
|
-
code = i.text.match(/[\d
|
263
|
+
code = i.text.match(/[\d.]+/).to_s.split "."
|
259
264
|
{ field: code[0], group: code[1], subgroup: code[2] }
|
260
265
|
end
|
261
266
|
end
|
@@ -292,11 +297,7 @@ module RelatonIec
|
|
292
297
|
# rubocop:enable Metrics/MethodLength
|
293
298
|
|
294
299
|
def name_url(abbrev)
|
295
|
-
|
296
|
-
when "ISO" then ["International Organization for Standardization", "www.iso.org"]
|
297
|
-
when "IEC" then ["International Electrotechnical Commission", "www.iec.ch"]
|
298
|
-
when "CISPR" then ["International special committee on radio interference", "www.iec.ch"]
|
299
|
-
end
|
300
|
+
ABBREVS[abbrev]
|
300
301
|
end
|
301
302
|
end
|
302
303
|
end
|
data/lib/relaton_iec/version.rb
CHANGED
data/relaton_iec.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
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: 2022-
|
11
|
+
date: 2022-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.10.
|
145
|
+
version: 1.10.1
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.10.
|
152
|
+
version: 1.10.1
|
153
153
|
description: 'RelatonIec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem
|
154
154
|
model'
|
155
155
|
email:
|