metanorma-iec 1.3.8 → 1.3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asciidoctor/iec/isodoc.rng +49 -11
- data/lib/asciidoctor/iec/isostandard.rng +4 -1
- data/lib/asciidoctor/iec/reqt.rng +15 -4
- data/lib/isodoc/iec/iec.international-standard.xsl +472 -169
- data/lib/metanorma/iec/processor.rb +1 -1
- data/lib/metanorma/iec/version.rb +1 -1
- data/spec/isodoc/iso_spec.rb +166 -172
- data/spec/spec_helper.rb +170 -165
- metadata +2 -2
data/spec/spec_helper.rb
CHANGED
@@ -25,218 +25,224 @@ RSpec.configure do |config|
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def metadata(
|
29
|
-
|
28
|
+
def metadata(xml)
|
29
|
+
xml.sort.to_h.delete_if do |_k, v|
|
30
|
+
v.nil? || v.respond_to?(:empty?) && v.empty?
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
|
-
def strip_guid(
|
33
|
-
|
34
|
+
def strip_guid(xml)
|
35
|
+
xml.gsub(%r{ id="_[^"]+"}, ' id="_"').gsub(%r{ target="_[^"]+"},
|
36
|
+
' target="_"')
|
34
37
|
end
|
35
38
|
|
36
|
-
def xmlpp(
|
39
|
+
def xmlpp(xml)
|
37
40
|
s = ""
|
38
41
|
f = REXML::Formatters::Pretty.new(2)
|
39
42
|
f.compact = true
|
40
|
-
f.write(REXML::Document.new(
|
43
|
+
f.write(REXML::Document.new(xml), s)
|
41
44
|
s
|
42
45
|
end
|
43
46
|
|
44
47
|
OPTIONS = [backend: :iec, header_footer: true, agree_to_terms: true].freeze
|
45
48
|
|
46
|
-
ASCIIDOC_BLANK_HDR = <<~"HDR"
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
ASCIIDOC_BLANK_HDR = <<~"HDR".freeze
|
50
|
+
= Document title
|
51
|
+
Author
|
52
|
+
:docfile: test.adoc
|
53
|
+
:nodoc:
|
54
|
+
:novalid:
|
55
|
+
:no-isobib:
|
53
56
|
|
54
57
|
HDR
|
55
58
|
|
56
|
-
ISOBIB_BLANK_HDR = <<~"HDR"
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
ISOBIB_BLANK_HDR = <<~"HDR".freeze
|
60
|
+
= Document title
|
61
|
+
Author
|
62
|
+
:docfile: test.adoc
|
63
|
+
:nodoc:
|
64
|
+
:novalid:
|
65
|
+
:no-isobib-cache:
|
63
66
|
|
64
67
|
HDR
|
65
68
|
|
66
|
-
FLUSH_CACHE_ISOBIB_BLANK_HDR = <<~"HDR"
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
FLUSH_CACHE_ISOBIB_BLANK_HDR = <<~"HDR".freeze
|
70
|
+
= Document title
|
71
|
+
Author
|
72
|
+
:docfile: test.adoc
|
73
|
+
:nodoc:
|
74
|
+
:novalid:
|
75
|
+
:flush-caches:
|
73
76
|
|
74
77
|
HDR
|
75
78
|
|
76
|
-
CACHED_ISOBIB_BLANK_HDR = <<~"HDR"
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
CACHED_ISOBIB_BLANK_HDR = <<~"HDR".freeze
|
80
|
+
= Document title
|
81
|
+
Author
|
82
|
+
:docfile: test.adoc
|
83
|
+
:nodoc:
|
84
|
+
:novalid:
|
82
85
|
|
83
86
|
HDR
|
84
87
|
|
85
|
-
LOCAL_CACHED_ISOBIB_BLANK_HDR = <<~"HDR"
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
LOCAL_CACHED_ISOBIB_BLANK_HDR = <<~"HDR".freeze
|
89
|
+
= Document title
|
90
|
+
Author
|
91
|
+
:docfile: test.adoc
|
92
|
+
:nodoc:
|
93
|
+
:novalid:
|
94
|
+
:local-cache:
|
92
95
|
|
93
96
|
HDR
|
94
97
|
|
95
|
-
VALIDATING_BLANK_HDR = <<~"HDR"
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
98
|
+
VALIDATING_BLANK_HDR = <<~"HDR".freeze
|
99
|
+
= Document title
|
100
|
+
Author
|
101
|
+
:docfile: test.adoc
|
102
|
+
:nodoc:
|
103
|
+
:no-isobib:
|
101
104
|
|
102
105
|
HDR
|
103
106
|
|
104
|
-
TERMS_BOILERPLATE = <<~"BOILERPLATE"
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
</ul>
|
107
|
+
TERMS_BOILERPLATE = <<~"BOILERPLATE".freeze
|
108
|
+
<p id="_">ISO and IEC maintain terminological databases for use in
|
109
|
+
standardization at the following addresses:</p>
|
110
|
+
#{' '}
|
111
|
+
<ul id="_">
|
112
|
+
<li> <p id="_">IEC Electropedia: available at
|
113
|
+
<link target="http://www.electropedia.org"/>
|
114
|
+
</p> </li>#{' '}
|
115
|
+
<li> <p id="_">ISO Online browsing platform: available at
|
116
|
+
<link target="http://www.iso.org/obp"/></p> </li>
|
117
|
+
</ul>
|
115
118
|
BOILERPLATE
|
116
119
|
|
117
120
|
def boilerplate(xmldoc)
|
118
|
-
file = File.read(
|
119
|
-
|
120
|
-
|
121
|
+
file = File.read(
|
122
|
+
File.join(File.dirname(__FILE__), "..", "lib", "asciidoctor", "iec",
|
123
|
+
"iec_intro_en.xml"), encoding: "utf-8"
|
124
|
+
)
|
125
|
+
conv = Asciidoctor::Iec::Converter.new(nil, backend: :iec,
|
126
|
+
header_footer: true)
|
127
|
+
conv.init(Asciidoctor::Document.new([]))
|
121
128
|
ret = Nokogiri::XML(
|
122
|
-
conv.boilerplate_isodoc(xmldoc).populate_template(file, nil)
|
123
|
-
gsub(/<p>/, "<p id='_'>")
|
124
|
-
gsub(/<ol>/, "<ol id='_'>")
|
129
|
+
conv.boilerplate_isodoc(xmldoc).populate_template(file, nil)
|
130
|
+
.gsub(/<p>/, "<p id='_'>")
|
131
|
+
.gsub(/<ol>/, "<ol id='_'>"),
|
132
|
+
)
|
125
133
|
conv.smartquotes_cleanup(ret)
|
126
134
|
HTMLEntities.new.decode(ret.to_xml)
|
127
135
|
end
|
128
136
|
|
129
|
-
BLANK_HDR = <<~"HDR"
|
130
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
131
|
-
<iec-standard xmlns="https://www.metanorma.org/ns/iec" type="semantic" version="#{Metanorma::Iec::VERSION}">
|
132
|
-
<bibdata type="standard">
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
<organization>
|
143
|
-
<name>International Electrotechnical Commission</name>
|
144
|
-
<abbreviation>IEC</abbreviation>
|
145
|
-
</organization>
|
146
|
-
</contributor>
|
147
|
-
<language>en</language>
|
148
|
-
<script>Latn</script>
|
149
|
-
<status>
|
150
|
-
<stage abbreviation="PPUB">60</stage>
|
151
|
-
<substage abbreviation="PPUB">60</substage>
|
152
|
-
</status>
|
153
|
-
<copyright>
|
154
|
-
<from>#{Time.new.year}</from>
|
155
|
-
<owner>
|
137
|
+
BLANK_HDR = <<~"HDR".freeze
|
138
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
139
|
+
<iec-standard xmlns="https://www.metanorma.org/ns/iec" type="semantic" version="#{Metanorma::Iec::VERSION}">
|
140
|
+
<bibdata type="standard">
|
141
|
+
<contributor>
|
142
|
+
<role type="author"/>
|
143
|
+
<organization>
|
144
|
+
<name>International Electrotechnical Commission</name>
|
145
|
+
<abbreviation>IEC</abbreviation>
|
146
|
+
</organization>
|
147
|
+
</contributor>
|
148
|
+
<contributor>
|
149
|
+
<role type="publisher"/>
|
156
150
|
<organization>
|
157
151
|
<name>International Electrotechnical Commission</name>
|
158
152
|
<abbreviation>IEC</abbreviation>
|
159
153
|
</organization>
|
160
|
-
</
|
161
|
-
|
162
|
-
|
163
|
-
<
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
<
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
</
|
154
|
+
</contributor>
|
155
|
+
<language>en</language>
|
156
|
+
<script>Latn</script>
|
157
|
+
<status>
|
158
|
+
<stage abbreviation="PPUB">60</stage>
|
159
|
+
<substage abbreviation="PPUB">60</substage>
|
160
|
+
</status>
|
161
|
+
<copyright>
|
162
|
+
<from>#{Time.new.year}</from>
|
163
|
+
<owner>
|
164
|
+
<organization>
|
165
|
+
<name>International Electrotechnical Commission</name>
|
166
|
+
<abbreviation>IEC</abbreviation>
|
167
|
+
</organization>
|
168
|
+
</owner>
|
169
|
+
</copyright>
|
170
|
+
<ext>
|
171
|
+
<doctype>article</doctype>
|
172
|
+
<horizontal>false</horizontal>
|
173
|
+
<editorialgroup>
|
174
|
+
<technical-committee/>
|
175
|
+
<subcommittee/>
|
176
|
+
<workgroup/>
|
177
|
+
</editorialgroup>
|
178
|
+
<stagename>International standard</stagename>
|
179
|
+
</ext>
|
180
|
+
</bibdata>
|
173
181
|
HDR
|
174
182
|
|
175
183
|
def blank_hdr_gen
|
176
|
-
<<~"HDR"
|
177
|
-
#{BLANK_HDR}
|
178
|
-
#{boilerplate(Nokogiri::XML(BLANK_HDR
|
179
|
-
HDR
|
184
|
+
<<~"HDR"
|
185
|
+
#{BLANK_HDR}
|
186
|
+
#{boilerplate(Nokogiri::XML("#{BLANK_HDR}</iec-standard>"))}
|
187
|
+
HDR
|
180
188
|
end
|
181
189
|
|
190
|
+
IEC_TITLE = <<~TITLE.freeze
|
191
|
+
<p class="zzSTDTitle1">INTERNATIONAL ELECTROTECHNICAL COMMISSION</p>
|
192
|
+
<p class="zzSTDTitle1">____________</p>
|
193
|
+
<p class="zzSTDTitle1"> </p>
|
194
|
+
<p class="zzSTDTitle1">
|
195
|
+
<b/>
|
196
|
+
</p>
|
197
|
+
<p class="zzSTDTitle1"> </p>
|
198
|
+
TITLE
|
199
|
+
|
200
|
+
IEC_TITLE1 = <<~TITLE.freeze
|
201
|
+
<p class="zzSTDTitle1">
|
202
|
+
<b/>
|
203
|
+
</p>
|
204
|
+
<p class="zzSTDTitle1"> </p>
|
205
|
+
TITLE
|
206
|
+
|
207
|
+
HTML_HDR = <<~HDR.freeze
|
208
|
+
<html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
|
209
|
+
<head/>
|
210
|
+
<body lang="en">
|
211
|
+
<div class="title-section">
|
212
|
+
<p> </p>
|
213
|
+
</div>
|
214
|
+
<br/>
|
215
|
+
<div class="prefatory-section">
|
216
|
+
<p> </p>
|
217
|
+
</div>
|
218
|
+
<br/>
|
219
|
+
<div class="main-section">
|
220
|
+
<br/>
|
221
|
+
#{IEC_TITLE}
|
222
|
+
HDR
|
182
223
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
HTML_HDR = <<~END
|
201
|
-
<html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
|
202
|
-
<head/>
|
203
|
-
<body lang="en">
|
204
|
-
<div class="title-section">
|
205
|
-
<p> </p>
|
206
|
-
</div>
|
207
|
-
<br/>
|
208
|
-
<div class="prefatory-section">
|
209
|
-
<p> </p>
|
210
|
-
</div>
|
211
|
-
<br/>
|
212
|
-
<div class="main-section">
|
213
|
-
<br/>
|
214
|
-
#{IEC_TITLE}
|
215
|
-
END
|
216
|
-
|
217
|
-
WORD_HDR = <<~END
|
218
|
-
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
219
|
-
<head>
|
220
|
-
<title>test</title>
|
221
|
-
</head>
|
222
|
-
<body lang="EN-US" link="blue" vlink="#954F72">
|
223
|
-
<div class="WordSection1">
|
224
|
-
<p> </p>
|
225
|
-
</div>
|
226
|
-
<p><br clear="all" class="section"/></p>
|
227
|
-
<div class="WordSection2">
|
228
|
-
<p> </p>
|
229
|
-
</div>
|
230
|
-
<p><br clear="all" class="section"/></p>
|
231
|
-
<div class="WordSection3">
|
232
|
-
END
|
233
|
-
|
224
|
+
WORD_HDR = <<~HDR.freeze
|
225
|
+
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
226
|
+
<head>
|
227
|
+
<title>test</title>
|
228
|
+
</head>
|
229
|
+
<body lang="EN-US" link="blue" vlink="#954F72">
|
230
|
+
<div class="WordSection1">
|
231
|
+
<p> </p>
|
232
|
+
</div>
|
233
|
+
<p><br clear="all" class="section"/></p>
|
234
|
+
<div class="WordSection2">
|
235
|
+
<p> </p>
|
236
|
+
</div>
|
237
|
+
<p><br clear="all" class="section"/></p>
|
238
|
+
<div class="WordSection3">
|
239
|
+
HDR
|
234
240
|
|
235
241
|
def stub_fetch_ref(**opts)
|
236
242
|
xml = ""
|
237
243
|
|
238
244
|
hit = double("hit")
|
239
|
-
expect(hit).to receive(:
|
245
|
+
expect(hit).to receive(:[]).with("title") do
|
240
246
|
Nokogiri::XML(xml).at("//docidentifier").content
|
241
247
|
end.at_least(:once)
|
242
248
|
|
@@ -254,8 +260,8 @@ def stub_fetch_ref(**opts)
|
|
254
260
|
hit_pages = double("hit_pages")
|
255
261
|
expect(hit_pages).to receive(:first).and_return(hit_page).at_least :once
|
256
262
|
|
257
|
-
expect(Isobib::IsoBibliography).to receive(:search)
|
258
|
-
and_wrap_original do |search, *args|
|
263
|
+
expect(Isobib::IsoBibliography).to receive(:search)
|
264
|
+
.and_wrap_original do |search, *args|
|
259
265
|
code = args[0]
|
260
266
|
expect(code).to be_instance_of String
|
261
267
|
xml = get_xml(search, code, opts)
|
@@ -264,7 +270,7 @@ def stub_fetch_ref(**opts)
|
|
264
270
|
end
|
265
271
|
|
266
272
|
def mock_pdf
|
267
|
-
allow(::Mn2pdf).to receive(:convert) do |url, output,
|
273
|
+
allow(::Mn2pdf).to receive(:convert) do |url, output, _c, _d|
|
268
274
|
FileUtils.cp(url.gsub(/"/, ""), output.gsub(/"/, ""))
|
269
275
|
end
|
270
276
|
end
|
@@ -272,7 +278,7 @@ end
|
|
272
278
|
private
|
273
279
|
|
274
280
|
def get_xml(search, code, opts)
|
275
|
-
c = code.gsub(%r{[
|
281
|
+
c = code.gsub(%r{[/\s:-]}, "_").sub(%r{_+$}, "").downcase
|
276
282
|
o = opts.keys.join "_"
|
277
283
|
file = "spec/examples/#{[c, o].join '_'}.xml"
|
278
284
|
if File.exist? file
|
@@ -287,11 +293,10 @@ def get_xml(search, code, opts)
|
|
287
293
|
end
|
288
294
|
|
289
295
|
def mock_open_uri(code)
|
290
|
-
#expect(OpenURI).to receive(:open_uri).and_wrap_original do |m, *args|
|
296
|
+
# expect(OpenURI).to receive(:open_uri).and_wrap_original do |m, *args|
|
291
297
|
expect(Iev).to receive(:get).with(code, "en") do |m, *args|
|
292
298
|
file = "spec/examples/#{code.tr('-', '_')}.html"
|
293
299
|
File.write file, m.call(*args).read unless File.exist? file
|
294
300
|
File.read file
|
295
301
|
end.at_least :once
|
296
302
|
end
|
297
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-iec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metanorma-iso
|