erbtex 0.4.4 → 0.5.0

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.
@@ -0,0 +1,307 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'open3'
5
+ require 'rbconfig'
6
+ require 'tmpdir'
7
+ require 'json'
8
+
9
+ describe ErbTeX do
10
+ describe '.run' do
11
+ before do
12
+ allow(described_class).to receive(:puts)
13
+ allow(described_class).to receive(:warn)
14
+ end
15
+
16
+ it 'returns success for help without terminating its caller' do
17
+ expect(described_class.run(ErbTeX::CommandLine.new(['--help']))).to eq(0)
18
+ end
19
+
20
+ it 'returns success for version information without terminating its caller' do
21
+ expect(described_class.run(ErbTeX::CommandLine.new(['--version']))).to eq(0)
22
+ end
23
+
24
+ it 'raises a recoverable error when preprocess-only has no input file' do
25
+ expect { described_class.run(ErbTeX::CommandLine.new(['--preprocess-only'])) }
26
+ .to raise_error(ErbTeX::NoInputFile, '--preprocess-only requires an input file')
27
+ end
28
+
29
+ it 'returns the TeX failure status without terminating its caller' do
30
+ cl = ErbTeX::CommandLine.new(["--invoke=#{RbConfig.ruby}", '-e', 'exit 7', '--', '\\relax'])
31
+
32
+ expect(described_class.run(cl)).to eq(7)
33
+ end
34
+ end
35
+
36
+ describe '.erb_to_tex' do
37
+ before do
38
+ allow(described_class).to receive(:warn)
39
+ end
40
+
41
+ around do |example|
42
+ Dir.mktmpdir('erbtex-spec') do |directory|
43
+ Dir.chdir(directory) { example.run }
44
+ end
45
+ end
46
+
47
+ it 'preserves existing output when the template has a syntax error' do
48
+ File.write('file.tex.erb', '{: if :}')
49
+ File.write('file.tex', "#{described_class::GENERATED_MARKER}\nprevious output")
50
+
51
+ expect { described_class.erb_to_tex('file.tex.erb', '') }
52
+ .to raise_error(SyntaxError)
53
+ expect(File.read('file.tex')).to eq("#{described_class::GENERATED_MARKER}\nprevious output")
54
+ expect(Dir.children('.')).to contain_exactly('file.tex.erb', 'file.tex')
55
+ end
56
+
57
+ it 'reports the input path and line number for a template syntax error' do
58
+ Dir.mkdir('templates')
59
+ File.write('templates/my document.tex.erb', "first line\nsecond line\n{: ) :}\n")
60
+
61
+ _, stderr, status = run_erbtex('templates/my document.tex.erb')
62
+
63
+ expect(status.exitstatus).to eq(1)
64
+ expect(stderr).to include('Erubis pre-processing failed:', 'templates/my document.tex.erb:3')
65
+ end
66
+
67
+ it 'identifies the input path and line number in a template runtime backtrace' do
68
+ Dir.mkdir('templates')
69
+ File.write('templates/my document.tex.erb', "first line\nsecond line\n{: raise 'template failed' :}\n")
70
+
71
+ _, stderr, status = run_erbtex('templates/my document.tex.erb')
72
+
73
+ expect(status.exitstatus).to eq(1)
74
+ expect(stderr).to include('template failed', 'templates/my document.tex.erb:3')
75
+ end
76
+
77
+ it 'preserves existing output when the template raises an exception' do
78
+ File.write('file.tex.erb', '{: raise "template failed" :}')
79
+ File.write('file.tex', "#{described_class::GENERATED_MARKER}\nprevious output")
80
+
81
+ expect { described_class.erb_to_tex('file.tex.erb', '') }
82
+ .to raise_error(RuntimeError, 'template failed')
83
+ expect(File.read('file.tex')).to eq("#{described_class::GENERATED_MARKER}\nprevious output")
84
+ expect(Dir.children('.')).to contain_exactly('file.tex.erb', 'file.tex')
85
+ end
86
+
87
+ it 'raises a recoverable filesystem error for missing input' do
88
+ expect { described_class.erb_to_tex('missing.tex.erb') }.to raise_error(Errno::ENOENT)
89
+ end
90
+
91
+ it 'refuses unmarked output before executing the template' do
92
+ File.write('file.tex.erb', '{: File.write("executed", "yes") :}')
93
+ File.write('file.tex', 'hand-written document')
94
+
95
+ expect { described_class.erb_to_tex('file.tex.erb') }.to raise_error(ErbTeX::OutputExists)
96
+ expect(File.read('file.tex')).to eq('hand-written document')
97
+ expect(Dir.children('.')).to contain_exactly('file.tex.erb', 'file.tex')
98
+ end
99
+
100
+ it 'requires an exact marker on the first line' do
101
+ File.write('file.tex.erb', 'new output')
102
+ contents = "hand-written document\n#{described_class::GENERATED_MARKER}\n"
103
+ File.write('file.tex', contents)
104
+
105
+ expect { described_class.erb_to_tex('file.tex.erb') }.to raise_error(ErbTeX::OutputExists)
106
+ expect(File.read('file.tex')).to eq(contents)
107
+ end
108
+
109
+ it 'refuses marked output with no-clobber before executing the template' do
110
+ File.write('file.tex.erb', '{: File.write("executed", "yes") :}')
111
+ contents = "#{described_class::GENERATED_MARKER}\nprevious output"
112
+ File.write('file.tex', contents)
113
+
114
+ expect { described_class.erb_to_tex('file.tex.erb', no_clobber: true) }
115
+ .to raise_error(ErbTeX::OutputExists, /--no-clobber/)
116
+ expect(File.read('file.tex')).to eq(contents)
117
+ expect(Dir.children('.')).to contain_exactly('file.tex.erb', 'file.tex')
118
+ end
119
+
120
+ it 'reports missing input as a CLI failure' do
121
+ _, stderr, status = run_erbtex('--preprocess-only', 'missing.tex.erb')
122
+
123
+ expect(status.exitstatus).to eq(1)
124
+ expect(stderr).to include('Error:', 'missing.tex.erb')
125
+ end
126
+
127
+ it 'replaces existing output after rendering successfully and removes the temporary file' do
128
+ File.write('file.tex.erb', 'answer: {:= 6 * 7 :}')
129
+ File.write('file.tex', "#{described_class::GENERATED_MARKER}\nprevious output")
130
+
131
+ expect(described_class.erb_to_tex('file.tex.erb', '')).to eq('file.tex')
132
+ expect(File.read('file.tex')).to eq("#{described_class::GENERATED_MARKER}\nanswer: 42")
133
+ expect(File.read('file.tex.erb')).to eq('answer: {:= 6 * 7 :}')
134
+ expect(Dir.children('.')).to contain_exactly('file.tex.erb', 'file.tex')
135
+ end
136
+ end
137
+
138
+ describe 'TeX invocation' do
139
+ around do |example|
140
+ Dir.mktmpdir('erbtex-invocation') do |directory|
141
+ Dir.chdir(directory) { example.run }
142
+ end
143
+ end
144
+
145
+ before do
146
+ script = <<~RUBY
147
+ #!#{RbConfig.ruby}
148
+ require 'json'
149
+ File.open('calls.jsonl', 'a') { |file| file.puts(JSON.generate(ARGV)) }
150
+ exit(Integer(ENV.fetch('FAKE_TEX_STATUS', '0')))
151
+ RUBY
152
+ File.write('faketex', script)
153
+ File.chmod(0o755, 'faketex')
154
+ File.write('file.tex.erb', 'answer: {:= 6 * 7 :}')
155
+ end
156
+
157
+ def invoke_tex(*arguments, status: '0')
158
+ run_erbtex(
159
+ *arguments,
160
+ env: { 'PATH' => "#{Dir.pwd}:#{ENV.fetch('PATH')}", 'FAKE_TEX_STATUS' => status },
161
+ )
162
+ end
163
+
164
+ it 'preserves spaces, empty arguments, shell characters, and filenames across both passes' do
165
+ filename = 'my file; echo INJECTED.tex.erb'
166
+ File.rename('file.tex.erb', filename)
167
+ arguments = ['-jobname=a b', '', 'literal $HOME & `echo bad`', filename]
168
+ stdout, stderr, status = invoke_tex('--invoke=faketex', *arguments)
169
+
170
+ expect(status.exitstatus).to eq(0), stderr
171
+ expect(stdout).to eq('')
172
+ expected = [*arguments[0...-1], 'my file; echo INJECTED.tex']
173
+ expect(File.readlines('calls.jsonl').map { |line| JSON.parse(line) }).to eq([expected, expected])
174
+ end
175
+
176
+ it 'propagates a failed TeX exit status and skips the second pass' do
177
+ _, stderr, status = invoke_tex('--invoke=faketex', 'file.tex.erb', status: '7')
178
+
179
+ expect(status.exitstatus).to eq(7), stderr
180
+ expect(File.readlines('calls.jsonl').size).to eq(1)
181
+ end
182
+
183
+ it 'preprocesses without invoking TeX when preprocess-only is supplied' do
184
+ _, stderr, status = invoke_tex('--preprocess-only', '--invoke=faketex', 'file.tex.erb')
185
+
186
+ expect(status.exitstatus).to eq(0), stderr
187
+ expect(File.read('file.tex')).to eq("#{described_class::GENERATED_MARKER}\nanswer: 42")
188
+ expect(File.exist?('calls.jsonl')).to be(false)
189
+ end
190
+
191
+ it 'allows no-clobber when the destination does not exist' do
192
+ _, stderr, status = invoke_tex('--preprocess-only', '--no-clobber', 'file.tex.erb')
193
+
194
+ expect(status.exitstatus).to eq(0), stderr
195
+ expect(File.read('file.tex')).to eq("#{described_class::GENERATED_MARKER}\nanswer: 42")
196
+ end
197
+
198
+ it 'warns and skips TeX when the output is unmarked' do
199
+ File.write('file.tex', 'hand-written document')
200
+ _, stderr, status = invoke_tex('--invoke=faketex', 'file.tex.erb')
201
+
202
+ expect(status.exitstatus).to eq(1)
203
+ expect(stderr).to include('Warning: Refusing to overwrite file.tex', 'missing erbtex generated-file marker')
204
+ expect(File.read('file.tex')).to eq('hand-written document')
205
+ expect(File.exist?('calls.jsonl')).to be(false)
206
+ end
207
+
208
+ it 'allows marked output to be regenerated by default' do
209
+ invoke_tex('--preprocess-only', 'file.tex.erb')
210
+ File.write('file.tex.erb', 'updated document')
211
+ _, stderr, status = invoke_tex('--preprocess-only', 'file.tex.erb')
212
+
213
+ expect(status.exitstatus).to eq(0), stderr
214
+ expect(File.read('file.tex')).to eq("#{described_class::GENERATED_MARKER}\nupdated document")
215
+ end
216
+
217
+ it 'warns and skips TeX when no-clobber protects marked output' do
218
+ contents = "#{described_class::GENERATED_MARKER}\nprevious output"
219
+ File.write('file.tex', contents)
220
+ _, stderr, status = invoke_tex('--no-clobber', '--invoke=faketex', 'file.tex.erb')
221
+
222
+ expect(status.exitstatus).to eq(1)
223
+ expect(stderr).to include('Warning: Refusing to overwrite file.tex', '--no-clobber')
224
+ expect(File.read('file.tex')).to eq(contents)
225
+ expect(File.exist?('calls.jsonl')).to be(false)
226
+ end
227
+
228
+ it 'writes an etx file for tex input in preprocess-only mode' do
229
+ File.rename('file.tex.erb', 'file.tex')
230
+ _, stderr, status = invoke_tex('--preprocess-only', '--invoke=faketex', 'file.tex')
231
+
232
+ expect(status.exitstatus).to eq(0), stderr
233
+ expect(File.read('file.etx')).to eq("#{described_class::GENERATED_MARKER}\nanswer: 42")
234
+ expect(File.exist?('calls.jsonl')).to be(false)
235
+ end
236
+
237
+ it 'fails without invoking TeX when preprocess-only has no input file' do
238
+ _, stderr, status = invoke_tex('--preprocess-only', '--invoke=faketex')
239
+
240
+ expect(status.exitstatus).to eq(1)
241
+ expect(stderr).to include('--preprocess-only requires an input file')
242
+ expect(File.exist?('calls.jsonl')).to be(false)
243
+ end
244
+
245
+ it 'reports template failures in preprocess-only mode without invoking TeX' do
246
+ File.write('file.tex.erb', '{: ) :}')
247
+ _, stderr, status = invoke_tex('--preprocess-only', '--invoke=faketex', 'file.tex.erb')
248
+
249
+ expect(status.exitstatus).to eq(1)
250
+ expect(stderr).to include('Erubis pre-processing failed:', 'file.tex.erb:1')
251
+ expect(File.exist?('calls.jsonl')).to be(false)
252
+ expect(File.exist?('file.tex')).to be(false)
253
+ end
254
+
255
+ it 'invokes an executable by its complete path with spaces and hyphens' do
256
+ File.rename('faketex', 'fake tex-engine')
257
+ executable = File.join(Dir.pwd, 'fake tex-engine')
258
+ _, stderr, status = invoke_tex("--invoke=#{executable}", 'file.tex.erb')
259
+
260
+ expect(status.exitstatus).to eq(0), stderr
261
+ expect(File.readlines('calls.jsonl').map { |line| JSON.parse(line) }).to eq([['file.tex'], ['file.tex']])
262
+ end
263
+
264
+ it 'runs latexmk only once' do
265
+ File.rename('faketex', 'latexmk')
266
+ _, stderr, status = invoke_tex('--invoke=latexmk', 'file.tex.erb')
267
+
268
+ expect(status.exitstatus).to eq(0), stderr
269
+ expect(File.readlines('calls.jsonl').size).to eq(1)
270
+ end
271
+
272
+ it 'passes TeX commands without requiring an input file' do
273
+ commands = ['\\relax', 'a b', '\\end']
274
+ _, stderr, status = invoke_tex('--invoke=faketex', *commands)
275
+
276
+ expect(status.exitstatus).to eq(0), stderr
277
+ expect(File.readlines('calls.jsonl').map { |line| JSON.parse(line) }).to eq([commands, commands])
278
+ end
279
+ end
280
+
281
+ def run_erbtex(*arguments, env: {})
282
+ root = File.expand_path('../..', __dir__)
283
+ Open3.capture3(
284
+ env,
285
+ RbConfig.ruby,
286
+ "-I#{File.join(root, 'lib')}",
287
+ File.join(root, 'bin', 'erbtex'),
288
+ *arguments,
289
+ )
290
+ end
291
+
292
+ it 'prints help and exits successfully without processing a file' do
293
+ stdout, stderr, status = run_erbtex('--help')
294
+
295
+ expect(status.exitstatus).to eq(0), stderr
296
+ expect(stdout).to include('Usage: erbtex', '--preprocess-only', '--no-clobber', 'without invoking TeX')
297
+ expect(stderr).to eq('')
298
+ end
299
+
300
+ it 'prints version information and exits successfully without processing a file' do
301
+ stdout, stderr, status = run_erbtex('--version')
302
+
303
+ expect(status.exitstatus).to eq(0), stderr
304
+ expect(stdout).to include("erbtex version: #{ErbTeX::VERSION}", 'Ruby version:', 'erubis version:')
305
+ expect(stderr).to eq('')
306
+ end
307
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/setup'
2
4
  Bundler.setup
3
5
 
4
6
  require 'erbtex'
5
7
 
6
- require 'pry'
7
8
  require 'byebug'
8
9
 
9
10
  # This file was generated by the `rspec --init` command. Conventionally, all
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erbtex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2012-05-13 00:00:00.000000000 Z
10
+ date: 2026-10-20 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: erubis
@@ -39,7 +38,7 @@ dependencies:
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
40
  - !ruby/object:Gem::Dependency
42
- name: rake
41
+ name: bundler
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - ">="
@@ -53,7 +52,7 @@ dependencies:
53
52
  - !ruby/object:Gem::Version
54
53
  version: '0'
55
54
  - !ruby/object:Gem::Dependency
56
- name: bundler
55
+ name: minitest
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - ">="
@@ -67,7 +66,7 @@ dependencies:
67
66
  - !ruby/object:Gem::Version
68
67
  version: '0'
69
68
  - !ruby/object:Gem::Dependency
70
- name: rspec
69
+ name: pry
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
72
  - - ">="
@@ -81,7 +80,7 @@ dependencies:
81
80
  - !ruby/object:Gem::Version
82
81
  version: '0'
83
82
  - !ruby/object:Gem::Dependency
84
- name: minitest
83
+ name: pry-byebug
85
84
  requirement: !ruby/object:Gem::Requirement
86
85
  requirements:
87
86
  - - ">="
@@ -95,7 +94,7 @@ dependencies:
95
94
  - !ruby/object:Gem::Version
96
95
  version: '0'
97
96
  - !ruby/object:Gem::Dependency
98
- name: pry
97
+ name: pry-doc
99
98
  requirement: !ruby/object:Gem::Requirement
100
99
  requirements:
101
100
  - - ">="
@@ -109,7 +108,7 @@ dependencies:
109
108
  - !ruby/object:Gem::Version
110
109
  version: '0'
111
110
  - !ruby/object:Gem::Dependency
112
- name: pry-doc
111
+ name: rake
113
112
  requirement: !ruby/object:Gem::Requirement
114
113
  requirements:
115
114
  - - ">="
@@ -123,7 +122,7 @@ dependencies:
123
122
  - !ruby/object:Gem::Version
124
123
  version: '0'
125
124
  - !ruby/object:Gem::Dependency
126
- name: pry-byebug
125
+ name: rspec
127
126
  requirement: !ruby/object:Gem::Requirement
128
127
  requirements:
129
128
  - - ">="
@@ -148,10 +147,15 @@ extensions: []
148
147
  extra_rdoc_files: []
149
148
  files:
150
149
  - ".bundle/config"
150
+ - ".envrc"
151
151
  - ".gitignore"
152
+ - ".rubocop.yml"
153
+ - CHANGELOG.md
154
+ - CHANGELOG.org
152
155
  - Gemfile
153
156
  - Gemfile.lock
154
157
  - LICENCE
158
+ - README.md
155
159
  - README.org
156
160
  - Rakefile
157
161
  - bin/erbtex
@@ -160,6 +164,7 @@ files:
160
164
  - examples/TrigTable.tex
161
165
  - examples/TrigTable2.tex
162
166
  - examples/dms.rb
167
+ - examples/int_ext.rb
163
168
  - examples/roots.tex
164
169
  - examples/testbind.rb
165
170
  - examples/testbind.tex
@@ -168,15 +173,16 @@ files:
168
173
  - lib/erbtex/file_names.rb
169
174
  - lib/erbtex/runner.rb
170
175
  - lib/erbtex/version.rb
176
+ - spec/erbtex/command_line_spec.rb
177
+ - spec/erbtex/file_names_spec.rb
178
+ - spec/erbtex/runner_spec.rb
171
179
  - spec/example_files/roots.tex
172
180
  - spec/example_files/roots.tex.erb
173
- - spec/lib/command_line_spec.rb
174
- - spec/lib/file_names_spec.rb
175
181
  - spec/spec_helper.rb
176
182
  homepage: https://github.com/ddoherty03/erbtex
177
- licenses: []
183
+ licenses:
184
+ - MIT
178
185
  metadata: {}
179
- post_install_message:
180
186
  rdoc_options: []
181
187
  require_paths:
182
188
  - lib
@@ -191,8 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
197
  - !ruby/object:Gem::Version
192
198
  version: '0'
193
199
  requirements: []
194
- rubygems_version: 3.0.3
195
- signing_key:
200
+ rubygems_version: 3.6.2
196
201
  specification_version: 4
197
202
  summary: Preprocesses TeX and LaTeX files with erubis for ruby.
198
203
  test_files: []
@@ -1,150 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module ErbTeX
4
- describe CommandLine do
5
- describe 'parsing' do
6
- before :all do
7
- # Without this fakery, $0 would be rspec when these specs are run.
8
- $0 = 'erbtex'
9
- # Note: ARGV does not include the name of the program as the first
10
- # element, as in C.
11
- @argv_with_file =
12
- %w(
13
- -draftmode -enc -etex -file-line-error -fmt junk
14
- -halt-on-error -ini -interaction batchmode -ipc -ipc-start
15
- -jobname junk -kpathsea-debug 8 -mktex tex --invoke=pdflatex
16
- -mltex -nomktex tfm -ouptput-comment This\ is\ a\ long\ comment
17
- -output-directory ~/texmf/tex -parse-first-line -progname pdflatex
18
- -recorder -shell-escape -src-specials cr,display,hbox,math,par
19
- -translate-file willy -version &myformat file_name.tex.erb
20
- )
21
- @argv_with_remote_file =
22
- %w(
23
- -draftmode -enc -etex -file-line-error -fmt junk
24
- -halt-on-error -ini -interaction batchmode -ipc -ipc-start
25
- -jobname junk -kpathsea-debug 8 -mktex tex --invoke=pdflatex
26
- -mltex -nomktex tfm -ouptput-comment This\ is\ a\ long\ comment
27
- -output-directory ~/texmf/tex -parse-first-line -progname pdflatex
28
- -recorder -shell-escape -src-specials cr,display,hbox,math,par
29
- -translate-file willy -version &myformat example_files/file_name.tex.erb
30
- )
31
- @argv_with_invoke_and_file =
32
- %w(
33
- --invoke=lualatex
34
- -draftmode -enc -etex -file-line-error -fmt junk
35
- -halt-on-error -ini -interaction batchmode -ipc -ipc-start
36
- -jobname junk -kpathsea-debug 8 -mktex tex --invoke=pdflatex
37
- -mltex -nomktex tfm -ouptput-comment This\ is\ a\ long\ comment
38
- -output-directory ~/texmf/tex -parse-first-line -progname pdflatex
39
- -recorder -shell-escape -src-specials cr,display,hbox,math,par
40
- -translate-file willy -version &myformat file_name.tex.erb
41
- )
42
- @argv_with_cmds =
43
- %w(
44
- -draftmode -enc -etex -file-line-error -fmt junk
45
- -halt-on-error -ini -interaction batchmode -ipc -ipc-start
46
- -jobname junk -kpathsea-debug 8 -mktex tex --invoke=pdflatex
47
- -mltex -nomktex tfm -ouptput-comment This\ is\ a\ long\ comment
48
- -output-directory ~/texmf/tex -parse-first-line -progname pdflatex
49
- -recorder -shell-escape -src-specials cr,display,hbox,math,par
50
- -translate-file willy -version &myformat
51
- \\input{junk.tex} \\print these \\items \\end not_a_file
52
- )
53
- @argv_with_file_cmds =
54
- %w(
55
- -draftmode -enc -etex -file-line-error -fmt junk
56
- -halt-on-error -ini -interaction batchmode -ipc -ipc-start
57
- -jobname junk -kpathsea-debug 8 -mktex tex --invoke=pdflatex
58
- -mltex -nomktex tfm -ouptput-comment This\ is\ a\ long\ comment
59
- -output-directory ~/texmf/tex -parse-first-line -progname pdflatex
60
- -recorder -shell-escape -src-specials cr,display,hbox,math,par
61
- -translate-file willy -version &myformat file_name
62
- \\input{junk.tex} \\print these \\items \\end not_a_file
63
- )
64
- end
65
-
66
- it 'parse command line with file name' do
67
- cl = CommandLine.new(@argv_with_file)
68
- expect(cl.erbtex_name).to eq('erbtex')
69
- expect(cl.tex_program).to eq('pdflatex')
70
- expect(cl.input_file).to eq('file_name.tex.erb')
71
- expect(cl.tex_command).to eq(<<~'EOS'.tr("\n", ' ').strip)
72
- pdflatex -draftmode -enc -etex -file-line-error -fmt junk -halt-on-error
73
- -ini -interaction batchmode -ipc -ipc-start -jobname junk -kpathsea-debug 8
74
- -mktex tex -mltex -nomktex tfm
75
- -ouptput-comment This\ is\ a\ long\ comment
76
- -output-directory \~/texmf/tex -parse-first-line -progname pdflatex
77
- -recorder -shell-escape -src-specials cr,display,hbox,math,par
78
- -translate-file willy -version \&myformat file_name.tex.erb
79
- EOS
80
- end
81
-
82
- it 'parse command line with remote file name' do
83
- cl = CommandLine.new(@argv_with_remote_file)
84
- expect(cl.erbtex_name).to eq('erbtex')
85
- expect(cl.tex_program).to eq('pdflatex')
86
- expect(cl.input_file).to eq('example_files/file_name.tex.erb')
87
- expect(cl.tex_command).to eq(<<~'EOS'.tr("\n", ' ').strip)
88
- pdflatex -draftmode -enc -etex -file-line-error -fmt junk -halt-on-error
89
- -ini -interaction batchmode -ipc -ipc-start -jobname junk -kpathsea-debug 8
90
- -mktex tex -mltex -nomktex tfm
91
- -ouptput-comment This\ is\ a\ long\ comment
92
- -output-directory \~/texmf/tex -parse-first-line -progname pdflatex
93
- -recorder -shell-escape -src-specials cr,display,hbox,math,par
94
- -translate-file willy -version \&myformat example_files/file_name.tex.erb
95
- EOS
96
- end
97
-
98
- it 'parse command line with invoke and file name' do
99
- cl = CommandLine.new(@argv_with_invoke_and_file)
100
- expect(cl.erbtex_name).to eq('erbtex')
101
- expect(cl.tex_program).to eq('lualatex')
102
- expect(cl.input_file).to eq('file_name.tex.erb')
103
- expect(cl.tex_command).to eq(<<~'EOS'.tr("\n", ' ').strip)
104
- lualatex -draftmode -enc -etex -file-line-error -fmt junk -halt-on-error
105
- -ini -interaction batchmode -ipc -ipc-start -jobname junk -kpathsea-debug 8
106
- -mktex tex -mltex -nomktex tfm
107
- -ouptput-comment This\ is\ a\ long\ comment
108
- -output-directory \~/texmf/tex -parse-first-line -progname pdflatex
109
- -recorder -shell-escape -src-specials cr,display,hbox,math,par
110
- -translate-file willy -version \&myformat file_name.tex.erb
111
- EOS
112
- end
113
-
114
- it 'parse command line with TeX commands' do
115
- cl = CommandLine.new(@argv_with_cmds)
116
- expect(cl.erbtex_name).to eq('erbtex')
117
- expect(cl.tex_program).to eq('pdflatex')
118
- expect(cl.input_file).to be_nil
119
- expect(cl.tex_command).to eq(<<~'EOS'.tr("\n", ' ').strip)
120
- pdflatex -draftmode -enc -etex -file-line-error -fmt junk -halt-on-error
121
- -ini -interaction batchmode -ipc -ipc-start -jobname junk -kpathsea-debug 8
122
- -mktex tex -mltex -nomktex tfm
123
- -ouptput-comment This\ is\ a\ long\ comment
124
- -output-directory \~/texmf/tex -parse-first-line -progname pdflatex
125
- -recorder -shell-escape -src-specials cr,display,hbox,math,par
126
- -translate-file willy -version \&myformat
127
- \\input\{junk.tex\} \\print these \\items \\end not_a_file
128
- EOS
129
- end
130
-
131
- it 'parse command line with a file name and TeX commands' do
132
- cl = CommandLine.new(@argv_with_file_cmds)
133
- expect(cl.erbtex_name).to eq('erbtex')
134
- expect(cl.tex_program).to eq('pdflatex')
135
- expect(cl.input_file).to eq('file_name')
136
- expect(cl.tex_command).to eq(<<~'EOS'.tr("\n", ' ').strip)
137
- pdflatex -draftmode -enc -etex -file-line-error -fmt junk -halt-on-error
138
- -ini -interaction batchmode -ipc -ipc-start -jobname junk -kpathsea-debug 8
139
- -mktex tex -mltex -nomktex tfm
140
- -ouptput-comment This\ is\ a\ long\ comment
141
- -output-directory \~/texmf/tex -parse-first-line -progname pdflatex
142
- -recorder -shell-escape -src-specials cr,display,hbox,math,par
143
- -translate-file willy -version \&myformat
144
- \\input\{junk.tex\} \\print these \\items \\end not_a_file
145
- file_name
146
- EOS
147
- end
148
- end
149
- end
150
- end