metanorma-iso 1.5.9 → 1.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "1.5.9".freeze
3
+ VERSION = "1.5.10".freeze
4
4
  end
5
5
  end
@@ -189,6 +189,12 @@ RSpec.describe Asciidoctor::ISO do
189
189
  :copyright-holder: ISO,IETF
190
190
  :copyright-year: 2001
191
191
  :doctype: technical-report
192
+ :pub-address: 1 Infinity Loop + \
193
+ California
194
+ :pub-phone: 3333333
195
+ :pub-fax: 4444444
196
+ :pub-email: x@example.com
197
+ :pub-uri: http://www.example.com
192
198
  INPUT
193
199
  <?xml version="1.0" encoding="UTF-8"?>
194
200
  <iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="#{Metanorma::ISO::VERSION}">
@@ -280,6 +286,116 @@ RSpec.describe Asciidoctor::ISO do
280
286
  OUTPUT
281
287
  end
282
288
 
289
+ it "processes subdivisions" do
290
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true).sub(%r{<boilerplate>.*</boilerplate>}m, "")))).to be_equivalent_to xmlpp(<<~"OUTPUT")
291
+ = Document title
292
+ Author
293
+ :docfile: test.adoc
294
+ :nodoc:
295
+ :novalid:
296
+ :revdate: 2000-01
297
+ :published-date: 1000-01
298
+ :docnumber: 1000
299
+ :partnumber: 1-1
300
+ :tc-docnumber: 2000
301
+ :language: el
302
+ :script: Grek
303
+ :subdivision: Subdivision
304
+ :subdivision-abbr: SD
305
+ :doctype: This is a DocType
306
+ :pub-address: 1 Infinity Loop + \\
307
+ California
308
+ :pub-phone: 3333333
309
+ :pub-fax: 4444444
310
+ :pub-email: x@example.com
311
+ :pub-uri: http://www.example.com
312
+
313
+ INPUT
314
+ <iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="#{Metanorma::ISO::VERSION}">
315
+ <bibdata type='standard'>
316
+ <docidentifier type='ISO'>SD 1000-1-1</docidentifier>
317
+ <docidentifier type='iso-with-lang'>SD 1000-1-1(X)</docidentifier>
318
+ <docidentifier type='iso-reference'>SD 1000-1-1(X)</docidentifier>
319
+ <docidentifier type='iso-tc'>2000</docidentifier>
320
+ <docnumber>1000</docnumber>
321
+ <date type='published'>
322
+ <on>1000-01</on>
323
+ </date>
324
+ <contributor>
325
+ <role type='author'/>
326
+ <organization>
327
+ <name>International Organization for Standardization</name>
328
+ <subdivision>Subdivision</subdivision>
329
+ <abbreviation>SD</abbreviation>
330
+ <address>
331
+ <formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
332
+ </address>
333
+ <phone>3333333</phone>
334
+ <phone type='fax'>4444444</phone>
335
+ <email>x@example.com</email>
336
+ <uri>http://www.example.com</uri>
337
+ </organization>
338
+ </contributor>
339
+ <contributor>
340
+ <role type='publisher'/>
341
+ <organization>
342
+ <name>International Organization for Standardization</name>
343
+ <subdivision>Subdivision</subdivision>
344
+ <abbreviation>SD</abbreviation>
345
+ <address>
346
+ <formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
347
+ </address>
348
+ <phone>3333333</phone>
349
+ <phone type='fax'>4444444</phone>
350
+ <email>x@example.com</email>
351
+ <uri>http://www.example.com</uri>
352
+ </organization>
353
+ </contributor>
354
+ <version>
355
+ <revision-date>2000-01</revision-date>
356
+ </version>
357
+ <language>el</language>
358
+ <script>Grek</script>
359
+ <status>
360
+ <stage abbreviation='IS'>60</stage>
361
+ <substage>60</substage>
362
+ </status>
363
+ <copyright>
364
+ <from>2020</from>
365
+ <owner>
366
+ <organization>
367
+ <name>International Organization for Standardization</name>
368
+ <subdivision>Subdivision</subdivision>
369
+ <abbreviation>SD</abbreviation>
370
+ <address>
371
+ <formattedAddress>1 Infinity Loop <br/>California</formattedAddress>
372
+ </address>
373
+ <phone>3333333</phone>
374
+ <phone type='fax'>4444444</phone>
375
+ <email>x@example.com</email>
376
+ <uri>http://www.example.com</uri>
377
+ </organization>
378
+ </owner>
379
+ </copyright>
380
+ <ext>
381
+ <doctype>this-is-a-doctype</doctype>
382
+ <editorialgroup>
383
+ <technical-committee/>
384
+ <subcommittee/>
385
+ <workgroup/>
386
+ </editorialgroup>
387
+ <structuredidentifier>
388
+ <project-number part='1' subpart='1'>SD 1000</project-number>
389
+ </structuredidentifier>
390
+ <stagename>International standard</stagename>
391
+ </ext>
392
+ </bibdata>
393
+ <sections> </sections>
394
+ </iso-standard>
395
+
396
+ OUTPUT
397
+ end
398
+
283
399
  it "defaults substage, defines iteration on stage 50, gives stage 50 on technical specification" do
284
400
  expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true).sub(%r{<boilerplate>.*</boilerplate>}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
285
401
  = Document title
@@ -2,6 +2,26 @@ require "spec_helper"
2
2
  require "fileutils"
3
3
 
4
4
  RSpec.describe Asciidoctor::ISO do
5
+ context "when xref_error.adoc compilation" do
6
+ around do |example|
7
+ FileUtils.rm_f "spec/assets/xref_error.err"
8
+ example.run
9
+ Dir["spec/assets/xref_error*"].each do |file|
10
+ next if file.match?(/adoc$/)
11
+
12
+ FileUtils.rm_f(file)
13
+ end
14
+ end
15
+
16
+ it "generates error file" do
17
+ expect do
18
+ Metanorma::Compile
19
+ .new
20
+ .compile("spec/assets/xref_error.adoc", type: "iso")
21
+ end.to(change { File.exist?("spec/assets/xref_error.err") }
22
+ .from(false).to(true))
23
+ end
24
+ end
5
25
 
6
26
  it "Warns of missing scope" do
7
27
  FileUtils.rm_f "test.err"
@@ -332,7 +352,7 @@ it "warns that undated reference has locality" do
332
352
  FileUtils.rm_f "test.err"
333
353
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
334
354
  #{VALIDATING_BLANK_HDR}
335
-
355
+
336
356
  == Scope
337
357
  <<iso123,clause=1>>
338
358
 
@@ -417,7 +437,7 @@ it "warns that Scope contains subclauses" do
417
437
  #{VALIDATING_BLANK_HDR}
418
438
 
419
439
  == Scope
420
-
440
+
421
441
  === Scope subclause
422
442
  INPUT
423
443
  expect(File.read("test.err")).to include "Scope contains subclauses: should be succinct"
@@ -427,7 +447,7 @@ end
427
447
  it "warns that Table should have title" do
428
448
  FileUtils.rm_f "test.err"
429
449
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
430
- #{VALIDATING_BLANK_HDR}
450
+ #{VALIDATING_BLANK_HDR}
431
451
 
432
452
  |===
433
453
  |a |b |c
@@ -439,7 +459,7 @@ end
439
459
  it "gives Style warning if number not broken up in threes" do
440
460
  FileUtils.rm_f "test.err"
441
461
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
442
- #{VALIDATING_BLANK_HDR}
462
+ #{VALIDATING_BLANK_HDR}
443
463
 
444
464
  == Clause
445
465
  12121
@@ -450,7 +470,7 @@ end
450
470
  it "gives No style warning if number not broken up in threes is ISO reference" do
451
471
  FileUtils.rm_f "test.err"
452
472
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
453
- #{VALIDATING_BLANK_HDR}
473
+ #{VALIDATING_BLANK_HDR}
454
474
 
455
475
  == Clause
456
476
  ISO 12121
@@ -461,7 +481,7 @@ end
461
481
  it "Style warning if decimal point" do
462
482
  FileUtils.rm_f "test.err"
463
483
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
464
- #{VALIDATING_BLANK_HDR}
484
+ #{VALIDATING_BLANK_HDR}
465
485
 
466
486
  == Clause
467
487
  8.1
@@ -472,7 +492,7 @@ end
472
492
  it "Style warning if billion used" do
473
493
  FileUtils.rm_f "test.err"
474
494
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
475
- #{VALIDATING_BLANK_HDR}
495
+ #{VALIDATING_BLANK_HDR}
476
496
 
477
497
  == Clause
478
498
  "Billions" are a term of art.
@@ -483,7 +503,7 @@ end
483
503
  it "Style warning if no space before percent sign" do
484
504
  FileUtils.rm_f "test.err"
485
505
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
486
- #{VALIDATING_BLANK_HDR}
506
+ #{VALIDATING_BLANK_HDR}
487
507
 
488
508
  == Clause
489
509
  95%
@@ -572,7 +592,7 @@ end
572
592
  # it "Style warning if foreword contains subclauses" do
573
593
  # expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(%r{non-standard unit}).to_stderr
574
594
  # #{VALIDATING_BLANK_HDR}
575
- #
595
+ #
576
596
  # INPUT
577
597
  # end
578
598
 
@@ -644,7 +664,7 @@ it "Warning if introduction not followed by scope" do
644
664
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
645
665
  #{VALIDATING_BLANK_HDR}
646
666
 
647
- .Foreword
667
+ .Foreword
648
668
  Foreword
649
669
 
650
670
  == Introduction
@@ -661,7 +681,7 @@ it "Warning if normative references not followed by terms and definitions" do
661
681
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
662
682
  #{VALIDATING_BLANK_HDR}
663
683
 
664
- .Foreword
684
+ .Foreword
665
685
  Foreword
666
686
 
667
687
  == Scope
@@ -681,7 +701,7 @@ it "Warning if there are no clauses in the document" do
681
701
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
682
702
  #{VALIDATING_BLANK_HDR}
683
703
 
684
- .Foreword
704
+ .Foreword
685
705
  Foreword
686
706
 
687
707
  == Scope
@@ -1089,7 +1109,7 @@ it "Warning if term definition starts with article" do
1089
1109
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
1090
1110
  #{VALIDATING_BLANK_HDR}
1091
1111
  == Terms and Definitions
1092
-
1112
+
1093
1113
  === Term
1094
1114
 
1095
1115
  The definition of a term is a part of the specialized vocabulary of a particular field
@@ -1102,7 +1122,7 @@ it "Warning if term definition ends with period" do
1102
1122
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
1103
1123
  #{VALIDATING_BLANK_HDR}
1104
1124
  == Terms and Definitions
1105
-
1125
+
1106
1126
  === Term
1107
1127
 
1108
1128
  Part of the specialized vocabulary of a particular field.
@@ -1202,7 +1222,7 @@ it "Warn if an undated reference has no associated footnote" do
1202
1222
  FileUtils.rm_f "test.err"
1203
1223
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
1204
1224
  #{VALIDATING_BLANK_HDR}
1205
-
1225
+
1206
1226
  [bibliography]
1207
1227
  == Bibliography
1208
1228
  * [[[ISO8,ISO 8:--]]], _Title_
@@ -0,0 +1,7 @@
1
+ = X
2
+ A
3
+
4
+ == Clause
5
+
6
+ <<a,b>>
7
+
@@ -642,7 +642,7 @@ OUTPUT
642
642
  arr = c.convert_init(<<~"INPUT", "test", false)
643
643
  <iso-standard xmlns="http://riboseinc.com/isoxml">
644
644
  INPUT
645
- expect(Hash[c.info(Nokogiri::XML(<<~"INPUT"), nil).sort]).to be_equivalent_to <<~"OUTPUT"
645
+ expect(metadata(c.info(Nokogiri::XML(<<~"INPUT"), nil))).to be_equivalent_to <<~"OUTPUT"
646
646
  <iso-standard xmlns='https://www.metanorma.org/ns/iso'>
647
647
  <bibdata type='standard'>
648
648
  <title language='en' format='text/plain' type='main'>Introduction — Main Title — Title — Title Part  — Mass fraction of
@@ -735,8 +735,6 @@ OUTPUT
735
735
  </iso-standard>
736
736
  INPUT
737
737
  {:agency=>"ISO",
738
- :authors=>[],
739
- :authors_affiliations=>{},
740
738
  :createddate=>"2016-05-01",
741
739
  :docnumber=>"ISO/PreNWIP3 17301-1:2016/Amd.1",
742
740
  :docnumber_lang=>"ISO/PreNWIP3 17301-1:2016/Amd.1(E)",
@@ -765,9 +763,6 @@ INPUT
765
763
  :edition=>"2",
766
764
  :editorialgroup=>["A 1", "B 2", "C 3"],
767
765
  :ics=>"1, 2, 3",
768
- :keywords=>[],
769
- :obsoletes=>nil,
770
- :obsoletes_part=>nil,
771
766
  :publisher=>"International Organization for Standardization",
772
767
  :revdate=>"2000-01-01",
773
768
  :revdate_monthyear=>"January 2000",
@@ -778,7 +773,6 @@ INPUT
778
773
  :stageabbr=>"NWIP",
779
774
  :statusabbr=>"PreNWIP3",
780
775
  :tc=>"A 1",
781
- :tc_docnumber=>[],
782
776
  :unpublished=>true,
783
777
  :wg=>"C 3"}
784
778
  OUTPUT
@@ -7,7 +7,7 @@ RSpec.describe IsoDoc::Iso::Metadata do
7
7
  arr = c.convert_init(<<~"INPUT", "test", false)
8
8
  <iso-standard xmlns="http://riboseinc.com/isoxml">
9
9
  INPUT
10
- expect(Hash[c.info(Nokogiri::XML(<<~"INPUT"), nil).sort]).to be_equivalent_to <<~"OUTPUT"
10
+ expect(metadata(c.info(Nokogiri::XML(<<~"INPUT"), nil))).to be_equivalent_to <<~"OUTPUT"
11
11
  <iso-standard xmlns="http://riboseinc.com/isoxml">
12
12
  <bibdata type="standard">
13
13
  <title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
@@ -81,8 +81,6 @@ INPUT
81
81
  {:accesseddate=>"2012",
82
82
  :activateddate=>"2013",
83
83
  :agency=>"ISO",
84
- :authors=>[],
85
- :authors_affiliations=>{},
86
84
  :createddate=>"2010&ndash;2011",
87
85
  :docnumber=>"ISO/PreCD3 17301-1",
88
86
  :docnumber_lang=>"ISO/PreCD3 17301-1 (E)",
@@ -104,11 +102,8 @@ INPUT
104
102
  :draftinfo=>" (draft 0.4, 2016-05-01)",
105
103
  :edition=>"2",
106
104
  :editorialgroup=>["TC 34", "SC 4", "WG 3"],
107
- :ics=>nil,
108
105
  :keywords=>["kw2", "kw1"],
109
106
  :obsoleteddate=>"2014",
110
- :obsoletes=>nil,
111
- :obsoletes_part=>nil,
112
107
  :publisheddate=>"2011",
113
108
  :publisher=>"International Organization for Standardization",
114
109
  :revdate=>"2016-05-01",
@@ -131,7 +126,7 @@ OUTPUT
131
126
  arr = c.convert_init(<<~"INPUT", "test", false)
132
127
  <iso-standard xmlns="http://riboseinc.com/isoxml">
133
128
  INPUT
134
- expect(Hash[c.info(Nokogiri::XML(<<~"INPUT"), nil).sort]).to be_equivalent_to <<~"OUTPUT"
129
+ expect(metadata(c.info(Nokogiri::XML(<<~"INPUT"), nil))).to be_equivalent_to <<~"OUTPUT"
135
130
  <iso-standard xmlns="http://riboseinc.com/isoxml">
136
131
  <bibdata type="standard">
137
132
  <title>
@@ -204,12 +199,9 @@ OUTPUT
204
199
  </iso-standard>
205
200
  INPUT
206
201
  {:agency=>"ISO/IEC",
207
- :authors=>[],
208
- :authors_affiliations=>{},
209
202
  :docnumber=>"ISO/IEC/CD 17301-1-3",
210
203
  :docnumber_lang=>"ISO/IEC/CD 17301-1-3 (E)",
211
204
  :docnumber_reference=>"ISO/IEC/CD 17301-1-3 (E)",
212
- :docnumeric=>nil,
213
205
  :docsubtitle=>"C&#xe9;r&#xe9;ales et l&#xe9;gumineuses&nbsp;&mdash; Sp&#xe9;cification et m&#xe9;thodes d&#x27;essai&nbsp;&mdash; Partie&nbsp;1&ndash;3: Riz",
214
206
  :docsubtitleintro=>"C&#xe9;r&#xe9;ales et l&#xe9;gumineuses",
215
207
  :docsubtitlemain=>"Sp&#xe9;cification et m&#xe9;thodes d&#x27;essai",
@@ -222,17 +214,11 @@ INPUT
222
214
  :doctitlepartlabel=>"Part&nbsp;1&ndash;3",
223
215
  :doctype=>"International Standard",
224
216
  :docyear=>"2016",
225
- :draft=>nil,
226
- :draftinfo=>"",
227
- :edition=>nil,
228
217
  :editorialgroup=>["ABC 34", "DEF 4", "GHI 3"],
229
218
  :ics=>"1.2.3, 1.2.3",
230
- :keywords=>[],
231
219
  :obsoletes=>"IEC 8121",
232
220
  :obsoletes_part=>"3.1",
233
221
  :publisher=>"International Organization for Standardization and International Electrotechnical Commission",
234
- :revdate=>nil,
235
- :revdate_monthyear=>nil,
236
222
  :sc=>"DEF 4",
237
223
  :secretariat=>"XXXX",
238
224
  :stage=>"60",
@@ -29,6 +29,10 @@ def strip_guid(x)
29
29
  x.gsub(%r{ id="_[^"]+"}, ' id="_"').gsub(%r{ target="_[^"]+"}, ' target="_"')
30
30
  end
31
31
 
32
+ def metadata(x)
33
+ Hash[x.sort].delete_if{ |k, v| v.nil? || v.respond_to?(:empty?) && v.empty? }
34
+ end
35
+
32
36
  def xmlpp(x)
33
37
  s = ""
34
38
  f = REXML::Formatters::Pretty.new(2)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.9
4
+ version: 1.5.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-26 00:00:00.000000000 Z
11
+ date: 2020-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-jing
@@ -364,6 +364,7 @@ files:
364
364
  - spec/assets/word.css
365
365
  - spec/assets/wordcover.html
366
366
  - spec/assets/wordintro.html
367
+ - spec/assets/xref_error.adoc
367
368
  - spec/examples/103_01_02.html
368
369
  - spec/examples/english.yaml
369
370
  - spec/examples/iso_123_.xml