metanorma-iso 1.7.1 → 1.8.1
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 +11 -41
- data/.gitignore +2 -0
- data/.rubocop.yml +6 -2
- data/lib/asciidoctor/iso/base.rb +18 -16
- data/lib/asciidoctor/iso/biblio.rng +4 -6
- data/lib/asciidoctor/iso/cleanup.rb +28 -24
- data/lib/asciidoctor/iso/front.rb +26 -16
- data/lib/asciidoctor/iso/front_id.rb +30 -25
- data/lib/asciidoctor/iso/isodoc.rng +172 -3
- data/lib/asciidoctor/iso/isostandard-amd.rng +3 -0
- data/lib/asciidoctor/iso/isostandard.rng +17 -97
- data/lib/asciidoctor/iso/validate.rb +22 -109
- data/lib/asciidoctor/iso/validate_image.rb +97 -0
- data/lib/asciidoctor/iso/validate_requirements.rb +26 -20
- data/lib/asciidoctor/iso/validate_section.rb +39 -20
- data/lib/asciidoctor/iso/validate_style.rb +36 -24
- data/lib/asciidoctor/iso/validate_title.rb +23 -17
- data/lib/isodoc/iso/base_convert.rb +19 -2
- data/lib/isodoc/iso/html/style-human.css +7 -0
- data/lib/isodoc/iso/html/style-iso.css +7 -0
- data/lib/isodoc/iso/html_convert.rb +0 -1
- data/lib/isodoc/iso/i18n-en.yaml +4 -0
- data/lib/isodoc/iso/i18n-fr.yaml +4 -0
- data/lib/isodoc/iso/i18n-zh-Hans.yaml +4 -0
- data/lib/isodoc/iso/index.rb +140 -0
- data/lib/isodoc/iso/iso.amendment.xsl +1092 -208
- data/lib/isodoc/iso/iso.international-standard.xsl +1092 -208
- data/lib/isodoc/iso/presentation_xml_convert.rb +45 -37
- data/lib/isodoc/iso/word_convert.rb +0 -1
- data/lib/isodoc/iso/xref.rb +15 -7
- data/lib/metanorma/iso/processor.rb +1 -0
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +8 -8
- data/spec/asciidoctor/amd_spec.rb +696 -0
- data/spec/asciidoctor/base_spec.rb +733 -0
- data/spec/asciidoctor/blocks_spec.rb +527 -0
- data/spec/asciidoctor/cleanup_spec.rb +1134 -0
- data/spec/asciidoctor/inline_spec.rb +195 -0
- data/spec/asciidoctor/lists_spec.rb +197 -0
- data/spec/asciidoctor/refs_spec.rb +375 -0
- data/spec/asciidoctor/section_spec.rb +393 -0
- data/spec/asciidoctor/table_spec.rb +329 -0
- data/spec/asciidoctor/validate_spec.rb +1627 -0
- data/spec/isodoc/amd_spec.rb +967 -946
- data/spec/isodoc/blocks_spec.rb +530 -507
- data/spec/isodoc/i18n_spec.rb +953 -911
- data/spec/isodoc/inline_spec.rb +355 -293
- data/spec/isodoc/iso_spec.rb +338 -314
- data/spec/isodoc/metadata_spec.rb +392 -382
- data/spec/isodoc/postproc_spec.rb +836 -657
- data/spec/isodoc/ref_spec.rb +374 -331
- data/spec/isodoc/section_spec.rb +821 -519
- data/spec/isodoc/table_spec.rb +472 -411
- data/spec/isodoc/terms_spec.rb +209 -185
- data/spec/isodoc/xref_spec.rb +1370 -1236
- data/spec/metanorma/processor_spec.rb +28 -26
- data/spec/spec_helper.rb +178 -193
- metadata +65 -66
- data/.rubocop.ribose.yml +0 -66
- data/lib/isodoc/iso/html/scripts.html +0 -178
- data/spec/asciidoctor-iso/amd_spec.rb +0 -694
- data/spec/asciidoctor-iso/base_spec.rb +0 -713
- data/spec/asciidoctor-iso/blocks_spec.rb +0 -482
- data/spec/asciidoctor-iso/cleanup_spec.rb +0 -1025
- data/spec/asciidoctor-iso/inline_spec.rb +0 -170
- data/spec/asciidoctor-iso/lists_spec.rb +0 -190
- data/spec/asciidoctor-iso/refs_spec.rb +0 -317
- data/spec/asciidoctor-iso/section_spec.rb +0 -362
- data/spec/asciidoctor-iso/table_spec.rb +0 -313
- data/spec/asciidoctor-iso/validate_spec.rb +0 -1621
- data/spec/assets/xref_error.adoc +0 -7
@@ -2,9 +2,8 @@ require "spec_helper"
|
|
2
2
|
require "metanorma"
|
3
3
|
require "fileutils"
|
4
4
|
|
5
|
-
#RSpec.describe Asciidoctor::Gb do
|
5
|
+
# RSpec.describe Asciidoctor::Gb do
|
6
6
|
RSpec.describe Metanorma::Iso::Processor do
|
7
|
-
|
8
7
|
registry = Metanorma::Registry.instance
|
9
8
|
registry.register(Metanorma::Iso::Processor)
|
10
9
|
processor = registry.find_processor(:iso)
|
@@ -15,7 +14,7 @@ RSpec.describe Metanorma::Iso::Processor do
|
|
15
14
|
|
16
15
|
it "registers output formats against metanorma" do
|
17
16
|
expect(processor.output_formats.sort.to_s).to be_equivalent_to <<~"OUTPUT"
|
18
|
-
|
17
|
+
[[:doc, "doc"], [:html, "html"], [:html_alt, "alt.html"], [:isosts, "iso.sts.xml"], [:pdf, "pdf"], [:presentation, "presentation.xml"], [:rxl, "rxl"], [:sts, "sts.xml"], [:xml, "xml"]]
|
19
18
|
OUTPUT
|
20
19
|
end
|
21
20
|
|
@@ -25,37 +24,40 @@ RSpec.describe Metanorma::Iso::Processor do
|
|
25
24
|
|
26
25
|
it "generates IsoDoc XML from a blank document" do
|
27
26
|
expect(xmlpp(processor.input_to_isodoc(<<~"INPUT", nil))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
28
|
-
|
27
|
+
#{ASCIIDOC_BLANK_HDR}
|
29
28
|
INPUT
|
30
|
-
|
31
|
-
<sections/>
|
32
|
-
</iso-standard>
|
29
|
+
#{BLANK_HDR}
|
30
|
+
<sections/>
|
31
|
+
</iso-standard>
|
33
32
|
OUTPUT
|
34
33
|
end
|
35
34
|
|
36
35
|
it "generates HTML from IsoDoc XML" do
|
37
36
|
FileUtils.rm_f "test.xml"
|
38
37
|
processor.output(<<~"INPUT", "test.xml", "test.html", :html)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
39
|
+
<sections>
|
40
|
+
<terms id="H" obligation="normative"><title>1  Terms, Definitions, Symbols and Abbreviated Terms</title>
|
41
|
+
<term id="J">
|
42
|
+
<name>1.1</name>
|
43
|
+
<preferred>Term2</preferred>
|
44
|
+
</term>
|
45
|
+
</terms>
|
47
46
|
</sections>
|
48
|
-
|
47
|
+
</iso-standard>
|
49
48
|
INPUT
|
50
|
-
expect(xmlpp(File.read("test.html", encoding: "utf-8")
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
49
|
+
expect(xmlpp(File.read("test.html", encoding: "utf-8")
|
50
|
+
.gsub(%r{^.*<main}m, "<main")
|
51
|
+
.gsub(%r{</main>.*}m, "</main>")))
|
52
|
+
.to be_equivalent_to xmlpp(<<~"OUTPUT")
|
53
|
+
<main class="main-section">
|
54
|
+
<button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
55
|
+
<p class="zzSTDTitle1"></p>
|
56
|
+
<div id="H"><h1 id="toc0">1  Terms, Definitions, Symbols and Abbreviated Terms</h1>
|
57
|
+
<h2 class="TermNum" id="J">1.1</h2>
|
58
|
+
<p class="Terms" style="text-align:left;">Term2</p>
|
59
|
+
</div>
|
60
|
+
</main>
|
61
|
+
OUTPUT
|
59
62
|
end
|
60
|
-
|
61
63
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -23,250 +23,237 @@ RSpec.configure do |config|
|
|
23
23
|
config.expect_with :rspec do |c|
|
24
24
|
c.syntax = :expect
|
25
25
|
end
|
26
|
+
|
27
|
+
=begin
|
28
|
+
config.around do |example|
|
29
|
+
Dir.mktmpdir("rspec-") do |dir|
|
30
|
+
tmp_assets = File.join(dir, "spec/assets/")
|
31
|
+
FileUtils.mkdir_p tmp_assets
|
32
|
+
FileUtils.cp_r Dir.glob("spec/assets/*"), tmp_assets
|
33
|
+
Dir.chdir(dir) { example.run }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
=end
|
26
37
|
end
|
27
38
|
|
28
|
-
def strip_guid(
|
29
|
-
|
39
|
+
def strip_guid(xml)
|
40
|
+
xml.gsub(%r{ id="_[^"]+"}, ' id="_"').gsub(%r{ target="_[^"]+"}, ' target="_"')
|
30
41
|
end
|
31
42
|
|
32
|
-
def metadata(
|
33
|
-
Hash[
|
43
|
+
def metadata(hash)
|
44
|
+
Hash[hash.sort].delete_if { |_, v| v.nil? || v.respond_to?(:empty?) && v.empty? }
|
34
45
|
end
|
35
46
|
|
36
|
-
def xmlpp(
|
47
|
+
def xmlpp(xml)
|
37
48
|
s = ""
|
38
49
|
f = REXML::Formatters::Pretty.new(2)
|
39
50
|
f.compact = true
|
40
|
-
f.write(REXML::Document.new(
|
51
|
+
f.write(REXML::Document.new(xml), s)
|
41
52
|
s
|
42
53
|
end
|
43
54
|
|
44
|
-
ASCIIDOC_BLANK_HDR = <<~"HDR"
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
55
|
+
ASCIIDOC_BLANK_HDR = <<~"HDR".freeze
|
56
|
+
= Document title
|
57
|
+
Author
|
58
|
+
:docfile: test.adoc
|
59
|
+
:nodoc:
|
60
|
+
:novalid:
|
61
|
+
:no-isobib:
|
51
62
|
|
52
63
|
HDR
|
53
64
|
|
54
|
-
AMD_BLANK_HDR = <<~"HDR"
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
65
|
+
AMD_BLANK_HDR = <<~"HDR".freeze
|
66
|
+
= Document title
|
67
|
+
Author
|
68
|
+
:docfile: test.adoc
|
69
|
+
:nodoc:
|
70
|
+
:novalid:
|
71
|
+
:no-isobib:
|
72
|
+
:doctype: amendment
|
62
73
|
|
63
74
|
HDR
|
64
75
|
|
65
|
-
ISOBIB_BLANK_HDR = <<~"HDR"
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
76
|
+
ISOBIB_BLANK_HDR = <<~"HDR".freeze
|
77
|
+
= Document title
|
78
|
+
Author
|
79
|
+
:docfile: test.adoc
|
80
|
+
:nodoc:
|
81
|
+
:novalid:
|
82
|
+
:no-isobib-cache:
|
72
83
|
|
73
84
|
HDR
|
74
85
|
|
75
|
-
FLUSH_CACHE_ISOBIB_BLANK_HDR = <<~"HDR"
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
86
|
+
FLUSH_CACHE_ISOBIB_BLANK_HDR = <<~"HDR".freeze
|
87
|
+
= Document title
|
88
|
+
Author
|
89
|
+
:docfile: test.adoc
|
90
|
+
:nodoc:
|
91
|
+
:novalid:
|
92
|
+
:flush-caches:
|
82
93
|
|
83
94
|
HDR
|
84
95
|
|
85
|
-
CACHED_ISOBIB_BLANK_HDR = <<~"HDR"
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
96
|
+
CACHED_ISOBIB_BLANK_HDR = <<~"HDR".freeze
|
97
|
+
= Document title
|
98
|
+
Author
|
99
|
+
:docfile: test.adoc
|
100
|
+
:nodoc:
|
101
|
+
:novalid:
|
91
102
|
|
92
103
|
HDR
|
93
104
|
|
94
|
-
LOCAL_CACHED_ISOBIB_BLANK_HDR = <<~"HDR"
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
105
|
+
LOCAL_CACHED_ISOBIB_BLANK_HDR = <<~"HDR".freeze
|
106
|
+
= Document title
|
107
|
+
Author
|
108
|
+
:docfile: test.adoc
|
109
|
+
:nodoc:
|
110
|
+
:novalid:
|
111
|
+
:local-cache:
|
101
112
|
|
102
113
|
HDR
|
103
114
|
|
104
|
-
VALIDATING_BLANK_HDR = <<~"HDR"
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
115
|
+
VALIDATING_BLANK_HDR = <<~"HDR".freeze
|
116
|
+
= Document title
|
117
|
+
Author
|
118
|
+
:docfile: test.adoc
|
119
|
+
:nodoc:
|
120
|
+
:no-isobib:
|
111
121
|
HDR
|
112
122
|
|
123
|
+
ASCIIDOCTOR_ISO_DIR = Pathname.new(File.dirname(__FILE__)) / "../lib/asciidoctor/iso"
|
124
|
+
|
113
125
|
BOILERPLATE =
|
114
126
|
HTMLEntities.new.decode(
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
)
|
127
|
+
File.read(ASCIIDOCTOR_ISO_DIR / "boilerplate.xml", encoding: "utf-8")
|
128
|
+
.gsub(/\{\{ agency \}\}/, "ISO").gsub(/\{\{ docyear \}\}/, Date.today.year.to_s)
|
129
|
+
.gsub(/\{% if unpublished %\}.*\{% endif %\}/m, "")
|
130
|
+
.gsub(/(?<=\p{Alnum})'(?=\p{Alpha})/, "’")
|
131
|
+
)
|
120
132
|
|
121
133
|
BOILERPLATE_FR =
|
122
134
|
HTMLEntities.new.decode(
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
)
|
128
|
-
|
129
|
-
BLANK_HDR1 = <<~"HDR"
|
130
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
131
|
-
<iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="#{Metanorma::ISO::VERSION}">
|
132
|
-
<bibdata type="standard">
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
</bibdata>
|
135
|
+
File.read(ASCIIDOCTOR_ISO_DIR / "boilerplate-fr.xml", encoding: "utf-8")
|
136
|
+
.gsub(/\{\{ agency \}\}/, "ISO").gsub(/\{\{ docyear \}\}/, Date.today.year.to_s)
|
137
|
+
.gsub(/\{% if unpublished %\}.*\{% endif %\}/m, "")
|
138
|
+
.gsub(/(?<=\p{Alnum})'(?=\p{Alpha})/, "’")
|
139
|
+
)
|
140
|
+
|
141
|
+
BLANK_HDR1 = <<~"HDR".freeze
|
142
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
143
|
+
<iso-standard xmlns="https://www.metanorma.org/ns/iso" type="semantic" version="#{Metanorma::ISO::VERSION}">
|
144
|
+
<bibdata type="standard">
|
145
|
+
<contributor>
|
146
|
+
<role type="author"/>
|
147
|
+
<organization>
|
148
|
+
<name>International Organization for Standardization</name>
|
149
|
+
<abbreviation>ISO</abbreviation>
|
150
|
+
</organization>
|
151
|
+
</contributor>
|
152
|
+
<contributor>
|
153
|
+
<role type="publisher"/>
|
154
|
+
<organization>
|
155
|
+
<name>International Organization for Standardization</name>
|
156
|
+
<abbreviation>ISO</abbreviation>
|
157
|
+
</organization>
|
158
|
+
</contributor>
|
159
|
+
<language>en</language>
|
160
|
+
<script>Latn</script>
|
161
|
+
<status>
|
162
|
+
<stage abbreviation="IS">60</stage>
|
163
|
+
<substage>60</substage>
|
164
|
+
</status>
|
165
|
+
<copyright>
|
166
|
+
<from>#{Time.new.year}</from>
|
167
|
+
<owner>
|
168
|
+
<organization>
|
169
|
+
<name>International Organization for Standardization</name>
|
170
|
+
<abbreviation>ISO</abbreviation>
|
171
|
+
</organization>
|
172
|
+
</owner>
|
173
|
+
</copyright>
|
174
|
+
<ext>
|
175
|
+
<doctype>article</doctype>
|
176
|
+
<editorialgroup>
|
177
|
+
<technical-committee/>
|
178
|
+
<subcommittee/>
|
179
|
+
<workgroup/>
|
180
|
+
</editorialgroup>
|
181
|
+
<stagename>International standard</stagename>
|
182
|
+
</ext>
|
183
|
+
</bibdata>
|
172
184
|
HDR
|
173
185
|
|
174
|
-
BLANK_HDR = <<~"HDR"
|
175
|
-
#{BLANK_HDR1}
|
176
|
-
#{BOILERPLATE}
|
186
|
+
BLANK_HDR = <<~"HDR".freeze
|
187
|
+
#{BLANK_HDR1}
|
188
|
+
#{BOILERPLATE}
|
177
189
|
HDR
|
178
190
|
|
179
|
-
BLANK_HDR_FR = <<~"HDR"
|
180
|
-
#{BLANK_HDR1.sub(%r{<language>en</language>},
|
181
|
-
#{BOILERPLATE_FR}
|
191
|
+
BLANK_HDR_FR = <<~"HDR".freeze
|
192
|
+
#{BLANK_HDR1.sub(%r{<language>en</language>}, '<language>fr</language>')}
|
193
|
+
#{BOILERPLATE_FR}
|
182
194
|
HDR
|
183
195
|
|
184
|
-
TERM_BOILERPLATE = <<~
|
196
|
+
TERM_BOILERPLATE = <<~TERM.freeze
|
185
197
|
<p id="_">For the purposes of this document,
|
186
198
|
the following terms and definitions apply.</p>
|
187
|
-
<p id="_">ISO and IEC maintain terminological databases for use in
|
188
|
-
standardization at the following addresses:</p>
|
189
|
-
|
190
|
-
<ul id="_">
|
191
|
-
<li>
|
192
|
-
|
193
|
-
<
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
</head>
|
218
|
-
<body lang="EN-US" link="blue" vlink="#954F72">
|
219
|
-
<div class="WordSection1">
|
220
|
-
<p> </p>
|
221
|
-
</div>
|
222
|
-
<p><br clear="all" class="section"/></p>
|
223
|
-
<div class="WordSection2">
|
224
|
-
<p> </p>
|
225
|
-
</div>
|
226
|
-
<p><br clear="all" class="section"/></p>
|
227
|
-
<div class="WordSection3">
|
228
|
-
END
|
229
|
-
|
230
|
-
|
231
|
-
def stub_fetch_ref(**opts)
|
232
|
-
xml = ""
|
233
|
-
|
234
|
-
hit = double("hit")
|
235
|
-
expect(hit).to receive(:"[]").with("title") do
|
236
|
-
Nokogiri::XML(xml).at("//docidentifier").content
|
237
|
-
end.at_least(:once)
|
238
|
-
|
239
|
-
hit_instance = double("hit_instance")
|
240
|
-
expect(hit_instance).to receive(:hit).and_return(hit).at_least(:once)
|
241
|
-
expect(hit_instance).to receive(:to_xml) do |builder, opt|
|
242
|
-
expect(builder).to be_instance_of Nokogiri::XML::Builder
|
243
|
-
expect(opt).to eq opts
|
244
|
-
builder << xml
|
245
|
-
end.at_least :once
|
246
|
-
|
247
|
-
hit_page = double("hit_page")
|
248
|
-
expect(hit_page).to receive(:first).and_return(hit_instance).at_least :once
|
199
|
+
<p id="_">ISO and IEC maintain terminological databases for use in
|
200
|
+
standardization at the following addresses:</p>
|
201
|
+
|
202
|
+
<ul id="_">
|
203
|
+
<li>
|
204
|
+
<p id="_">ISO Online browsing platform: available at
|
205
|
+
<link target="http://www.iso.org/obp"/></p>
|
206
|
+
</li>
|
207
|
+
<li>
|
208
|
+
<p id="_">IEC Electropedia: available at
|
209
|
+
<link target="http://www.electropedia.org"/>
|
210
|
+
</p>
|
211
|
+
</li>
|
212
|
+
</ul>
|
213
|
+
TERM
|
214
|
+
|
215
|
+
HTML_HDR = <<~HDR.freeze
|
216
|
+
<html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
|
217
|
+
<head/>
|
218
|
+
<body lang="en">
|
219
|
+
<div class="title-section">
|
220
|
+
<p> </p>
|
221
|
+
</div>
|
222
|
+
<br/>
|
223
|
+
<div class="prefatory-section">
|
224
|
+
<p> </p>
|
225
|
+
</div>
|
226
|
+
<br/>
|
227
|
+
<div class="main-section">
|
228
|
+
HDR
|
249
229
|
|
250
|
-
|
251
|
-
|
230
|
+
WORD_HDR = <<~HDR.freeze
|
231
|
+
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
232
|
+
<head>
|
233
|
+
<title>test</title>
|
234
|
+
</head>
|
235
|
+
<body lang="EN-US" link="blue" vlink="#954F72">
|
236
|
+
<div class="WordSection1">
|
237
|
+
<p> </p>
|
238
|
+
</div>
|
239
|
+
<p><br clear="all" class="section"/></p>
|
240
|
+
<div class="WordSection2">
|
241
|
+
<p> </p>
|
242
|
+
</div>
|
243
|
+
<p><br clear="all" class="section"/></p>
|
244
|
+
<div class="WordSection3">
|
245
|
+
HDR
|
252
246
|
|
253
|
-
|
254
|
-
and_wrap_original do |search, *args|
|
255
|
-
code = args[0]
|
256
|
-
expect(code).to be_instance_of String
|
257
|
-
xml = get_xml(search, code, opts)
|
258
|
-
hit_pages
|
259
|
-
end.at_least :once
|
260
|
-
end
|
247
|
+
OPTIONS = [backend: :iso, header_footer: true].freeze
|
261
248
|
|
262
249
|
def mock_pdf
|
263
|
-
allow(::Mn2pdf).to receive(:convert) do |url, output
|
250
|
+
allow(::Mn2pdf).to receive(:convert) do |url, output,|
|
264
251
|
FileUtils.cp(url.gsub(/"/, ""), output.gsub(/"/, ""))
|
265
252
|
end
|
266
253
|
end
|
267
254
|
|
268
255
|
def mock_sts
|
269
|
-
allow(::Mn2sts).to receive(:convert) do |url, output
|
256
|
+
allow(::Mn2sts).to receive(:convert) do |url, output,|
|
270
257
|
FileUtils.cp(url.gsub(/"/, ""), output.gsub(/"/, ""))
|
271
258
|
end
|
272
259
|
end
|
@@ -274,7 +261,7 @@ end
|
|
274
261
|
private
|
275
262
|
|
276
263
|
def get_xml(search, code, opts)
|
277
|
-
c = code.gsub(%r{[
|
264
|
+
c = code.gsub(%r{[/\s:-]}, "_").sub(%r{_+$}, "").downcase
|
278
265
|
o = opts.keys.join "_"
|
279
266
|
file = "spec/examples/#{[c, o].join '_'}.xml"
|
280
267
|
if File.exist? file
|
@@ -289,11 +276,9 @@ def get_xml(search, code, opts)
|
|
289
276
|
end
|
290
277
|
|
291
278
|
def mock_open_uri(code)
|
292
|
-
#expect(OpenURI).to receive(:open_uri).and_wrap_original do |m, *args|
|
293
279
|
expect(Iev).to receive(:get).with(code, "en") do |m, *args|
|
294
280
|
file = "spec/examples/#{code.tr('-', '_')}.html"
|
295
281
|
File.write file, m.call(*args).read unless File.exist? file
|
296
282
|
File.read file
|
297
283
|
end.at_least :once
|
298
284
|
end
|
299
|
-
|