metanorma-iec 2.0.7 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,12 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe Metanorma::Iec do
4
- before(:all) do
5
- @blank_hdr = blank_hdr_gen
6
- end
4
+ before(:all) do
5
+ @blank_hdr = blank_hdr_gen
6
+ end
7
7
 
8
8
  it "processes sections" do
9
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
9
+ input = <<~INPUT
10
10
  #{ASCIIDOC_BLANK_HDR}
11
11
  .Foreword
12
12
 
@@ -56,69 +56,72 @@ end
56
56
 
57
57
  === Bibliography Subsection
58
58
  INPUT
59
- #{@blank_hdr}
60
- <preface><foreword id="_" obligation="informative">
61
- <title>FOREWORD</title>
62
- <p id="_">Text</p>
63
- </foreword><introduction id="_" obligation="informative">
64
- <title>INTRODUCTION</title><clause id="_" inline-header="false" obligation="informative">
65
- <title>Introduction Subsection</title>
66
- </clause>
67
- </introduction></preface><sections>
68
- <clause id="_" obligation="normative" type="scope" inline-header='false'>
69
- <title>Scope</title>
70
- <p id="_">Text</p>
71
- </clause>
72
-
73
- <terms id="_" obligation="normative">
74
- <title>Terms and definitions</title>
75
- <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
76
- #{TERMS_BOILERPLATE}
77
- <term id="term-term1">
78
- <preferred><expression><name>Term1</name></expression></preferred>
79
- </term>
80
- </terms>
81
- <clause id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><terms id="_" obligation="normative">
82
- <title>Normal Terms</title>
83
- <term id="term-term2">
84
- <preferred><expression><name>Term2</name></expression></preferred>
85
- </term>
86
- </terms>
87
- <definitions id="_" obligation="normative"><title>Symbols and abbreviated terms</title></definitions></clause>
88
- <definitions id="_" obligation="normative"><title>Symbols and abbreviated terms</title></definitions>
89
- <clause id="_" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="_" inline-header="false" obligation="normative">
90
- <title>Introduction</title>
91
- </clause>
92
- <clause id="_" inline-header="false" obligation="normative">
93
- <title>Clause 4.2</title>
94
- </clause></clause>
95
- <clause id="_" inline-header="false" obligation="normative">
96
- <title>Terms and Definitions</title>
97
- </clause>
98
-
99
-
100
- </sections><annex id="_" inline-header="false" obligation="normative">
101
- <title>Annex</title>
102
- <clause id="_" inline-header="false" obligation="normative">
103
- <title>Annex A.1</title>
104
- </clause>
105
- <appendix id="_" inline-header="false" obligation="normative">
106
- <title>Appendix 1</title>
107
- </appendix></annex><bibliography><references id="_" obligation="informative" normative="true">
108
- <title>Normative references</title><p id="_">There are no normative references in this document.</p>
109
- </references><clause id="_" obligation="informative">
110
- <title>Bibliography</title>
111
- <references id="_" obligation="informative" normative="false">
112
- <title>Bibliography Subsection</title>
113
- </references>
114
- </clause>
115
- </bibliography>
116
- </iec-standard>
59
+ output = <<~OUTPUT
60
+ #{@blank_hdr}
61
+ <preface><foreword id="_" obligation="informative">
62
+ <title>FOREWORD</title>
63
+ <p id="_">Text</p>
64
+ </foreword><introduction id="_" obligation="informative">
65
+ <title>INTRODUCTION</title><clause id="_" inline-header="false" obligation="informative">
66
+ <title>Introduction Subsection</title>
67
+ </clause>
68
+ </introduction></preface><sections>
69
+ <clause id="_" obligation="normative" type="scope" inline-header='false'>
70
+ <title>Scope</title>
71
+ <p id="_">Text</p>
72
+ </clause>
73
+
74
+ <terms id="_" obligation="normative">
75
+ <title>Terms and definitions</title>
76
+ <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
77
+ #{TERMS_BOILERPLATE}
78
+ <term id="term-Term1">
79
+ <preferred><expression><name>Term1</name></expression></preferred>
80
+ </term>
81
+ </terms>
82
+ <clause id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title><terms id="_" obligation="normative">
83
+ <title>Normal Terms</title>
84
+ <term id="term-Term2">
85
+ <preferred><expression><name>Term2</name></expression></preferred>
86
+ </term>
87
+ </terms>
88
+ <definitions id="_" obligation="normative"><title>Symbols and abbreviated terms</title></definitions></clause>
89
+ <definitions id="_" obligation="normative"><title>Symbols and abbreviated terms</title></definitions>
90
+ <clause id="_" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="_" inline-header="false" obligation="normative">
91
+ <title>Introduction</title>
92
+ </clause>
93
+ <clause id="_" inline-header="false" obligation="normative">
94
+ <title>Clause 4.2</title>
95
+ </clause></clause>
96
+ <clause id="_" inline-header="false" obligation="normative">
97
+ <title>Terms and Definitions</title>
98
+ </clause>
99
+
100
+
101
+ </sections><annex id="_" inline-header="false" obligation="normative">
102
+ <title>Annex</title>
103
+ <clause id="_" inline-header="false" obligation="normative">
104
+ <title>Annex A.1</title>
105
+ </clause>
106
+ <appendix id="_" inline-header="false" obligation="normative">
107
+ <title>Appendix 1</title>
108
+ </appendix></annex><bibliography><references id="_" obligation="informative" normative="true">
109
+ <title>Normative references</title><p id="_">There are no normative references in this document.</p>
110
+ </references><clause id="_" obligation="informative">
111
+ <title>Bibliography</title>
112
+ <references id="_" obligation="informative" normative="false">
113
+ <title>Bibliography Subsection</title>
114
+ </references>
115
+ </clause>
116
+ </bibliography>
117
+ </iec-standard>
117
118
  OUTPUT
119
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
120
+ .to be_equivalent_to xmlpp(output)
118
121
  end
119
122
 
120
123
  it "processes sections with title attributes" do
121
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
124
+ input = <<~INPUT
122
125
  #{ASCIIDOC_BLANK_HDR}
123
126
  .Foreword
124
127
 
@@ -174,84 +177,86 @@ end
174
177
 
175
178
  === Bibliography Subsection
176
179
  INPUT
177
- #{@blank_hdr}
178
- <preface>
179
- <foreword id="_" obligation="informative">
180
- <title>FOREWORD</title>
181
- <p id="_">Text</p>
182
- </foreword>
183
- <introduction id="_" obligation="informative">
184
- <title>INTRODUCTION</title><clause id="_" inline-header="false" obligation="informative">
185
- <title>Introduction Subsection</title>
186
- </clause>
187
- </introduction>
188
- </preface>
189
- <sections>
190
- <clause id="_" obligation="normative" type="scope" inline-header='false'>
191
- <title>Scope</title>
192
- <p id="_">Text</p>
193
- </clause>
194
-
195
- <terms id="_" obligation="normative">
196
- <title>Terms and definitions</title>
197
- <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
198
- #{TERMS_BOILERPLATE}
199
- <term id="term-term1">
200
- <preferred><expression><name>Term1</name></expression></preferred>
201
- </term>
202
- </terms>
203
- <clause id='_' obligation='normative'>
204
- <title>Terms, definitions, symbols and abbreviated terms</title>
205
- <terms id='_' obligation='normative'>
206
- <title>Normal Terms</title>
207
- <term id='term-term2'>
208
- <preferred><expression><name>Term2</name></expression></preferred>
209
- </term>
210
- </terms>
211
- <definitions id='_' obligation="normative">
212
- <title>Symbols and abbreviated terms</title>
213
- </definitions>
214
- </clause>
215
- <definitions id='_' obligation="normative">
216
- <title>Symbols and abbreviated terms</title>
217
- </definitions>
218
- <clause id='_' inline-header='false' obligation='normative'>
219
- <title>Clause 4</title>
220
- <clause id='_' inline-header='false' obligation='normative'>
221
- <title>Introduction</title>
180
+ output = <<~OUTPUT
181
+ #{@blank_hdr}
182
+ <preface>
183
+ <foreword id="_" obligation="informative">
184
+ <title>FOREWORD</title>
185
+ <p id="_">Text</p>
186
+ </foreword>
187
+ <introduction id="_" obligation="informative">
188
+ <title>INTRODUCTION</title><clause id="_" inline-header="false" obligation="informative">
189
+ <title>Introduction Subsection</title>
222
190
  </clause>
223
- <clause id='_' inline-header='false' obligation='normative'>
224
- <title>Clause 4.2</title>
191
+ </introduction>
192
+ </preface>
193
+ <sections>
194
+ <clause id="_" obligation="normative" type="scope" inline-header='false'>
195
+ <title>Scope</title>
196
+ <p id="_">Text</p>
225
197
  </clause>
226
- </clause>
227
- </sections>
228
- <annex id='_' inline-header='false' obligation='normative'>
229
- <title>Annex</title>
230
- <clause id='_' inline-header='false' obligation='normative'>
231
- <title>Annex A.1</title>
232
- </clause>
233
- <appendix id='_' inline-header='false' obligation='normative'>
234
- <title>Appendx 1</title>
235
- </appendix>
236
- </annex>
237
- <bibliography>
238
- <references id='_' obligation='informative' normative="true">
239
- <title>Normative references</title>
240
- <p id="_">There are no normative references in this document.</p>
241
- </references>
242
- <clause id='_' obligation='informative'>
243
- <title>Bibliography</title>
244
- <references id='_' obligation='informative' normative="false">
245
- <title>Bibliography Subsection</title>
246
- </references>
247
- </clause>
248
- </bibliography>
249
- </iec-standard>
198
+ <terms id="_" obligation="normative">
199
+ <title>Terms and definitions</title>
200
+ <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
201
+ #{TERMS_BOILERPLATE}
202
+ <term id="term-Term1">
203
+ <preferred><expression><name>Term1</name></expression></preferred>
204
+ </term>
205
+ </terms>
206
+ <clause id='_' obligation='normative'>
207
+ <title>Terms, definitions, symbols and abbreviated terms</title>
208
+ <terms id='_' obligation='normative'>
209
+ <title>Normal Terms</title>
210
+ <term id='term-Term2'>
211
+ <preferred><expression><name>Term2</name></expression></preferred>
212
+ </term>
213
+ </terms>
214
+ <definitions id='_' obligation="normative">
215
+ <title>Symbols and abbreviated terms</title>
216
+ </definitions>
217
+ </clause>
218
+ <definitions id='_' obligation="normative">
219
+ <title>Symbols and abbreviated terms</title>
220
+ </definitions>
221
+ <clause id='_' inline-header='false' obligation='normative'>
222
+ <title>Clause 4</title>
223
+ <clause id='_' inline-header='false' obligation='normative'>
224
+ <title>Introduction</title>
225
+ </clause>
226
+ <clause id='_' inline-header='false' obligation='normative'>
227
+ <title>Clause 4.2</title>
228
+ </clause>
229
+ </clause>
230
+ </sections>
231
+ <annex id='_' inline-header='false' obligation='normative'>
232
+ <title>Annex</title>
233
+ <clause id='_' inline-header='false' obligation='normative'>
234
+ <title>Annex A.1</title>
235
+ </clause>
236
+ <appendix id='_' inline-header='false' obligation='normative'>
237
+ <title>Appendx 1</title>
238
+ </appendix>
239
+ </annex>
240
+ <bibliography>
241
+ <references id='_' obligation='informative' normative="true">
242
+ <title>Normative references</title>
243
+ <p id="_">There are no normative references in this document.</p>
244
+ </references>
245
+ <clause id='_' obligation='informative'>
246
+ <title>Bibliography</title>
247
+ <references id='_' obligation='informative' normative="false">
248
+ <title>Bibliography Subsection</title>
249
+ </references>
250
+ </clause>
251
+ </bibliography>
252
+ </iec-standard>
250
253
  OUTPUT
254
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
255
+ .to be_equivalent_to xmlpp(output)
251
256
  end
252
257
 
253
258
  it "processes section obligations" do
254
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
259
+ input = <<~INPUT
255
260
  #{ASCIIDOC_BLANK_HDR}
256
261
  [obligation=informative]
257
262
  == Clause 1
@@ -263,26 +268,29 @@ end
263
268
 
264
269
  [appendix,obligation=informative]
265
270
  == Annex
266
- INPUT
267
- #{@blank_hdr}
268
- <sections><clause id="_" inline-header="false" obligation="informative">
269
- <title>Clause 1</title>
270
- <clause id="_" inline-header="false" obligation="informative">
271
- <title>Clause 1a</title>
272
- </clause>
273
- </clause>
274
- <clause id="_" inline-header="false" obligation="normative">
275
- <title>Clause 2</title>
276
- </clause>
277
- </sections><annex id="_" inline-header="false" obligation="informative">
278
- <title>Annex</title>
279
- </annex>
280
- </iec-standard>
281
- OUTPUT
271
+ INPUT
272
+ output = <<~OUTPUT
273
+ #{@blank_hdr}
274
+ <sections><clause id="_" inline-header="false" obligation="informative">
275
+ <title>Clause 1</title>
276
+ <clause id="_" inline-header="false" obligation="informative">
277
+ <title>Clause 1a</title>
278
+ </clause>
279
+ </clause>
280
+ <clause id="_" inline-header="false" obligation="normative">
281
+ <title>Clause 2</title>
282
+ </clause>
283
+ </sections><annex id="_" inline-header="false" obligation="informative">
284
+ <title>Annex</title>
285
+ </annex>
286
+ </iec-standard>
287
+ OUTPUT
288
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
289
+ .to be_equivalent_to xmlpp(output)
282
290
  end
283
291
 
284
- it "processes inline headers" do
285
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
292
+ it "processes inline headers" do
293
+ input = <<~INPUT
286
294
  #{ASCIIDOC_BLANK_HDR}
287
295
  == Clause 1
288
296
 
@@ -294,42 +302,47 @@ end
294
302
 
295
303
  [%inline-header]
296
304
  === Clause Aa
297
- INPUT
298
- #{@blank_hdr}
299
- <sections><clause id="_" inline-header="false" obligation="normative">
300
- <title>Clause 1</title>
301
- <clause id="_" inline-header="true" obligation="normative">
302
- <title>Clause 1a</title>
303
- </clause>
304
- </clause>
305
- </sections><annex id="_" inline-header="false" obligation="normative">
306
- <title>Annex A</title>
307
- <clause id="_" inline-header="true" obligation="normative">
308
- <title>Clause Aa</title>
309
- </clause>
310
- </annex>
311
- </iec-standard>
312
- OUTPUT
313
- end
305
+ INPUT
306
+ output = <<~OUTPUT
307
+ #{@blank_hdr}
308
+ <sections><clause id="_" inline-header="false" obligation="normative">
309
+ <title>Clause 1</title>
310
+ <clause id="_" inline-header="true" obligation="normative">
311
+ <title>Clause 1a</title>
312
+ </clause>
313
+ </clause>
314
+ </sections><annex id="_" inline-header="false" obligation="normative">
315
+ <title>Annex A</title>
316
+ <clause id="_" inline-header="true" obligation="normative">
317
+ <title>Clause Aa</title>
318
+ </clause>
319
+ </annex>
320
+ </iec-standard>
321
+ OUTPUT
322
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
323
+ .to be_equivalent_to xmlpp(output)
324
+ end
314
325
 
315
326
  it "processes blank headers" do
316
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
327
+ input = <<~INPUT
317
328
  #{ASCIIDOC_BLANK_HDR}
318
329
  == Clause 1
319
330
 
320
331
  === {blank}
321
332
 
322
- INPUT
323
- #{@blank_hdr}
324
- <sections>
325
- <clause id="_" inline-header="false" obligation="normative">
326
- <title>Clause 1</title>
327
- <clause id="_" inline-header="false" obligation="normative">
328
- </clause>
329
- </clause>
330
- </sections>
331
- </iec-standard>
332
- OUTPUT
333
+ INPUT
334
+ output = <<~OUTPUT
335
+ #{@blank_hdr}
336
+ <sections>
337
+ <clause id="_" inline-header="false" obligation="normative">
338
+ <title>Clause 1</title>
339
+ <clause id="_" inline-header="false" obligation="normative">
340
+ </clause>
341
+ </clause>
342
+ </sections>
343
+ </iec-standard>
344
+ OUTPUT
345
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
346
+ .to be_equivalent_to xmlpp(output)
333
347
  end
334
-
335
348
  end
data/spec/spec_helper.rb CHANGED
@@ -37,6 +37,13 @@ def strip_guid(xml)
37
37
  end
38
38
 
39
39
  def xmlpp(xml)
40
+ c = HTMLEntities.new
41
+ xml &&= xml.split(/(&\S+?;)/).map do |n|
42
+ if /^&\S+?;$/.match?(n)
43
+ c.encode(c.decode(n), :hexadecimal)
44
+ else n
45
+ end
46
+ end.join
40
47
  s = ""
41
48
  f = REXML::Formatters::Pretty.new(2)
42
49
  f.compact = true
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: 2.0.7
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-04 00:00:00.000000000 Z
11
+ date: 2022-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-iso
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0
19
+ version: 2.1.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0
26
+ version: 2.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby-jing
29
29
  requirement: !ruby/object:Gem::Requirement