relaton-cen 1.9.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/.rubocop.yml +2 -0
- data/README.adoc +10 -0
- data/grammars/basicdoc.rng +26 -7
- data/grammars/biblio.rng +7 -5
- data/grammars/isodoc.rng +617 -89
- data/grammars/isostandard.rng +24 -23
- data/grammars/reqt.rng +34 -5
- data/lib/relaton_cen/cen_bibliography.rb +3 -12
- data/lib/relaton_cen/hit_collection.rb +9 -7
- data/lib/relaton_cen/processor.rb +2 -2
- data/lib/relaton_cen/scrapper.rb +2 -2
- data/lib/relaton_cen/version.rb +1 -1
- data/relaton_cen.gemspec +1 -1
- metadata +4 -4
data/grammars/isostandard.rng
CHANGED
@@ -142,14 +142,9 @@
|
|
142
142
|
</optional>
|
143
143
|
<choice>
|
144
144
|
<choice>
|
145
|
-
<
|
146
|
-
<
|
147
|
-
|
148
|
-
</oneOrMore>
|
149
|
-
<zeroOrMore>
|
150
|
-
<ref name="note"/>
|
151
|
-
</zeroOrMore>
|
152
|
-
</group>
|
145
|
+
<oneOrMore>
|
146
|
+
<ref name="BasicBlock"/>
|
147
|
+
</oneOrMore>
|
153
148
|
<ref name="amend"/>
|
154
149
|
</choice>
|
155
150
|
<oneOrMore>
|
@@ -164,6 +159,20 @@
|
|
164
159
|
<data type="ID"/>
|
165
160
|
</attribute>
|
166
161
|
</optional>
|
162
|
+
<optional>
|
163
|
+
<attribute name="language"/>
|
164
|
+
</optional>
|
165
|
+
<optional>
|
166
|
+
<attribute name="script"/>
|
167
|
+
</optional>
|
168
|
+
<optional>
|
169
|
+
<attribute name="tag"/>
|
170
|
+
</optional>
|
171
|
+
<optional>
|
172
|
+
<attribute name="multilingual-rendering">
|
173
|
+
<ref name="MultilingualRenderingType"/>
|
174
|
+
</attribute>
|
175
|
+
</optional>
|
167
176
|
<ref name="preferred"/>
|
168
177
|
<zeroOrMore>
|
169
178
|
<ref name="admitted"/>
|
@@ -174,7 +183,7 @@
|
|
174
183
|
<optional>
|
175
184
|
<ref name="termdomain"/>
|
176
185
|
</optional>
|
177
|
-
<ref name="
|
186
|
+
<ref name="termdefinition"/>
|
178
187
|
<zeroOrMore>
|
179
188
|
<ref name="termnote"/>
|
180
189
|
</zeroOrMore>
|
@@ -184,6 +193,9 @@
|
|
184
193
|
<zeroOrMore>
|
185
194
|
<ref name="termsource"/>
|
186
195
|
</zeroOrMore>
|
196
|
+
<zeroOrMore>
|
197
|
+
<ref name="term"/>
|
198
|
+
</zeroOrMore>
|
187
199
|
</element>
|
188
200
|
</define>
|
189
201
|
<define name="annex">
|
@@ -222,9 +234,6 @@
|
|
222
234
|
-->
|
223
235
|
<ref name="BasicBlock"/>
|
224
236
|
</zeroOrMore>
|
225
|
-
<zeroOrMore>
|
226
|
-
<ref name="note"/>
|
227
|
-
</zeroOrMore>
|
228
237
|
<zeroOrMore>
|
229
238
|
<ref name="clause-hanging-paragraph-with-footnote"/>
|
230
239
|
</zeroOrMore>
|
@@ -348,14 +357,9 @@
|
|
348
357
|
<ref name="section-title"/>
|
349
358
|
</optional>
|
350
359
|
<choice>
|
351
|
-
<
|
352
|
-
<
|
353
|
-
|
354
|
-
</zeroOrMore>
|
355
|
-
<zeroOrMore>
|
356
|
-
<ref name="note"/>
|
357
|
-
</zeroOrMore>
|
358
|
-
</group>
|
360
|
+
<zeroOrMore>
|
361
|
+
<ref name="BasicBlock"/>
|
362
|
+
</zeroOrMore>
|
359
363
|
<oneOrMore>
|
360
364
|
<ref name="content-subsection"/>
|
361
365
|
</oneOrMore>
|
@@ -472,9 +476,6 @@
|
|
472
476
|
<!-- allow hanging paragraphs in annexes: they introduce lists -->
|
473
477
|
<ref name="BasicBlock"/>
|
474
478
|
</zeroOrMore>
|
475
|
-
<zeroOrMore>
|
476
|
-
<ref name="note"/>
|
477
|
-
</zeroOrMore>
|
478
479
|
<zeroOrMore>
|
479
480
|
<ref name="clause-hanging-paragraph-with-footnote"/>
|
480
481
|
</zeroOrMore>
|
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
|
-
<
|
75
|
+
<zeroOrMore>
|
68
76
|
<ref name="subject"/>
|
69
|
-
</
|
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
|
-
<
|
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
|
-
<
|
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
|
-
<
|
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>
|
@@ -14,7 +14,7 @@ module RelatonCen
|
|
14
14
|
# @param text [String]
|
15
15
|
# @return [RelatonCen::HitCollection]
|
16
16
|
def search(text, year = nil)
|
17
|
-
/^
|
17
|
+
/^C?EN\s(?<code>.+)/ =~ text
|
18
18
|
HitCollection.new code, year
|
19
19
|
rescue Mechanize::ResponseCodeError => e
|
20
20
|
raise RelatonBib::RequestError, e.message
|
@@ -26,20 +26,11 @@ module RelatonCen
|
|
26
26
|
# reference is required
|
27
27
|
# @return [RelatonBib::BibliographicItem, nil]
|
28
28
|
def get(code, year = nil, opts = {}) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
29
|
-
# if year.nil?
|
30
29
|
code1, year1 = code.split ":"
|
31
|
-
# unless code1.nil?
|
32
30
|
code = code1
|
33
31
|
year ||= year1
|
34
|
-
# end
|
35
|
-
# end
|
36
|
-
|
37
|
-
ret = bib_get1(code, year, opts)
|
38
|
-
return nil if ret.nil?
|
39
32
|
|
40
|
-
|
41
|
-
# ret = ret.to_all_parts if opts[:all_parts]
|
42
|
-
ret
|
33
|
+
bib_get1(code, year, opts)
|
43
34
|
end
|
44
35
|
|
45
36
|
private
|
@@ -67,7 +58,7 @@ module RelatonCen
|
|
67
58
|
# @param code [String]
|
68
59
|
# @return [RelatonCen::HitCollection]
|
69
60
|
def search_filter(code) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
70
|
-
%r{^
|
61
|
+
%r{^C?EN\s(?<code1>[^-:]+)(?:-(?<part1>\d+))?} =~ code
|
71
62
|
warn "[relaton-cen] (\"#{code}\") fetching..."
|
72
63
|
result = search(code)
|
73
64
|
result.select do |i|
|
@@ -5,7 +5,7 @@ require "relaton_cen/hit"
|
|
5
5
|
module RelatonCen
|
6
6
|
# Page of hit collection.
|
7
7
|
class HitCollection < RelatonBib::HitCollection
|
8
|
-
DOMAIN = "https://standards.
|
8
|
+
DOMAIN = "https://standards.cencenelec.eu/dyn/www/"
|
9
9
|
|
10
10
|
# @return [Mechanize]
|
11
11
|
attr_reader :agent
|
@@ -21,23 +21,25 @@ module RelatonCen
|
|
21
21
|
return
|
22
22
|
end
|
23
23
|
|
24
|
-
search_page = agent.get "#{DOMAIN}f?p=
|
25
|
-
form = search_page.at "//form"
|
26
|
-
|
27
|
-
|
24
|
+
search_page = agent.get "#{DOMAIN}f?p=205:105:0:::::"
|
25
|
+
form = search_page.at "//form[@id='wwvFlowForm']"
|
26
|
+
skip_inputs = %w[f11 essentialCookies]
|
27
|
+
req_body = form.xpath(".//input").map do |f|
|
28
|
+
next if f[:name].empty? || skip_inputs.include?(f[:name])
|
28
29
|
|
29
30
|
val = case f[:value]
|
30
31
|
when "LANGUAGE_LIST" then 0
|
31
32
|
when "STAND_REF" then ref
|
32
33
|
else
|
33
34
|
case f[:name]
|
34
|
-
when "p_request" then "S1-S2-S3-S4-S5-S6"
|
35
|
+
when "p_request" then "S1-S2-S3-S4-S5-S6-CEN-CLC-"
|
35
36
|
when "f10" then ""
|
36
37
|
else f[:value]
|
37
38
|
end
|
38
39
|
end
|
39
40
|
if f[:name] == "f10" then "f10=#{f[:value]}&f11=#{val}"
|
40
|
-
else
|
41
|
+
else
|
42
|
+
"#{f[:name]}=#{val}"
|
41
43
|
end
|
42
44
|
end.compact.join("&")
|
43
45
|
resp = agent.post form[:action], req_body
|
@@ -2,10 +2,10 @@ require "relaton/processor"
|
|
2
2
|
|
3
3
|
module RelatonCen
|
4
4
|
class Processor < Relaton::Processor
|
5
|
-
def initialize
|
5
|
+
def initialize # rubocop:disable Lint/MissingSuper
|
6
6
|
@short = :relaton_cen
|
7
7
|
@prefix = "CEN"
|
8
|
-
@defaultprefix = %r{^
|
8
|
+
@defaultprefix = %r{^C?EN\s}
|
9
9
|
@idtype = "CEN"
|
10
10
|
end
|
11
11
|
|
data/lib/relaton_cen/scrapper.rb
CHANGED
@@ -58,7 +58,7 @@ module RelatonCen
|
|
58
58
|
# @param ref [String]
|
59
59
|
# @return [Array<RelatonBib::DocumentIdentifier>]
|
60
60
|
def fetch_docid(ref)
|
61
|
-
[RelatonBib::DocumentIdentifier.new(type: "CEN", id: ref)]
|
61
|
+
[RelatonBib::DocumentIdentifier.new(type: "CEN", id: ref, primary: true)]
|
62
62
|
end
|
63
63
|
|
64
64
|
# Fetch status.
|
@@ -76,7 +76,7 @@ module RelatonCen
|
|
76
76
|
# @return [RelatonIsoBib::EditorialGroup]
|
77
77
|
def fetch_editorialgroup(doc) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
78
78
|
code = doc.at("//tr/td/h1/text()").text
|
79
|
-
title = doc.at("//tr/td/h1
|
79
|
+
title = doc.at("//tr/td[3]/h1").text
|
80
80
|
%r{/(?<type>\w+)(?:\s(?<num>[^/]+))?$} =~ code
|
81
81
|
tc = []
|
82
82
|
COMMITTEES.each do |k, v|
|
data/lib/relaton_cen/version.rb
CHANGED
data/relaton_cen.gemspec
CHANGED
@@ -42,7 +42,7 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_development_dependency "webmock"
|
43
43
|
|
44
44
|
spec.add_dependency "mechanize"
|
45
|
-
spec.add_dependency "relaton-iso-bib", "~> 1.
|
45
|
+
spec.add_dependency "relaton-iso-bib", "~> 1.10.1"
|
46
46
|
|
47
47
|
# For more information and examples about making a new gem, checkout our
|
48
48
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-cen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
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:
|
11
|
+
date: 2022-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.
|
159
|
+
version: 1.10.1
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 1.
|
166
|
+
version: 1.10.1
|
167
167
|
description: 'RelatonCen: retrieve Cenelec Standards for bibliographic use using the
|
168
168
|
IsoBibliographicItem model'
|
169
169
|
email:
|