relaton-iec 1.7.4 → 1.8.0
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 +230 -1
- data/bin/rspec +29 -0
- data/grammars/basicdoc.rng +165 -20
- data/grammars/biblio.rng +4 -6
- data/grammars/iec.rng +92 -1
- data/grammars/isodoc.rng +460 -6
- data/grammars/isostandard.rng +42 -104
- data/grammars/reqt.rng +31 -2
- data/lib/relaton_iec.rb +71 -7
- data/lib/relaton_iec/basic_block/alignment.rb +30 -0
- data/lib/relaton_iec/basic_block/basic_block.rb +15 -0
- data/lib/relaton_iec/basic_block/citation_type.rb +32 -0
- data/lib/relaton_iec/basic_block/dl.rb +60 -0
- data/lib/relaton_iec/basic_block/eref.rb +10 -0
- data/lib/relaton_iec/basic_block/eref_type.rb +39 -0
- data/lib/relaton_iec/basic_block/formula.rb +34 -0
- data/lib/relaton_iec/basic_block/image.rb +41 -0
- data/lib/relaton_iec/basic_block/index.rb +27 -0
- data/lib/relaton_iec/basic_block/index_xref.rb +31 -0
- data/lib/relaton_iec/basic_block/note.rb +21 -0
- data/lib/relaton_iec/basic_block/paragraph.rb +27 -0
- data/lib/relaton_iec/basic_block/paragraph_with_footnote.rb +29 -0
- data/lib/relaton_iec/basic_block/reference_format.rb +38 -0
- data/lib/relaton_iec/basic_block/stem.rb +30 -0
- data/lib/relaton_iec/basic_block/table.rb +115 -0
- data/lib/relaton_iec/basic_block/text_element.rb +27 -0
- data/lib/relaton_iec/hash_converter.rb +1 -1
- data/lib/relaton_iec/hit.rb +4 -0
- data/lib/relaton_iec/hit_collection.rb +31 -12
- data/lib/relaton_iec/iec_bibliographic_item.rb +92 -0
- data/lib/relaton_iec/iec_bibliography.rb +82 -49
- data/lib/relaton_iec/processor.rb +7 -2
- data/lib/relaton_iec/scrapper.rb +12 -40
- data/lib/relaton_iec/statuses.yml +84 -17
- data/lib/relaton_iec/tc_sc_officers_note.rb +24 -0
- data/lib/relaton_iec/version.rb +1 -1
- data/lib/relaton_iec/xml_parser.rb +21 -1
- data/relaton_iec.gemspec +3 -3
- metadata +25 -36
- data/.github/workflows/macos.yml +0 -34
- data/.github/workflows/ubuntu.yml +0 -33
- data/.github/workflows/windows.yml +0 -35
data/grammars/isostandard.rng
CHANGED
@@ -38,6 +38,9 @@
|
|
38
38
|
</define>
|
39
39
|
<define name="BibDataExtensionType">
|
40
40
|
<ref name="doctype"/>
|
41
|
+
<optional>
|
42
|
+
<ref name="horizontal"/>
|
43
|
+
</optional>
|
41
44
|
<ref name="editorialgroup"/>
|
42
45
|
<zeroOrMore>
|
43
46
|
<ref name="ics"/>
|
@@ -76,19 +79,6 @@
|
|
76
79
|
</choice>
|
77
80
|
</element>
|
78
81
|
</define>
|
79
|
-
<define name="ul">
|
80
|
-
<element name="ul">
|
81
|
-
<attribute name="id">
|
82
|
-
<data type="ID"/>
|
83
|
-
</attribute>
|
84
|
-
<oneOrMore>
|
85
|
-
<ref name="ul_li"/>
|
86
|
-
</oneOrMore>
|
87
|
-
<zeroOrMore>
|
88
|
-
<ref name="note"/>
|
89
|
-
</zeroOrMore>
|
90
|
-
</element>
|
91
|
-
</define>
|
92
82
|
<define name="sections">
|
93
83
|
<element name="sections">
|
94
84
|
<zeroOrMore>
|
@@ -137,22 +127,28 @@
|
|
137
127
|
</choice>
|
138
128
|
</attribute>
|
139
129
|
</optional>
|
130
|
+
<optional>
|
131
|
+
<attribute name="type"/>
|
132
|
+
</optional>
|
140
133
|
<optional>
|
141
134
|
<ref name="section-title"/>
|
142
135
|
</optional>
|
143
|
-
<
|
144
|
-
<
|
145
|
-
<
|
146
|
-
<
|
147
|
-
|
148
|
-
|
149
|
-
<
|
150
|
-
|
151
|
-
|
136
|
+
<group>
|
137
|
+
<choice>
|
138
|
+
<group>
|
139
|
+
<oneOrMore>
|
140
|
+
<ref name="BasicBlock"/>
|
141
|
+
</oneOrMore>
|
142
|
+
<zeroOrMore>
|
143
|
+
<ref name="note"/>
|
144
|
+
</zeroOrMore>
|
145
|
+
</group>
|
146
|
+
<ref name="amend"/>
|
147
|
+
</choice>
|
152
148
|
<oneOrMore>
|
153
149
|
<ref name="clause-subsection"/>
|
154
150
|
</oneOrMore>
|
155
|
-
</
|
151
|
+
</group>
|
156
152
|
</define>
|
157
153
|
<define name="term">
|
158
154
|
<element name="term">
|
@@ -183,17 +179,6 @@
|
|
183
179
|
</zeroOrMore>
|
184
180
|
</element>
|
185
181
|
</define>
|
186
|
-
<define name="definition">
|
187
|
-
<element name="definition">
|
188
|
-
<oneOrMore>
|
189
|
-
<choice>
|
190
|
-
<ref name="paragraph"/>
|
191
|
-
<ref name="figure"/>
|
192
|
-
<ref name="formula"/>
|
193
|
-
</choice>
|
194
|
-
</oneOrMore>
|
195
|
-
</element>
|
196
|
-
</define>
|
197
182
|
<define name="annex">
|
198
183
|
<element name="annex">
|
199
184
|
<optional>
|
@@ -271,6 +256,7 @@
|
|
271
256
|
<value>guide</value>
|
272
257
|
<value>amendment</value>
|
273
258
|
<value>technical-corrigendum</value>
|
259
|
+
<value>directive</value>
|
274
260
|
</choice>
|
275
261
|
</define>
|
276
262
|
<define name="structuredidentifier">
|
@@ -324,6 +310,11 @@
|
|
324
310
|
<optional>
|
325
311
|
<attribute name="script"/>
|
326
312
|
</optional>
|
313
|
+
<optional>
|
314
|
+
<attribute name="inline-header">
|
315
|
+
<data type="boolean"/>
|
316
|
+
</attribute>
|
317
|
+
</optional>
|
327
318
|
<optional>
|
328
319
|
<attribute name="obligation">
|
329
320
|
<choice>
|
@@ -332,6 +323,12 @@
|
|
332
323
|
</choice>
|
333
324
|
</attribute>
|
334
325
|
</optional>
|
326
|
+
<optional>
|
327
|
+
<attribute name="number"/>
|
328
|
+
</optional>
|
329
|
+
<optional>
|
330
|
+
<attribute name="type"/>
|
331
|
+
</optional>
|
335
332
|
<optional>
|
336
333
|
<ref name="section-title"/>
|
337
334
|
</optional>
|
@@ -349,54 +346,6 @@
|
|
349
346
|
</oneOrMore>
|
350
347
|
</choice>
|
351
348
|
</define>
|
352
|
-
<define name="table">
|
353
|
-
<element name="table">
|
354
|
-
<attribute name="id">
|
355
|
-
<data type="ID"/>
|
356
|
-
</attribute>
|
357
|
-
<optional>
|
358
|
-
<attribute name="width"/>
|
359
|
-
</optional>
|
360
|
-
<optional>
|
361
|
-
<attribute name="unnumbered">
|
362
|
-
<data type="boolean"/>
|
363
|
-
</attribute>
|
364
|
-
</optional>
|
365
|
-
<optional>
|
366
|
-
<attribute name="number"/>
|
367
|
-
</optional>
|
368
|
-
<optional>
|
369
|
-
<attribute name="subsequence"/>
|
370
|
-
</optional>
|
371
|
-
<optional>
|
372
|
-
<attribute name="alt"/>
|
373
|
-
</optional>
|
374
|
-
<optional>
|
375
|
-
<attribute name="summary"/>
|
376
|
-
</optional>
|
377
|
-
<optional>
|
378
|
-
<attribute name="uri">
|
379
|
-
<data type="anyURI"/>
|
380
|
-
</attribute>
|
381
|
-
</optional>
|
382
|
-
<optional>
|
383
|
-
<ref name="tname"/>
|
384
|
-
</optional>
|
385
|
-
<optional>
|
386
|
-
<ref name="thead"/>
|
387
|
-
</optional>
|
388
|
-
<ref name="tbody"/>
|
389
|
-
<optional>
|
390
|
-
<ref name="tfoot"/>
|
391
|
-
</optional>
|
392
|
-
<zeroOrMore>
|
393
|
-
<ref name="table-note"/>
|
394
|
-
</zeroOrMore>
|
395
|
-
<optional>
|
396
|
-
<ref name="dl"/>
|
397
|
-
</optional>
|
398
|
-
</element>
|
399
|
-
</define>
|
400
349
|
</include>
|
401
350
|
<!-- end overrides -->
|
402
351
|
<!--
|
@@ -416,6 +365,9 @@
|
|
416
365
|
<zeroOrMore>
|
417
366
|
<ref name="termdocsource"/>
|
418
367
|
</zeroOrMore>
|
368
|
+
<optional>
|
369
|
+
<ref name="misccontainer"/>
|
370
|
+
</optional>
|
419
371
|
<optional>
|
420
372
|
<ref name="boilerplate"/>
|
421
373
|
</optional>
|
@@ -427,6 +379,14 @@
|
|
427
379
|
<ref name="annex"/>
|
428
380
|
</zeroOrMore>
|
429
381
|
<ref name="bibliography"/>
|
382
|
+
<zeroOrMore>
|
383
|
+
<ref name="indexsect"/>
|
384
|
+
</zeroOrMore>
|
385
|
+
</element>
|
386
|
+
</define>
|
387
|
+
<define name="horizontal">
|
388
|
+
<element name="horizontal">
|
389
|
+
<data type="boolean"/>
|
430
390
|
</element>
|
431
391
|
</define>
|
432
392
|
<define name="documentnumber">
|
@@ -510,28 +470,6 @@
|
|
510
470
|
<ref name="Clause-Section"/>
|
511
471
|
</element>
|
512
472
|
</define>
|
513
|
-
<define name="ul_li">
|
514
|
-
<element name="li">
|
515
|
-
<optional>
|
516
|
-
<attribute name="id">
|
517
|
-
<data type="ID"/>
|
518
|
-
</attribute>
|
519
|
-
</optional>
|
520
|
-
<optional>
|
521
|
-
<attribute name="uncheckedcheckbox">
|
522
|
-
<data type="boolean"/>
|
523
|
-
</attribute>
|
524
|
-
</optional>
|
525
|
-
<optional>
|
526
|
-
<attribute name="checkedcheckbox">
|
527
|
-
<data type="boolean"/>
|
528
|
-
</attribute>
|
529
|
-
</optional>
|
530
|
-
<oneOrMore>
|
531
|
-
<ref name="BasicBlock"/>
|
532
|
-
</oneOrMore>
|
533
|
-
</element>
|
534
|
-
</define>
|
535
473
|
<define name="stagename">
|
536
474
|
<element name="stagename">
|
537
475
|
<text/>
|
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>
|
data/lib/relaton_iec.rb
CHANGED
@@ -10,12 +10,76 @@ require "relaton_iec/hash_converter"
|
|
10
10
|
require "digest/md5"
|
11
11
|
|
12
12
|
module RelatonIec
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
class << self
|
14
|
+
# Returns hash of XML reammar
|
15
|
+
# @return [String]
|
16
|
+
def grammar_hash
|
17
|
+
gem_path = File.expand_path "..", __dir__
|
18
|
+
grammars_path = File.join gem_path, "grammars", "*"
|
19
|
+
grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
20
|
+
Digest::MD5.hexdigest grammars
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param code [String]
|
24
|
+
# @param lang [String]
|
25
|
+
# @return [String, nil]
|
26
|
+
def code_to_urn(code, lang = nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
27
|
+
rest = code.downcase.sub(%r{
|
28
|
+
(?<head>[^\s]+)\s
|
29
|
+
(?<type>is|ts|tr|pas|srd|guide|tec|wp)?(?(<type>)\s)
|
30
|
+
(?<pnum>[\d-]+)\s?
|
31
|
+
(?<_dd>:)?(?(<_dd>)(?<date>[\d-]+)\s?)
|
32
|
+
}x, "")
|
33
|
+
m = $~
|
34
|
+
return unless m[:head] && m[:pnum]
|
35
|
+
|
36
|
+
deliv = /cmv|csv|exv|prv|rlv|ser/.match(code.downcase).to_s
|
37
|
+
urn = ["urn", "iec", "std", m[:head].split("/").join("-"), m[:pnum], m[:date], m[:type], deliv, lang]
|
38
|
+
(urn + ajunct_to_urn(rest)).join ":"
|
39
|
+
end
|
40
|
+
|
41
|
+
# @param urn [String]
|
42
|
+
# @return [Array<String>, nil] urn & language
|
43
|
+
def urn_to_code(urn) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
44
|
+
fields = urn.upcase.split ":"
|
45
|
+
return if fields.size < 5
|
46
|
+
|
47
|
+
head, num, date, type, deliv, lang = fields[3, 8]
|
48
|
+
code = head.gsub("-", "/")
|
49
|
+
code += " #{type}" unless type.nil? || type.empty?
|
50
|
+
code += " #{num}"
|
51
|
+
code += ":#{date}" unless date.nil? || date.empty?
|
52
|
+
code += ajanct_to_code(fields[9..-1])
|
53
|
+
code += " #{deliv}" unless deliv.nil? || deliv.empty?
|
54
|
+
[code, lang&.downcase]
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
# @param fields [Array<String>]
|
60
|
+
# @return [String]
|
61
|
+
def ajanct_to_code(fields)
|
62
|
+
return "" if fields.nil? || fields.empty?
|
63
|
+
|
64
|
+
rel, type, num, date = fields[0..3]
|
65
|
+
code = (rel.empty? ? "/" : "+") + type + num
|
66
|
+
code += ":#{date}" unless date.empty?
|
67
|
+
code + ajanct_to_code(fields[4..-1])
|
68
|
+
end
|
69
|
+
|
70
|
+
# @param rest [String]
|
71
|
+
# @return [Array<String, nil>]
|
72
|
+
def ajunct_to_urn(rest)
|
73
|
+
r = rest.sub(%r{
|
74
|
+
(?<pl>\+|\/)(?(<pl>)(?<adjunct>(amd|cor|ish))(?<adjnum>\d+)\s?)
|
75
|
+
(?<_d2>:)?(?(<_d2>)(?<adjdt>[\d-]+)\s?)
|
76
|
+
}x, "")
|
77
|
+
m = $~ || {}
|
78
|
+
return [] unless m[:adjunct]
|
79
|
+
|
80
|
+
plus = "plus" if m[:pl] == "+"
|
81
|
+
urn = [plus, m[:adjunct], m[:adjnum], m[:adjdt]]
|
82
|
+
urn + ajunct_to_urn(r)
|
83
|
+
end
|
20
84
|
end
|
21
85
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module BasicBlock
|
2
|
+
class Alignment
|
3
|
+
ALIGNS = %w[left right center justified].freeze
|
4
|
+
|
5
|
+
#
|
6
|
+
# @param [String] content
|
7
|
+
#
|
8
|
+
def initialize(content)
|
9
|
+
unless ALIGNS.include?(content)
|
10
|
+
warn "[basic-block] WARNING: invalid alignment \"#{content}\""
|
11
|
+
warn "[basic-block] alloved aligments are: #{ALIGNS.join ', '}"
|
12
|
+
end
|
13
|
+
@content = content
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# @return [String]
|
18
|
+
#
|
19
|
+
def to_s
|
20
|
+
@content
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
#
|
26
|
+
def inspect
|
27
|
+
to_s
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative "alignment"
|
2
|
+
require_relative "citation_type"
|
3
|
+
require_relative "dl"
|
4
|
+
require_relative "eref_type"
|
5
|
+
require_relative "eref"
|
6
|
+
require_relative "formula"
|
7
|
+
require_relative "image"
|
8
|
+
require_relative "index_xref"
|
9
|
+
require_relative "index"
|
10
|
+
require_relative "note"
|
11
|
+
require_relative "paragraph_with_footnote"
|
12
|
+
require_relative "paragraph"
|
13
|
+
require_relative "reference_format"
|
14
|
+
require_relative "stem"
|
15
|
+
require_relative "text_element"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RelatonIec
|
2
|
+
class CitationType
|
3
|
+
# @return [String]
|
4
|
+
attr_reader :bibitemid
|
5
|
+
|
6
|
+
# @return [Array<elatonBib::Locality, RelatonBib::LocalityStack>]
|
7
|
+
attr_reader :locality
|
8
|
+
|
9
|
+
# @return [String, nil]
|
10
|
+
attr_reader :date
|
11
|
+
|
12
|
+
#
|
13
|
+
# @param [String] bibitemid
|
14
|
+
# @param [Array<RelatonBib::Locality, RelatonBib::LocalityStack>] locality
|
15
|
+
# @param [String, nil] date
|
16
|
+
#
|
17
|
+
def initialize(bibitemid:, locality:, date: nil)
|
18
|
+
@bibitemid = bibitemid
|
19
|
+
@locality = locality
|
20
|
+
@date = date
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# @param [Nokogiri::XML::Builder] builder
|
25
|
+
#
|
26
|
+
def to_xml(builder)
|
27
|
+
builder.parent[:bibitemid] = bibitemid
|
28
|
+
locality.each { |l| l.to_xml builder }
|
29
|
+
builder.date date if date
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|