metanorma-iec 1.3.9 → 1.3.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Iec
3
- VERSION = "1.3.9".freeze
3
+ VERSION = "1.3.10".freeze
4
4
  end
5
5
  end
6
6
 
@@ -4,15 +4,16 @@ require "fileutils"
4
4
  RSpec.describe IsoDoc::Iec do
5
5
  FileUtils.rm_f "test.html"
6
6
  it "processes isodoc as ISO: HTML output" do
7
- IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", false)
8
- <iso-standard xmlns="http://riboseinc.com/isoxml">
9
- <preface><foreword>
10
- <note>
11
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
12
- </note>
13
- </foreword></preface>
14
- </iso-standard>
15
- INPUT
7
+ IsoDoc::Iec::HtmlConvert.new({})
8
+ .convert("test", <<~"INPUT", false)
9
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
10
+ <preface><foreword>
11
+ <note>
12
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
13
+ </note>
14
+ </foreword></preface>
15
+ </iso-standard>
16
+ INPUT
16
17
  html = File.read("test.html", encoding: "utf-8")
17
18
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
18
19
  expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Arial", sans-serif;]m)
@@ -20,16 +21,17 @@ RSpec.describe IsoDoc::Iec do
20
21
  end
21
22
 
22
23
  it "processes isodoc as ISO: Chinese HTML output" do
23
- FileUtils.rm_f "test.html"
24
- IsoDoc::Iec::HtmlConvert.new({script: "Hans"}).convert("test", <<~"INPUT", false)
25
- <iso-standard xmlns="http://riboseinc.com/isoxml">
26
- <preface><foreword>
27
- <note>
28
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
29
- </note>
30
- </foreword></preface>
31
- </iso-standard>
32
- INPUT
24
+ FileUtils.rm_f "test.html"
25
+ IsoDoc::Iec::HtmlConvert.new({ script: "Hans" })
26
+ .convert("test", <<~"INPUT", false)
27
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
28
+ <preface><foreword>
29
+ <note>
30
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
31
+ </note>
32
+ </foreword></preface>
33
+ </iso-standard>
34
+ INPUT
33
35
  html = File.read("test.html", encoding: "utf-8")
34
36
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
35
37
  expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Source Han Sans", serif;]m)
@@ -37,16 +39,19 @@ RSpec.describe IsoDoc::Iec do
37
39
  end
38
40
 
39
41
  it "processes isodoc as ISO: user nominated fonts" do
40
- FileUtils.rm_f "test.html"
41
- IsoDoc::Iec::HtmlConvert.new({bodyfont: "Zapf Chancery", headerfont: "Comic Sans", monospacefont: "Andale Mono"}).convert("test", <<~"INPUT", false)
42
- <iso-standard xmlns="http://riboseinc.com/isoxml">
43
- <preface><foreword>
44
- <note>
45
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
46
- </note>
47
- </foreword></preface>
48
- </iso-standard>
49
- INPUT
42
+ FileUtils.rm_f "test.html"
43
+ IsoDoc::Iec::HtmlConvert
44
+ .new({ bodyfont: "Zapf Chancery", headerfont: "Comic Sans",
45
+ monospacefont: "Andale Mono" })
46
+ .convert("test", <<~"INPUT", false)
47
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
48
+ <preface><foreword>
49
+ <note>
50
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
51
+ </note>
52
+ </foreword></preface>
53
+ </iso-standard>
54
+ INPUT
50
55
  html = File.read("test.html", encoding: "utf-8")
51
56
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: Andale Mono;]m)
52
57
  expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: Zapf Chancery;]m)
@@ -54,16 +59,17 @@ RSpec.describe IsoDoc::Iec do
54
59
  end
55
60
 
56
61
  it "processes isodoc as ISO: Word output" do
57
- FileUtils.rm_f "test.doc"
58
- IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", false)
59
- <iso-standard xmlns="http://riboseinc.com/isoxml">
60
- <preface><foreword>
61
- <note>
62
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
63
- </note>
64
- </foreword></preface>
65
- </iso-standard>
66
- INPUT
62
+ FileUtils.rm_f "test.doc"
63
+ IsoDoc::Iec::WordConvert.new({})
64
+ .convert("test", <<~"INPUT", false)
65
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
66
+ <preface><foreword>
67
+ <note>
68
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
69
+ </note>
70
+ </foreword></preface>
71
+ </iso-standard>
72
+ INPUT
67
73
  html = File.read("test.doc", encoding: "utf-8")
68
74
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
69
75
  expect(html).to match(%r[Quote[^{]+\{[^{]+font-family: "Arial", sans-serif;]m)
@@ -71,147 +77,135 @@ RSpec.describe IsoDoc::Iec do
71
77
  end
72
78
 
73
79
  it "processes examples" do
74
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
75
- <iso-standard xmlns="http://riboseinc.com/isoxml">
76
- <preface><foreword>
77
- <example id="samplecode">
78
- <name>EXAMPLE</name>
79
- <p>Hello</p>
80
- </example>
81
- </foreword></preface>
82
- </iso-standard>
80
+ input = <<~INPUT
81
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
82
+ <preface><foreword>
83
+ <example id="samplecode">
84
+ <name>EXAMPLE</name>
85
+ <p>Hello</p>
86
+ </example>
87
+ </foreword></preface>
88
+ </iso-standard>
83
89
  INPUT
84
- #{HTML_HDR}
85
- <div>
86
- <h1 class="ForewordTitle">FOREWORD</h1>
87
- <div class="boilerplate_legal"/>
88
- <div id="samplecode" class="example">
89
- <p><span class="example_label">EXAMPLE</span>&#160; Hello</p>
90
- </div>
91
- </div>
92
- #{IEC_TITLE1}
93
- </div>
94
- </body>
95
- </html>
90
+ html = <<~OUTPUT
91
+ #{HTML_HDR}
92
+ <div>
93
+ <h1 class="ForewordTitle">FOREWORD</h1>
94
+ <div class="boilerplate_legal"/>
95
+ <div id="samplecode" class="example">
96
+ <p><span class="example_label">EXAMPLE</span>&#160; Hello</p>
97
+ </div>
98
+ </div>
99
+ #{IEC_TITLE1}
100
+ </div>
101
+ </body>
102
+ </html>
96
103
  OUTPUT
97
- end
98
-
99
-
100
- it "processes sequences of examples" do
101
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
102
- <iso-standard xmlns="http://riboseinc.com/isoxml">
103
- <preface><foreword>
104
- <example id="samplecode">
105
- <name>EXAMPLE 1</name>
106
- <p>Hello</p>
107
- </example>
108
- <example id="samplecode2">
109
- <name>EXAMPLE 2</name>
110
- <p>Hello</p>
111
- </example>
112
- </foreword></preface>
113
- </iso-standard>
114
- INPUT
115
- #{HTML_HDR}
116
- <div>
117
- <h1 class="ForewordTitle">FOREWORD</h1>
118
- <div class="boilerplate_legal"/>
119
- <div id="samplecode" class="example">
120
- <p><span class="example_label">EXAMPLE 1</span>&#160; Hello</p>
121
- </div>
122
- <div id="samplecode2" class="example">
123
- <p><span class="example_label">EXAMPLE 2</span>&#160; Hello</p>
124
- </div>
125
- </div>
126
- #{IEC_TITLE1}
127
- </div>
128
- </body>
129
- </html>
104
+ doc = <<~OUTPUT
105
+ <body lang="EN-US" link="blue" vlink="#954F72">
106
+ <div class="WordSection2">
107
+ <p>
108
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
109
+ </p>
110
+ #{IEC_TITLE}
111
+ <div>
112
+ <h1 class="ForewordTitle">FOREWORD</h1>
113
+ <div class="boilerplate_legal"/>
114
+ <div id="samplecode" class="example">
115
+ <p><span class="example_label">EXAMPLE</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
116
+ </div>
117
+ </div>
118
+ <p>&#160;</p>
119
+ </div>
120
+ <p>
121
+ <br clear="all" class="section"/>
122
+ </p>
123
+ <div class="WordSection3">
124
+ #{IEC_TITLE1}
125
+ </div>
126
+ <br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
127
+ <div class="colophon"/>
128
+ </body>
130
129
  OUTPUT
130
+ expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
131
+ .convert("test", input, true)))
132
+ .to be_equivalent_to xmlpp(html)
133
+ expect(xmlpp(IsoDoc::Iec::WordConvert.new({})
134
+ .convert("test", input, true)
135
+ .sub(/^.*<body/m, "<body")
136
+ .sub(%r{</body>.*$}m, "</body>")))
137
+ .to be_equivalent_to xmlpp(doc)
131
138
  end
132
139
 
133
- it "processes examples (Word)" do
134
- expect(xmlpp(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body/m, "<body").sub(%r{</body>.*$}m, "</body>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
135
- <iso-standard xmlns="http://riboseinc.com/isoxml">
136
- <preface><foreword>
137
- <example id="samplecode">
138
- <name>EXAMPLE</name>
139
- <p>Hello</p>
140
- </example>
141
- </foreword></preface>
142
- </iso-standard>
140
+ it "processes sequences of examples" do
141
+ input = <<~INPUT
142
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
143
+ <preface><foreword>
144
+ <example id="samplecode">
145
+ <name>EXAMPLE 1</name>
146
+ <p>Hello</p>
147
+ </example>
148
+ <example id="samplecode2">
149
+ <name>EXAMPLE 2</name>
150
+ <p>Hello</p>
151
+ </example>
152
+ </foreword></preface>
153
+ </iso-standard>
143
154
  INPUT
144
- <body lang="EN-US" link="blue" vlink="#954F72">
145
- <div class="WordSection2">
146
- <p>
147
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
148
- </p>
149
- #{IEC_TITLE}
150
- <div>
151
- <h1 class="ForewordTitle">FOREWORD</h1>
152
- <div class="boilerplate_legal"/>
153
- <div id="samplecode" class="example">
154
- <p><span class="example_label">EXAMPLE</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
155
- </div>
156
- </div>
157
- <p>&#160;</p>
158
- </div>
159
- <p>
160
- <br clear="all" class="section"/>
161
- </p>
162
- <div class="WordSection3">
163
- #{IEC_TITLE1}
164
- </div>
165
- <br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
166
- <div class="colophon"/>
167
- </body>
155
+ html = <<~OUTPUT
156
+ #{HTML_HDR}
157
+ <div>
158
+ <h1 class="ForewordTitle">FOREWORD</h1>
159
+ <div class="boilerplate_legal"/>
160
+ <div id="samplecode" class="example">
161
+ <p><span class="example_label">EXAMPLE 1</span>&#160; Hello</p>
162
+ </div>
163
+ <div id="samplecode2" class="example">
164
+ <p><span class="example_label">EXAMPLE 2</span>&#160; Hello</p>
165
+ </div>
166
+ </div>
167
+ #{IEC_TITLE1}
168
+ </div>
169
+ </body>
170
+ </html>
168
171
  OUTPUT
169
- end
170
-
171
172
 
172
- it "processes sequences of examples (Word)" do
173
- expect(xmlpp(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body/m, "<body").sub(%r{</body>.*$}m, "</body>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
174
- <iso-standard xmlns="http://riboseinc.com/isoxml">
175
- <preface><foreword>
176
- <example id="samplecode">
177
- <name>EXAMPLE 1</name>
178
- <p>Hello</p>
179
- </example>
180
- <example id="samplecode2">
181
- <name>EXAMPLE 2</name>
182
- <p>Hello</p>
183
- </example>
184
- </foreword></preface>
185
- </iso-standard>
186
- INPUT
187
- <body lang="EN-US" link="blue" vlink="#954F72">
188
- <div class="WordSection2">
189
- <p>
190
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
191
- </p>
192
- #{IEC_TITLE}
193
- <div>
194
- <h1 class="ForewordTitle">FOREWORD</h1>
195
- <div class="boilerplate_legal"/>
196
- <div id="samplecode" class="example">
197
- <p><span class="example_label">EXAMPLE 1</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
198
- </div>
199
- <div id="samplecode2" class="example">
200
- <p><span class="example_label">EXAMPLE 2</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
201
- </div>
202
- </div>
203
- <p>&#160;</p>
204
- </div>
205
- <p>
206
- <br clear="all" class="section"/>
207
- </p>
208
- <div class="WordSection3">
209
- #{IEC_TITLE1}
210
- </div>
211
- <br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
212
- <div class="colophon"/>
213
- </body>
173
+ doc = <<~OUTPUT
174
+ <body lang="EN-US" link="blue" vlink="#954F72">
175
+ <div class="WordSection2">
176
+ <p>
177
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
178
+ </p>
179
+ #{IEC_TITLE}
180
+ <div>
181
+ <h1 class="ForewordTitle">FOREWORD</h1>
182
+ <div class="boilerplate_legal"/>
183
+ <div id="samplecode" class="example">
184
+ <p><span class="example_label">EXAMPLE 1</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
185
+ </div>
186
+ <div id="samplecode2" class="example">
187
+ <p><span class="example_label">EXAMPLE 2</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
188
+ </div>
189
+ </div>
190
+ <p>&#160;</p>
191
+ </div>
192
+ <p>
193
+ <br clear="all" class="section"/>
194
+ </p>
195
+ <div class="WordSection3">
196
+ #{IEC_TITLE1}
197
+ </div>
198
+ <br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
199
+ <div class="colophon"/>
200
+ </body>
214
201
  OUTPUT
202
+ expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
203
+ .convert("test", input, true)))
204
+ .to be_equivalent_to xmlpp(html)
205
+ expect(xmlpp(IsoDoc::Iec::WordConvert.new({})
206
+ .convert("test", input, true)
207
+ .sub(/^.*<body/m, "<body")
208
+ .sub(%r{</body>.*$}m, "</body>")))
209
+ .to be_equivalent_to xmlpp(doc)
215
210
  end
216
-
217
211
  end
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(x)
29
- Hash[x.sort].delete_if{ |k, v| v.nil? || v.respond_to?(:empty?) && v.empty? }
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(x)
33
- x.gsub(%r{ id="_[^"]+"}, ' id="_"').gsub(%r{ target="_[^"]+"}, ' target="_"')
34
+ def strip_guid(xml)
35
+ xml.gsub(%r{ id="_[^"]+"}, ' id="_"').gsub(%r{ target="_[^"]+"},
36
+ ' target="_"')
34
37
  end
35
38
 
36
- def xmlpp(x)
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(x),s)
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
- = Document title
48
- Author
49
- :docfile: test.adoc
50
- :nodoc:
51
- :novalid:
52
- :no-isobib:
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
- = Document title
58
- Author
59
- :docfile: test.adoc
60
- :nodoc:
61
- :novalid:
62
- :no-isobib-cache:
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
- = Document title
68
- Author
69
- :docfile: test.adoc
70
- :nodoc:
71
- :novalid:
72
- :flush-caches:
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
- = Document title
78
- Author
79
- :docfile: test.adoc
80
- :nodoc:
81
- :novalid:
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
- = Document title
87
- Author
88
- :docfile: test.adoc
89
- :nodoc:
90
- :novalid:
91
- :local-cache:
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
- = Document title
97
- Author
98
- :docfile: test.adoc
99
- :nodoc:
100
- :no-isobib:
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
- <p id="_">ISO and IEC maintain terminological databases for use in
106
- standardization at the following addresses:</p>
107
-
108
- <ul id="_">
109
- <li> <p id="_">IEC Electropedia: available at
110
- <link target="http://www.electropedia.org"/>
111
- </p> </li>
112
- <li> <p id="_">ISO Online browsing platform: available at
113
- <link target="http://www.iso.org/obp"/></p> </li>
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(File.join(File.dirname(__FILE__), "..", "lib", "asciidoctor", "iec", "iec_intro_en.xml"), encoding: "utf-8")
119
- conv = Asciidoctor::Iec::Converter.new(nil, backend: :iec, header_footer: true)
120
- conv.init(Asciidoctor::Document.new [])
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
- <contributor>
134
- <role type="author"/>
135
- <organization>
136
- <name>International Electrotechnical Commission</name>
137
- <abbreviation>IEC</abbreviation>
138
- </organization>
139
- </contributor>
140
- <contributor>
141
- <role type="publisher"/>
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
- </owner>
161
- </copyright>
162
- <ext>
163
- <doctype>article</doctype>
164
- <horizontal>false</horizontal>
165
- <editorialgroup>
166
- <technical-committee/>
167
- <subcommittee/>
168
- <workgroup/>
169
- </editorialgroup>
170
- <stagename>International standard</stagename>
171
- </ext>
172
- </bibdata>
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 + "</iec-standard>"))}
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">&#160;</p>
194
+ <p class="zzSTDTitle1">
195
+ <b/>
196
+ </p>
197
+ <p class="zzSTDTitle1">&#160;</p>
198
+ TITLE
199
+
200
+ IEC_TITLE1 = <<~TITLE.freeze
201
+ <p class="zzSTDTitle1">
202
+ <b/>
203
+ </p>
204
+ <p class="zzSTDTitle1">&#160;</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>&#160;</p>
213
+ </div>
214
+ <br/>
215
+ <div class="prefatory-section">
216
+ <p>&#160;</p>
217
+ </div>
218
+ <br/>
219
+ <div class="main-section">
220
+ <br/>
221
+ #{IEC_TITLE}
222
+ HDR
182
223
 
183
- IEC_TITLE = <<~END
184
- <p class="zzSTDTitle1">INTERNATIONAL ELECTROTECHNICAL COMMISSION</p>
185
- <p class="zzSTDTitle1">____________</p>
186
- <p class="zzSTDTitle1">&#160;</p>
187
- <p class="zzSTDTitle1">
188
- <b/>
189
- </p>
190
- <p class="zzSTDTitle1">&#160;</p>
191
- END
192
-
193
- IEC_TITLE1 = <<~END
194
- <p class="zzSTDTitle1">
195
- <b/>
196
- </p>
197
- <p class="zzSTDTitle1">&#160;</p>
198
- END
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>&#160;</p>
206
- </div>
207
- <br/>
208
- <div class="prefatory-section">
209
- <p>&#160;</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>&#160;</p>
225
- </div>
226
- <p><br clear="all" class="section"/></p>
227
- <div class="WordSection2">
228
- <p>&#160;</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>&#160;</p>
232
+ </div>
233
+ <p><br clear="all" class="section"/></p>
234
+ <div class="WordSection2">
235
+ <p>&#160;</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(:"[]").with("title") do
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, c, d|
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{[\/\s:-]}, "_").sub(%r{_+$}, "").downcase
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
-