erbtex 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/.bundle/config +2 -0
- data/.gitignore +4 -1
- data/Gemfile.lock +40 -4
- data/README.org +137 -0
- data/Rakefile +10 -13
- data/bin/erbtex +3 -44
- data/erbtex.gemspec +11 -7
- data/examples/TrigTable.tex +3 -3
- data/examples/TrigTable2.tex +10 -6
- data/examples/{roots.tex → roots.tex.erb} +0 -0
- data/examples/{testbind.tex → testbind.tex.erb} +0 -0
- data/lib/erbtex/command_line.rb +79 -109
- data/lib/erbtex/runner.rb +163 -56
- data/lib/erbtex/version.rb +1 -1
- data/lib/erbtex.rb +8 -3
- data/spec/lib/command_line_spec.rb +146 -0
- data/spec/lib/find_executable_spec.rb +43 -0
- data/spec/spec_helper.rb +26 -0
- metadata +66 -31
- data/README.md +0 -127
- data/bin/etex +0 -49
- data/bin/latex +0 -49
- data/bin/lualatex +0 -49
- data/bin/luatex +0 -49
- data/bin/pdfetex +0 -49
- data/bin/pdflatex +0 -49
- data/bin/pdftex +0 -49
- data/bin/pslatex +0 -49
- data/bin/tex +0 -49
- data/bin/xelatex +0 -49
- data/bin/xetex +0 -49
- data/test/test_command_line.rb +0 -181
- data/test/test_find_executable.rb +0 -44
- data/test/test_helper.rb +0 -10
data/lib/erbtex/runner.rb
CHANGED
@@ -14,12 +14,10 @@ module ErbTeX
|
|
14
14
|
# Write the .etx file to the current directory unless it is not
|
15
15
|
# writable, in which case write it to /tmp.
|
16
16
|
#
|
17
|
-
# Perhaps change the Erubis pattern to something
|
18
|
-
#
|
19
|
-
#
|
20
|
-
|
21
|
-
# input.
|
22
|
-
#
|
17
|
+
# Perhaps change the Erubis pattern to something other than the erbtex
|
18
|
+
# default '{: :}'. Erubis normally by uses '<%= %>' by default. Erubis -p
|
19
|
+
# commandline -p '\.{ }\.'
|
20
|
+
|
23
21
|
# If there are no Erubis patterns in the file, skip the Erubis phase
|
24
22
|
# and just pass the original command on to the system.
|
25
23
|
#
|
@@ -37,72 +35,181 @@ module ErbTeX
|
|
37
35
|
# on our processed .etx file and otherwise leave the commandline
|
38
36
|
# intact.
|
39
37
|
#
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
38
|
+
def self.run(cl)
|
39
|
+
tex_dir = input_dir(cl.input_file)
|
40
|
+
tex_file = erb_to_tex(cl.input_file, tex_dir) if cl.input_file
|
41
|
+
run_tex(cl.tex_command(tex_file), tex_dir)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Run the TeX program, adding add_dir to the front of TEXINPUTS, unless it is
|
45
|
+
# already in TEXINPUTS.
|
46
|
+
def self.run_tex(cmd, add_dir = nil)
|
47
|
+
new_env = {}
|
48
|
+
if add_dir
|
49
|
+
add_dir = File.absolute_path(File.expand_path(add_dir))
|
50
|
+
unless ENV['TEXINPUTS'].split(File::PATH_SEPARATOR)
|
51
|
+
.reject { |p| p.strip.empty? }
|
52
|
+
.any? { |p| add_dir == File.absolute_path(File.expand_path(p)) }
|
53
|
+
new_env['TEXINPUTS'] = "#{add_dir}:#{ENV['TEXINPUTS']}"
|
56
54
|
end
|
57
55
|
end
|
56
|
+
unless system(cmd)
|
57
|
+
$stderr.puts "Call to '#{cmd}' failed."
|
58
|
+
exit $?.exitstatus
|
59
|
+
end
|
60
|
+
$?
|
58
61
|
end
|
59
62
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
def self.input_dir(in_file)
|
64
|
+
return nil unless in_file
|
65
|
+
in_file_absolute = File.absolute_path(File.expand_path(in_file))
|
66
|
+
in_file_absolute[/\A(.*\/)([^\/.]+)(\.[\w.]+)\z/, 1]
|
67
|
+
end
|
68
|
+
|
69
|
+
# Pre-process the input file with erubis, adding the add_dir to the front of
|
70
|
+
# the ruby load path if its not already in the load path. Return the name of
|
71
|
+
# the processed file.
|
72
|
+
def self.erb_to_tex(in_file, add_dir = nil)
|
73
|
+
add_dir = File.absolute_path(File.expand_path(add_dir))
|
74
|
+
unless $LOAD_PATH
|
75
|
+
.any? { |p| add_dir == File.absolute_path(File.expand_path(p)) }
|
76
|
+
$LOAD_PATH.unshift(add_dir)
|
77
|
+
end
|
78
|
+
|
79
|
+
in_contents = nil
|
80
|
+
File.open(in_file) do |f|
|
81
|
+
in_contents = f.read
|
69
82
|
end
|
70
83
|
# TODO: recurse through any \input or \include commands
|
71
84
|
|
72
|
-
|
73
|
-
|
85
|
+
pat =
|
86
|
+
if ENV['ERBTEX_PATTERN']
|
87
|
+
ENV['ERBTEX_PATTERN']
|
88
|
+
else
|
89
|
+
'{: :}'
|
90
|
+
end
|
74
91
|
|
75
|
-
|
76
|
-
|
92
|
+
out_file = set_out_file(in_file)
|
93
|
+
File.open(out_file, 'w') do |f|
|
94
|
+
er = ::Erubis::Eruby.new(in_contents, pattern: pat)
|
95
|
+
f.write(er.result)
|
96
|
+
end
|
97
|
+
out_file
|
98
|
+
rescue SystemCallError => ex
|
99
|
+
$stderr.puts "Error: #{ex}"
|
100
|
+
exit 1
|
101
|
+
rescue ScriptError => ex
|
102
|
+
$stderr.puts "Erubis pre-processing failed: #{ex}"
|
103
|
+
exit 1
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.set_out_file(in_file)
|
107
|
+
in_file_absolute = File.absolute_path(File.expand_path(in_file))
|
108
|
+
in_dir = in_file_absolute[/\A(.*\/)([^\/.]+)(\.[\w.]+)\z/, 1]
|
109
|
+
in_base = in_file_absolute[/\A(.*\/)([^\/.]+)(\.[\w.]+)\z/, 2]
|
110
|
+
in_ext = in_file_absolute[/\A(.*\/)([^\/.]+)(\.[\w.]+)\z/, 3]
|
111
|
+
|
112
|
+
if in_ext.empty?
|
113
|
+
if File.exists?("#{in_file}.tex.erb")
|
114
|
+
out_ext = '.tex'
|
115
|
+
elsif File.exists?("#{in_file}.tex")
|
116
|
+
out_ext = '.etx'
|
117
|
+
elsif File.exists?("#{in_file}.erb")
|
118
|
+
out_ext = '.tex'
|
119
|
+
else
|
120
|
+
out_ext = '.tex'
|
121
|
+
end
|
77
122
|
else
|
78
|
-
|
123
|
+
case in_ext
|
124
|
+
when '.tex.erb'
|
125
|
+
out_ext = '.tex'
|
126
|
+
when '.tex'
|
127
|
+
out_ext = '.etx'
|
128
|
+
when '.erb'
|
129
|
+
out_ext = '.tex'
|
130
|
+
else
|
131
|
+
out_ext = '.tex'
|
132
|
+
end
|
79
133
|
end
|
80
134
|
|
81
|
-
# Otherwise process the contents
|
82
135
|
# Find a writable directory, prefering the one the input file came
|
83
136
|
# from, or the current directory, and a temp file as a last resort.
|
84
|
-
|
85
|
-
|
86
|
-
if file_absolute =~ /\.tex\.erb$/
|
87
|
-
file_base = File.basename(file_absolute, '.tex.erb')
|
88
|
-
else
|
89
|
-
file_base = File.basename(file_absolute, '.tex')
|
90
|
-
end
|
91
|
-
of = nil
|
92
|
-
if File.writable?(file_dir)
|
93
|
-
out_file = file_dir + '/' + file_base + '.etx'
|
137
|
+
if File.writable?(in_dir)
|
138
|
+
out_file = File.join(in_dir, "#{in_base}#{out_ext}")
|
94
139
|
elsif File.writable?('.')
|
95
|
-
out_file = '
|
140
|
+
out_file = File.join('.', "#{in_base}#{out_ext}")
|
96
141
|
else
|
97
|
-
|
98
|
-
out_file = of.path
|
142
|
+
out_file = Tempfile.new([in_base, out_ext]).path
|
99
143
|
end
|
100
|
-
unless of
|
101
|
-
of = File.open(out_file, 'w+')
|
102
|
-
end
|
103
|
-
er = Erubis::Eruby.new(contents, :pattern => pat)
|
104
|
-
of.write(er.result)
|
105
|
-
of.close
|
106
144
|
out_file
|
107
145
|
end
|
108
146
|
end
|
147
|
+
# def ErbTeX.run(command)
|
148
|
+
# cl = CommandLine.new(command)
|
149
|
+
# Dir.chdir(cl.run_dir) do
|
150
|
+
# if cl.input_file
|
151
|
+
# new_infile = process(cl.input_file, cl.input_path)
|
152
|
+
# else
|
153
|
+
# new_infile = nil
|
154
|
+
# end
|
155
|
+
# if new_infile
|
156
|
+
# new_infile = Pathname.new(new_infile).
|
157
|
+
# relative_path_from(Pathname.new(cl.run_dir))
|
158
|
+
# end
|
159
|
+
# new_progname = ErbTeX.find_executable(command.lstrip.split(' ')[0])
|
160
|
+
# cmd = cl.new_command_line(new_progname, new_infile)
|
161
|
+
# cmd.sub!('\\', '\\\\\\')
|
162
|
+
# cmd.sub!('&', '\\\\&')
|
163
|
+
# puts "Executing: #{cmd}"
|
164
|
+
# system(cmd)
|
165
|
+
# end
|
166
|
+
# end
|
167
|
+
|
168
|
+
# Run erbtex on the content of file_name, a String, and return the
|
169
|
+
# name of the file where the processed content can be found. This
|
170
|
+
# could be the orignal file name if no processing was needed, or a
|
171
|
+
# temporary file if the erubis pattern is found anywhere in the file.
|
172
|
+
# def ErbTeX.process(file_name, dir)
|
173
|
+
# puts "Input path: #{dir}"
|
174
|
+
# contents = nil
|
175
|
+
# File.open(file_name) do |f|
|
176
|
+
# contents = f.read
|
177
|
+
# end
|
178
|
+
# # TODO: recurse through any \input or \include commands
|
179
|
+
|
180
|
+
# # Add current directory to LOAD_PATH
|
181
|
+
# $: << '.' unless $:.include?('.')
|
182
|
+
|
183
|
+
# if ENV['ERBTEX_PATTERN']
|
184
|
+
# pat = ENV['ERBTEX_PATTERN']
|
185
|
+
# else
|
186
|
+
# pat = '{: :}'
|
187
|
+
# end
|
188
|
+
|
189
|
+
# # Otherwise process the contents
|
190
|
+
# # Find a writable directory, prefering the one the input file came
|
191
|
+
# # from, or the current directory, and a temp file as a last resort.
|
192
|
+
# file_absolute = File.absolute_path(File.expand_path(file_name))
|
193
|
+
# file_dir = File.dirname(file_absolute)
|
194
|
+
# if file_absolute =~ /\.tex\.erb$/
|
195
|
+
# file_base = File.basename(file_absolute, '.tex.erb')
|
196
|
+
# else
|
197
|
+
# file_base = File.basename(file_absolute, '.tex')
|
198
|
+
# end
|
199
|
+
# of = nil
|
200
|
+
# if File.writable?(file_dir)
|
201
|
+
# out_file = file_dir + '/' + file_base + '.etx'
|
202
|
+
# elsif File.writable?('.')
|
203
|
+
# out_file = './' + file_base + '.etx'
|
204
|
+
# else
|
205
|
+
# of = Tempfile.new([File.basename(file_name), '.etx'])
|
206
|
+
# out_file = of.path
|
207
|
+
# end
|
208
|
+
# unless of
|
209
|
+
# of = File.open(out_file, 'w+')
|
210
|
+
# end
|
211
|
+
# er = Erubis::Eruby.new(contents, :pattern => pat)
|
212
|
+
# of.write(er.result)
|
213
|
+
# of.close
|
214
|
+
# out_file
|
215
|
+
# end
|
data/lib/erbtex/version.rb
CHANGED
data/lib/erbtex.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
-
|
1
|
+
# Conditional added to prevent running bundler/setup twice when it already has
|
2
|
+
# erbtex in the LOAD_PATH. Failure to do this was causing bundler to setup for
|
3
|
+
# the wrong Gemfile if it was run in the development directory of another gem,
|
4
|
+
# for example, ydl. This only happened on saturn for some reason that I don't
|
5
|
+
# understand, but this kludge made it work.
|
2
6
|
|
7
|
+
require 'bundler/setup' if $LOAD_PATH.none? { |p| p =~ /erbtex/ }
|
8
|
+
|
9
|
+
require 'shellwords'
|
3
10
|
require 'erubis'
|
4
11
|
|
5
12
|
require 'erbtex/version'
|
6
13
|
require 'erbtex/command_line'
|
7
14
|
require 'erbtex/find_binary'
|
8
15
|
require 'erbtex/runner'
|
9
|
-
|
10
|
-
require 'byebug'
|
@@ -0,0 +1,146 @@
|
|
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_cmds =
|
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
|
30
|
+
\\input{junk.tex} \\print these \\items \\end not_a_file
|
31
|
+
)
|
32
|
+
@argv_with_file_cmds =
|
33
|
+
%w(
|
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
|
41
|
+
\\input{junk.tex} \\print these \\items \\end not_a_file
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'parse command line with file name' do
|
46
|
+
cl = CommandLine.new(@argv_with_file)
|
47
|
+
expect(cl.erbtex_name).to eq('erbtex')
|
48
|
+
expect(cl.tex_program).to eq('pdflatex')
|
49
|
+
expect(cl.input_file).to eq('file_name.tex.erb')
|
50
|
+
expect(cl.tex_command).to eq(<<~'EOS'.tr("\n", ' ').strip)
|
51
|
+
pdflatex -draftmode -enc -etex -file-line-error -fmt junk -halt-on-error
|
52
|
+
-ini -interaction batchmode -ipc -ipc-start -jobname junk -kpathsea-debug 8
|
53
|
+
-mktex tex -mltex -nomktex tfm
|
54
|
+
-ouptput-comment This\ is\ a\ long\ comment
|
55
|
+
-output-directory \~/texmf/tex -parse-first-line -progname pdflatex
|
56
|
+
-recorder -shell-escape -src-specials cr,display,hbox,math,par
|
57
|
+
-translate-file willy -version \&myformat file_name.tex.erb
|
58
|
+
EOS
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'parse command line with TeX commands' do
|
62
|
+
cl = CommandLine.new(@argv_with_cmds)
|
63
|
+
expect(cl.erbtex_name).to eq('erbtex')
|
64
|
+
expect(cl.tex_program).to eq('pdflatex')
|
65
|
+
expect(cl.input_file).to be_nil
|
66
|
+
expect(cl.tex_command).to eq(<<~'EOS'.tr("\n", ' ').strip)
|
67
|
+
pdflatex -draftmode -enc -etex -file-line-error -fmt junk -halt-on-error
|
68
|
+
-ini -interaction batchmode -ipc -ipc-start -jobname junk -kpathsea-debug 8
|
69
|
+
-mktex tex -mltex -nomktex tfm
|
70
|
+
-ouptput-comment This\ is\ a\ long\ comment
|
71
|
+
-output-directory \~/texmf/tex -parse-first-line -progname pdflatex
|
72
|
+
-recorder -shell-escape -src-specials cr,display,hbox,math,par
|
73
|
+
-translate-file willy -version \&myformat
|
74
|
+
\\input\{junk.tex\} \\print these \\items \\end not_a_file
|
75
|
+
EOS
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'parse command line with a file name and TeX commands' do
|
79
|
+
cl = CommandLine.new(@argv_with_file_cmds)
|
80
|
+
expect(cl.erbtex_name).to eq('erbtex')
|
81
|
+
expect(cl.tex_program).to eq('pdflatex')
|
82
|
+
expect(cl.input_file).to eq('file_name')
|
83
|
+
expect(cl.tex_command).to eq(<<~'EOS'.tr("\n", ' ').strip)
|
84
|
+
pdflatex -draftmode -enc -etex -file-line-error -fmt junk -halt-on-error
|
85
|
+
-ini -interaction batchmode -ipc -ipc-start -jobname junk -kpathsea-debug 8
|
86
|
+
-mktex tex -mltex -nomktex tfm
|
87
|
+
-ouptput-comment This\ is\ a\ long\ comment
|
88
|
+
-output-directory \~/texmf/tex -parse-first-line -progname pdflatex
|
89
|
+
-recorder -shell-escape -src-specials cr,display,hbox,math,par
|
90
|
+
-translate-file willy -version \&myformat
|
91
|
+
\\input\{junk.tex\} \\print these \\items \\end not_a_file
|
92
|
+
file_name
|
93
|
+
EOS
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'expand input file' do
|
98
|
+
before :all do
|
99
|
+
unless Dir.exist?('tmp')
|
100
|
+
FileUtils.mkdir_p('tmp')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
before :each do
|
105
|
+
FileUtils.rm_f Dir.glob('tmp/*')
|
106
|
+
end
|
107
|
+
|
108
|
+
after :all do
|
109
|
+
FileUtils.rm_rf('tmp')
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'expand file name with no extension and .tex existing' do
|
113
|
+
FileUtils.touch('tmp/junk.tex')
|
114
|
+
expect(CommandLine.expand_input_file('tmp/junk')).to eq('tmp/junk.tex')
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'expand file name with no extension and .tex.erb existing' do
|
118
|
+
FileUtils.touch('tmp/junk.tex.erb')
|
119
|
+
expect(CommandLine.expand_input_file('tmp/junk'))
|
120
|
+
.to eq('tmp/junk.tex.erb')
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'expand file name with no extension and .erb existing' do
|
124
|
+
FileUtils.touch('tmp/junk.erb')
|
125
|
+
expect(CommandLine.expand_input_file('tmp/junk'))
|
126
|
+
.to eq('tmp/junk.erb')
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'expand file name with .tex extension and existing' do
|
130
|
+
FileUtils.touch('tmp/junk.tex')
|
131
|
+
expect(CommandLine.expand_input_file('tmp/junk'))
|
132
|
+
.to eq('tmp/junk.tex')
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'expand file name with .tex extension and not existing' do
|
136
|
+
expect(CommandLine.expand_input_file('tmp/junk.tex'))
|
137
|
+
.to eq('tmp/junk.tex')
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'expand file name with funny extension and not existing' do
|
141
|
+
expect(CommandLine.expand_input_file('tmp/junk.arb'))
|
142
|
+
.to eq('tmp/junk.arb')
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ErbTeX
|
4
|
+
describe 'FindExecutable' do
|
5
|
+
# Here we set up the situation as we expect it to be after
|
6
|
+
# installation. There is a "real" pdflatex executable binary and
|
7
|
+
# there is one that is just a link to our script, the "fake" binary.
|
8
|
+
# The fake binary is earlier in PATH than the real binary, and we want
|
9
|
+
# this function, when fed the name of the fake binary to deduce the
|
10
|
+
# name of the real binary.
|
11
|
+
before :all do
|
12
|
+
# Create a "fake" ruby script named pdflatex
|
13
|
+
@fake_dir = File.dirname(File.absolute_path(__FILE__)) + '/fake_bin'
|
14
|
+
FileUtils.mkdir(@fake_dir) unless File.exist?(@fake_dir)
|
15
|
+
@fake_binary = @fake_dir + '/pdflatex'
|
16
|
+
@erbtex = @fake_dir + '/erbtex'
|
17
|
+
FileUtils.touch(@erbtex)
|
18
|
+
FileUtils.chmod(0700, @erbtex)
|
19
|
+
FileUtils.rm_rf(@fake_binary) if File.exist?(@fake_binary)
|
20
|
+
FileUtils.ln_s(@erbtex, @fake_binary)
|
21
|
+
|
22
|
+
# Point to "real" pdflatex to find
|
23
|
+
@real_binary = '/usr/bin/pdflatex'
|
24
|
+
@real_dir = '/usr/bin'
|
25
|
+
|
26
|
+
# Put the fake dir on the PATH before the real dir
|
27
|
+
ENV['PATH'] = @fake_dir + ':' + @real_dir + ':' + ENV['PATH']
|
28
|
+
end
|
29
|
+
|
30
|
+
after :all do
|
31
|
+
FileUtils.rm_rf(@fake_dir)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should find the real executable from fake' do
|
35
|
+
expect(ErbTeX.find_executable(@fake_binary)).to eq @real_binary
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should find the real executable from erbtex' do
|
39
|
+
expect(ErbTeX.find_executable(@erbtex)).to eq @real_binary
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require 'erbtex'
|
5
|
+
|
6
|
+
require 'pry'
|
7
|
+
require 'byebug'
|
8
|
+
|
9
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
10
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
11
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
12
|
+
# loaded once.
|
13
|
+
#
|
14
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.run_all_when_everything_filtered = true
|
17
|
+
config.filter_run :focus
|
18
|
+
|
19
|
+
config.raise_errors_for_deprecations!
|
20
|
+
|
21
|
+
# Run specs in random order to surface order dependencies. If you find an
|
22
|
+
# order dependency and want to debug it, you can fix the order by providing
|
23
|
+
# the seed, which is printed after each run.
|
24
|
+
# --seed 1234
|
25
|
+
config.order = 'random'
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erbtex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel E. Doherty
|
@@ -53,7 +53,63 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-doc
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-byebug
|
57
113
|
requirement: !ruby/object:Gem::Requirement
|
58
114
|
requirements:
|
59
115
|
- - ">="
|
@@ -74,54 +130,33 @@ description: |-
|
|
74
130
|
email: ded-erbtex@ddoherty.net
|
75
131
|
executables:
|
76
132
|
- erbtex
|
77
|
-
- etex
|
78
|
-
- latex
|
79
|
-
- lualatex
|
80
|
-
- luatex
|
81
|
-
- pdfetex
|
82
|
-
- pdflatex
|
83
|
-
- pdftex
|
84
|
-
- pslatex
|
85
|
-
- tex
|
86
|
-
- xelatex
|
87
|
-
- xetex
|
88
133
|
extensions: []
|
89
134
|
extra_rdoc_files: []
|
90
135
|
files:
|
136
|
+
- ".bundle/config"
|
91
137
|
- ".gitignore"
|
92
138
|
- Gemfile
|
93
139
|
- Gemfile.lock
|
94
140
|
- LICENCE
|
95
|
-
- README.
|
141
|
+
- README.org
|
96
142
|
- Rakefile
|
97
143
|
- bin/erbtex
|
98
|
-
- bin/etex
|
99
|
-
- bin/latex
|
100
|
-
- bin/lualatex
|
101
|
-
- bin/luatex
|
102
|
-
- bin/pdfetex
|
103
|
-
- bin/pdflatex
|
104
|
-
- bin/pdftex
|
105
|
-
- bin/pslatex
|
106
|
-
- bin/tex
|
107
|
-
- bin/xelatex
|
108
|
-
- bin/xetex
|
109
144
|
- docs/NOTES.org
|
110
145
|
- erbtex.gemspec
|
111
146
|
- examples/TrigTable.tex
|
112
147
|
- examples/TrigTable2.tex
|
113
148
|
- examples/dms.rb
|
114
|
-
- examples/roots.tex
|
149
|
+
- examples/roots.tex.erb
|
115
150
|
- examples/testbind.rb
|
116
|
-
- examples/testbind.tex
|
151
|
+
- examples/testbind.tex.erb
|
117
152
|
- lib/erbtex.rb
|
118
153
|
- lib/erbtex/command_line.rb
|
119
154
|
- lib/erbtex/find_binary.rb
|
120
155
|
- lib/erbtex/runner.rb
|
121
156
|
- lib/erbtex/version.rb
|
122
|
-
-
|
123
|
-
-
|
124
|
-
-
|
157
|
+
- spec/lib/command_line_spec.rb
|
158
|
+
- spec/lib/find_executable_spec.rb
|
159
|
+
- spec/spec_helper.rb
|
125
160
|
homepage: ''
|
126
161
|
licenses: []
|
127
162
|
metadata: {}
|
@@ -141,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
176
|
version: '0'
|
142
177
|
requirements: []
|
143
178
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.
|
179
|
+
rubygems_version: 2.6.13
|
145
180
|
signing_key:
|
146
181
|
specification_version: 4
|
147
182
|
summary: Preprocesses TeX and LaTeX files with erubis for ruby.
|