erbtex 0.4.2 → 0.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f067b2e9d4e0a83eb0a956c21623146a1a0bc5471ebc6b0c2f1f6d623c2536b4
4
- data.tar.gz: 1cf76c21cdd007c9c2d19339ac8d85bd67a094119788f5d3755997b41a16301c
3
+ metadata.gz: da849bbae335cabdeb22f9817d5408660b1d37ed1036eba721ce8bdace2668f2
4
+ data.tar.gz: 4e933a21dfa948f00151d1cd695f425dfb17aec6f1ac1d940dd68d32799229d6
5
5
  SHA512:
6
- metadata.gz: af2c459fdb7d898bce5857bcd54513db08bc16b10362aa14ccff792c628d9f25728985b3efe800a4c5f46b46839d155cbf65014f5c573cfc5ad8478aa134bcb2
7
- data.tar.gz: c48ca28f0cd277621ab711a973b69dbcd3d72a7b3bc6e2f2372e022be13bda12e84e6a420dfcd1cead428be08c9f25f62e5c08cc69243d2f7c9b92b8d68eb181
6
+ metadata.gz: b1cf7577a154c728e92b44d555e464b62ff714ddcccad23744f1d5dc0b53ddcbc88d43e31698aecc2a1b4494bcf0660e1677c42c70998bcc76da743a5aa893c5
7
+ data.tar.gz: '051332985184a47f5515dda043d598bf835488d0d812dd753e9ec05cdaafdeebf51279bfdc1fb7307b97ac8155d3007f8572340175ec1148bc80a13d2fee557c'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- erbtex (0.4.2)
4
+ erbtex (0.4.3)
5
5
  erubis
6
6
  fat_core
7
7
 
@@ -19,7 +19,7 @@ GEM
19
19
  damerau-levenshtein (1.3.1)
20
20
  diff-lcs (1.3)
21
21
  erubis (2.7.0)
22
- fat_core (4.5.0)
22
+ fat_core (4.6.0)
23
23
  activesupport
24
24
  damerau-levenshtein
25
25
  i18n (1.6.0)
data/erbtex.gemspec CHANGED
@@ -7,15 +7,14 @@ Gem::Specification.new do |gem|
7
7
  gem.version = ErbTeX::VERSION
8
8
  gem.platform = Gem::Platform::RUBY
9
9
  gem.date = %q{2012-05-13}
10
- gem.homepage = ''
10
+ gem.homepage = 'https://github.com/ddoherty03/erbtex'
11
11
  gem.authors = ['Daniel E. Doherty']
12
- gem.email = %q{ded-erbtex@ddoherty.net}
12
+ gem.email = %q{ded@ddoherty.net}
13
13
  gem.summary = %q{Preprocesses TeX and LaTeX files with erubis for ruby.}
14
- gem.description = %q{Create a local link called pdflatex to erbtex and it will
15
- act just like pdflatex except that it will process ruby fragments
16
- between {: and :} markers, greatly expanding the ability to generate
14
+ gem.description = %q{erbtex will act just like pdflatex except that it will
15
+ process ruby fragments between {: and :} markers,
16
+ greatly expanding the ability to generate
17
17
  automated TeX and LaTeX documents.}
18
-
19
18
  gem.files = `git ls-files`.split("\n")
20
19
  gem.files.delete_if { |f| f =~ /\.(log|etc|aux|etx|pdf|gem|tmp)$/ }
21
20
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
data/examples/dms.rb CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  # A class for maipulating angles expressed as degreed, minutes,
4
4
  # and seconds.
5
-
6
5
  class DMS
7
6
  include Comparable
8
7
 
@@ -10,21 +9,21 @@ class DMS
10
9
 
11
10
  @@precision = 4
12
11
 
13
- def initialize(d, m = 0, s = 0.0)
14
- @degrees = d.to_i
15
- @minutes = m.to_i
16
- @seconds = s.to_f
17
- self.normalize
12
+ def initialize(deg, min = 0, sec = 0.0)
13
+ @degrees = deg.to_i
14
+ @minutes = min.to_i
15
+ @seconds = sec.to_f
16
+ normalize
18
17
  end
19
18
 
20
- def DMS.from_radians(r)
21
- if r < 0
22
- r = -r
19
+ def self.from_radians(rad)
20
+ if rad < 0
21
+ rad = -rad
23
22
  sign = -1
24
23
  else
25
24
  sign = 1
26
25
  end
27
- deg = r * (360.0 / (2.0 * Math::PI))
26
+ deg = rad * (360.0 / (2.0 * Math::PI))
28
27
  degrees = deg.floor
29
28
  min = (deg - degrees) * 60.0
30
29
  minutes = min.floor
@@ -32,10 +31,10 @@ class DMS
32
31
  DMS.new(degrees, minutes, seconds)
33
32
  end
34
33
 
35
- def DMS.precision=(p)
34
+ def self.precision=(p)
36
35
  @@precision = p
37
36
  end
38
-
37
+
39
38
  def to_s
40
39
  "#{@degrees}* #{@minutes}' %0.*f''" % [@@precision, @seconds]
41
40
  end
@@ -45,14 +44,14 @@ class DMS
45
44
  end
46
45
 
47
46
  def to_radians
48
- self.to_f * ((2.0 * Math::PI) / 360.0)
47
+ to_f * ((2.0 * Math::PI) / 360.0)
49
48
  end
50
49
 
51
50
  # If degrees are at well-known values, eppress as radians
52
51
  # symbolically, using TeX notation
53
52
  def to_radians_tex
54
53
  unless @seconds == 0.0 and @minutes == 0
55
- return "$%0.*f$" % [@@precision, self.to_radians]
54
+ return '$%0.*f$' % [@@precision, to_radians]
56
55
  end
57
56
 
58
57
  # This gets deg to 0 <= x <= 360, even for negative
@@ -60,51 +59,50 @@ class DMS
60
59
  deg = @degrees.divmod(360)[1]
61
60
  case deg
62
61
  when 0
63
- "$0$"
62
+ '$0$'
64
63
  when 30
65
- "$\\pi/6$"
64
+ '$\\pi/6$'
66
65
  when 60
67
- "$\\pi/3$"
66
+ '$\\pi/3$'
68
67
  when 90
69
- "$\\pi/2$"
68
+ '$\\pi/2$'
70
69
  when 120
71
- "$2\\pi/2$"
70
+ '$2\\pi/2$'
72
71
  when 150
73
- "$5\\pi/6$"
72
+ '$5\\pi/6$'
74
73
  when 180
75
- "$\\pi$"
74
+ '$\\pi$'
76
75
  when 210
77
- "$7\\pi/6$"
76
+ '$7\\pi/6$'
78
77
  when 240
79
- "$4\\pi/3$"
78
+ '$4\\pi/3$'
80
79
  when 270
81
- "$3\\pi/2$"
80
+ '$3\\pi/2$'
82
81
  when 300
83
- "5\\pi/3$"
82
+ '5\\pi/3$'
84
83
  when 330
85
- "11\\pi/6$"
84
+ '11\\pi/6$'
86
85
  when 360
87
- "$2\\pi$"
86
+ '$2\\pi$'
88
87
  else
89
- "$%0.*f$" % [@@precision, self.to_radians]
88
+ '$%0.*f$' % [@@precision, to_radians]
90
89
  end
91
90
  end
92
-
91
+
93
92
  def to_tex
94
- # "$#{@degrees}^\\circ #{@minutes}' %0.*f''$" % [@@precision, @seconds] #"
95
93
  "$%02d^\\circ~%02d'~%02.*f''$" % [@degrees, @minutes, @@precision, @seconds] #"
96
94
  end
97
-
95
+
98
96
  def -@
99
97
  DMS.new(-@degrees, @minutes, @seconds)
100
98
  end
101
-
99
+
102
100
  def +@
103
101
  DMS.new(@degrees, @minutes, @seconds)
104
102
  end
105
103
 
106
104
  def <=>(other)
107
- self.to_radians <=> other.to_radians
105
+ to_radians <=> other.to_radians
108
106
  end
109
107
 
110
108
  def +(other)
@@ -128,34 +126,34 @@ class DMS
128
126
  end
129
127
 
130
128
  def sin
131
- Math.sin(self.to_radians)
129
+ Math.sin(to_radians)
132
130
  end
133
-
131
+
134
132
  def cos
135
- Math.cos(self.to_radians)
133
+ Math.cos(to_radians)
136
134
  end
137
-
135
+
138
136
  def tan
139
- Math.tan(self.to_radians)
137
+ Math.tan(to_radians)
140
138
  end
141
-
139
+
142
140
  def sec
143
- (1.0 / Math.cos(self.to_radians))
141
+ (1.0 / Math.cos(to_radians))
144
142
  end
145
-
143
+
146
144
  def csc
147
- (1.0 / Math.sin(self.to_radians))
145
+ (1.0 / Math.sin(to_radians))
148
146
  end
149
-
147
+
150
148
  def cotan
151
- (1.0 / Math.tan(self.to_radians))
149
+ (1.0 / Math.tan(to_radians))
152
150
  end
153
-
151
+
154
152
  # Ensure that seconds and minutes are 0 <= x < 60.
155
153
  # After normalization, only degrees can be negative,
156
154
  # which will represent a negative quantity
157
155
  def normalize
158
- q, r = @seconds.divmod(60.0)
156
+ q, r = @seconds.divmod(60.0)
159
157
  @seconds = r
160
158
  @minutes += q
161
159
  q, r = @minutes.divmod(60)
@@ -164,22 +162,22 @@ class DMS
164
162
  end
165
163
  end
166
164
 
167
- class Fixnum
165
+ class Integer
168
166
  alias times *
169
- def *(dms)
170
- case dms
167
+ def *(other)
168
+ case other
171
169
  when DMS
172
- dms * self
170
+ other * self
173
171
  else
174
- self.times(dms)
172
+ times(other)
175
173
  end
176
174
  end
177
175
  end
178
-
176
+
179
177
  if __FILE__ == $0
180
- print "Fifty seconds: #{DMS.new(0, 0, 50).to_radians}\n"
181
- print "One minute: #{DMS.new(0, 1, 0).to_radians}\n"
182
- print "Fifty seconds: #{DMS.new(0, 0, 50).to_f}\n"
183
- print "One minute: #{DMS.new(0, 1, 0).to_f}\n"
184
- print "#{DMS.from_radians(Math::PI / 2.0)}\n"
178
+ print "Fifty seconds in radians: #{DMS.new(0, 0, 50).to_radians}\n"
179
+ print "One minute in radians: #{DMS.new(0, 1, 0).to_radians}\n"
180
+ print "Fifty seconds in degrees: #{DMS.new(0, 0, 50).to_f}\n"
181
+ print "One minute in degrees: #{DMS.new(0, 1, 0).to_f}\n"
182
+ print "One-half PI radians in DMS: #{DMS.from_radians(Math::PI / 2.0)}\n"
185
183
  end
data/lib/erbtex.rb CHANGED
@@ -13,3 +13,4 @@ require 'fat_core'
13
13
  require 'erbtex/version'
14
14
  require 'erbtex/command_line'
15
15
  require 'erbtex/runner'
16
+ require 'erbtex/file_names'
@@ -59,7 +59,7 @@ module ErbTeX
59
59
  # assumed to be the name of the input_file.
60
60
  @input_file = nil
61
61
  if !argv.empty? && argv[-1] !~ /\A[-&]/
62
- @input_file = CommandLine.expand_input_file(argv.pop)
62
+ @input_file = ErbTeX.expand_input_file(argv.pop)
63
63
  end
64
64
 
65
65
  # What remains in argv should be the tex program's '-options', which
@@ -75,31 +75,6 @@ module ErbTeX
75
75
  "#{tex_file}"
76
76
  .strip.squeeze(' ')
77
77
  end
78
-
79
- # Return the name of the input file based on the name given in the command
80
- # line. Try to find the right extension for the input file if none is given.
81
- def self.expand_input_file(input_file)
82
- return '' if input_file.blank?
83
-
84
- md = %r{\A(.*)(\.[\w.]+)?\z}.match(input_file)
85
- if md
86
- input_base = md[1]
87
- input_ext = md[2]
88
- end
89
- if input_ext.nil?
90
- if File.exist?("#{input_base}.tex.erb")
91
- "#{input_base}.tex.erb"
92
- elsif File.exist?("#{input_base}.tex")
93
- "#{input_base}.tex"
94
- elsif File.exist?("#{input_base}.erb")
95
- "#{input_base}.erb"
96
- else
97
- input_base
98
- end
99
- else
100
- input_base
101
- end
102
- end
103
78
  end
104
79
  end
105
80
 
@@ -0,0 +1,64 @@
1
+ module ErbTeX
2
+ # Given an arbitrary file name, parse it into its components in one go. It
3
+ # separates three parts of a filename: (1) the directory, if any, (2) the
4
+ # base name (including such things as .configrc) which is considered a base
5
+ # name rather than an extension, and (3) any extension, including a compound
6
+ # extension such as .tex.erb
7
+ def self.parse_file_name(path)
8
+ fn_re = %r{\A(?<dir>([^\/]*\/)*) (?<base>.?[^\/.]*) (?<ext>\.[\w.]+)?}x
9
+ md = fn_re.match(path)
10
+ { dir: md[:dir], base: md[:base], ext: md[:ext] }
11
+ end
12
+
13
+ # Return the name of the input file based on the name given in the command
14
+ # line. Try to add the right extension for the input file if none is given.
15
+ def self.expand_input_file(input_file)
16
+ return '' if input_file.blank?
17
+
18
+ fn = ErbTeX.parse_file_name(input_file)
19
+ input_dir = fn[:dir]
20
+ input_base = fn[:base]
21
+ input_ext = fn[:ext]
22
+ if input_ext.nil?
23
+ path = "#{input_dir}#{input_base}"
24
+ if File.exist?("#{path}.tex.erb")
25
+ "#{path}.tex.erb"
26
+ elsif File.exist?("#{path}.tex")
27
+ "#{path}.tex"
28
+ elsif File.exist?("#{path}.erb")
29
+ "#{path}.erb"
30
+ else
31
+ input_base
32
+ end
33
+ else
34
+ input_file
35
+ end
36
+ end
37
+
38
+ # Map the extension of the erbtex input file to the extension of the erubis
39
+ # output file in the following order of preference:
40
+ #
41
+ # base.tex.erb -> base.tex
42
+ # base.tex -> base.etx
43
+ # base.erb -> base.tex
44
+ # base.* -> base.tex
45
+ def self.out_file_name(in_file)
46
+ fn_parts = parse_file_name(in_file)
47
+ in_base = fn_parts[:base]
48
+ in_ext = fn_parts[:ext]
49
+
50
+ out_ext =
51
+ case in_ext
52
+ when '.tex.erb'
53
+ '.tex'
54
+ when '.tex'
55
+ '.etx'
56
+ when '.erb'
57
+ '.tex'
58
+ else
59
+ '.tex'
60
+ end
61
+ # Do not include the input directory, only output to current directory.
62
+ "#{in_base}#{out_ext}"
63
+ end
64
+ end
data/lib/erbtex/runner.rb CHANGED
@@ -4,13 +4,15 @@ require 'English'
4
4
 
5
5
  # Name space module for erbtex program.
6
6
  module ErbTeX
7
+ # Perform the erubis pre-processing and the TeX processing on the input
8
+ # file.
7
9
  def self.run(cmd_line)
8
10
  report_version && exit(0) if cmd_line.print_version
9
11
  report_help && exit(0) if cmd_line.print_help
10
12
 
11
- tex_dir = input_dir(cmd_line.input_file)
12
- tex_file = erb_to_tex(cmd_line.input_file, tex_dir) if cmd_line.input_file
13
- run_tex(cmd_line.tex_command(tex_file), tex_dir)
13
+ in_dir = parse_file_name(cmd_line.input_file)[:dir]
14
+ tex_file = erb_to_tex(cmd_line.input_file, in_dir) if cmd_line.input_file
15
+ run_tex(cmd_line.tex_command(tex_file), in_dir)
14
16
  end
15
17
 
16
18
  def self.report_version
@@ -26,6 +28,7 @@ module ErbTeX
26
28
  true
27
29
  end
28
30
 
31
+ # Display the help for erbtex.
29
32
  def self.report_help
30
33
  puts <<~HELP
31
34
  Usage: erbtex [erbtex_options] [tex_prog_args] [file]
@@ -49,44 +52,53 @@ module ErbTeX
49
52
  true
50
53
  end
51
54
 
52
- # Run the TeX program, adding add_dir to the front of TEXINPUTS, unless it is
53
- # already in TEXINPUTS.
54
- def self.run_tex(cmd, add_dir = nil)
55
+ # Run the TeX program on the erubis-processed output file, which is the
56
+ # input file to the TeX program. Return the exit status.
57
+ def self.run_tex(cmd, in_dir = nil)
58
+ # If the input file is located in another directory (in_dir), add that
59
+ # directory to TEXINPUTS if its not already there so that the input file
60
+ # can \include or \input files using relative file names.
55
61
  new_env = {}
56
- if add_dir
57
- add_dir = File.absolute_path(File.expand_path(add_dir))
62
+ if in_dir
63
+ in_dir = File.absolute_path(File.expand_path(in_dir))
64
+ ENV['TEXINPUTS'] ||= ''
58
65
  unless ENV['TEXINPUTS'].split(File::PATH_SEPARATOR)
59
66
  .reject { |p| p.strip.empty? }
60
- .any? { |p| add_dir == File.absolute_path(File.expand_path(p)) }
61
- new_env['TEXINPUTS'] = "#{add_dir}:#{ENV['TEXINPUTS']}"
67
+ .any? { |p| in_dir == File.absolute_path(File.expand_path(p)) }
68
+ new_env['TEXINPUTS'] = "#{in_dir}:#{ENV['TEXINPUTS']}"
62
69
  end
63
70
  end
64
- unless system(cmd)
71
+ # Call cmd with the environment augmented by possibly expanded TEXINPUTS
72
+ # environment variable.
73
+ unless system(new_env, cmd)
65
74
  warn "Call to '#{cmd}' failed."
66
75
  exit $CHILD_STATUS
67
76
  end
77
+ # Run a second time unless its latexmk
78
+ unless cmd =~ /\A *latexmk/
79
+ unless system(new_env, cmd)
80
+ warn "Call to '#{cmd}' failed."
81
+ exit $CHILD_STATUS
82
+ end
83
+ end
68
84
  $CHILD_STATUS
69
85
  end
70
86
 
71
- def self.input_dir(in_file)
72
- return nil unless in_file
73
-
74
- in_file_absolute = File.absolute_path(File.expand_path(in_file))
75
- in_file_absolute[%r{\A(.*/)([^/.]+)(\.[\w.]+)\z}, 1]
76
- end
77
-
78
- # Pre-process the input file with erubis, adding the add_dir to the front of
79
- # the ruby load path if its not already in the load path. Return the name of
80
- # the processed file.
81
- def self.erb_to_tex(in_file, add_dir = nil)
82
- if File.exist?(add_dir)
83
- add_dir = File.absolute_path(File.expand_path(add_dir))
87
+ # Pre-process the input file with erubis, adding the in_dir to the front of
88
+ # the ruby load path if its not already in the load path so that requires in
89
+ # the input file can be found if they are in the in_dir. Return the name of
90
+ # the output file.
91
+ def self.erb_to_tex(in_file, in_dir = nil)
92
+ # Add input to ruby LOAD_PATH, $:,if its not already there.
93
+ if File.exist?(in_dir)
94
+ in_dir = File.absolute_path(File.expand_path(in_dir))
84
95
  unless $LOAD_PATH
85
- .any? { |p| add_dir == File.absolute_path(File.expand_path(p)) }
86
- $LOAD_PATH.unshift(add_dir)
96
+ .any? { |p| in_dir == File.absolute_path(File.expand_path(p)) }
97
+ $LOAD_PATH.unshift(in_dir)
87
98
  end
88
99
  end
89
100
 
101
+ # Read the input
90
102
  in_contents = nil
91
103
  File.open(in_file) do |f|
92
104
  in_contents = f.read
@@ -95,7 +107,7 @@ module ErbTeX
95
107
 
96
108
  pat = ENV['ERBTEX_PATTERN'] || '{: :}'
97
109
 
98
- out_file = out_file_name(in_file)
110
+ out_file = ErbTeX.out_file_name(in_file)
99
111
  File.open(out_file, 'w') do |f|
100
112
  er = ::Erubis::Eruby.new(in_contents, pattern: pat)
101
113
  f.write(er.result)
@@ -108,53 +120,4 @@ module ErbTeX
108
120
  warn "Erubis pre-processing failed: #{e}"
109
121
  exit 1
110
122
  end
111
-
112
- def self.out_file_name(in_file)
113
- in_file_absolute = File.absolute_path(File.expand_path(in_file))
114
- in_dir = File.dirname(in_file_absolute)
115
- in_base = File.basename(in_file_absolute)
116
- # Note that File.extname only gets the last extension. We want all
117
- # extensions following the basename, but we don't count a dot at the
118
- # beginning of a filename as introducing an extension. So, we cook our
119
- # own solution here with Regexp's.
120
- if in_base =~ /[^.](.[^.]+)+\z/
121
- in_ext = $1
122
- in_base = File.basename(in_base, in_ext)
123
- else
124
- in_ext = ''
125
- end
126
-
127
- out_ext = if in_ext.empty?
128
- if File.exist?("#{in_file}.tex.erb")
129
- '.tex'
130
- elsif File.exist?("#{in_file}.tex")
131
- '.etx'
132
- elsif File.exist?("#{in_file}.erb")
133
- '.tex'
134
- else
135
- '.tex'
136
- end
137
- else
138
- case in_ext
139
- when '.tex.erb'
140
- '.tex'
141
- when '.tex'
142
- '.etx'
143
- when '.erb'
144
- '.tex'
145
- else
146
- '.tex'
147
- end
148
- end
149
-
150
- # Find a writable directory, prefering the one the input file came
151
- # from, or the current directory, and a temp file as a last resort.
152
- if File.writable?(in_dir)
153
- File.join(in_dir, "#{in_base}#{out_ext}")
154
- elsif File.writable?('.')
155
- File.join('.', "#{in_base}#{out_ext}")
156
- else
157
- Tempfile.new([in_base, out_ext]).path
158
- end
159
- end
160
123
  end
@@ -1,3 +1,3 @@
1
1
  module ErbTeX
2
- VERSION = "0.4.2"
2
+ VERSION = '0.4.3'
3
3
  end
@@ -0,0 +1,23 @@
1
+ \documentclass{article}
2
+ \usepackage[mathbf]{euler}
3
+ \usepackage{longtable}
4
+
5
+ \begin{document}
6
+ \begin{longtable}[c]{r|r}
7
+ \hline\hline
8
+ \multicolumn{1}{c|}{\mathversion{bold}$x$}&
9
+ \multicolumn{1}{c}{\mathversion{bold}\rule{0pt}{12pt}$\sqrt{x}$}\\
10
+ \hline\hline
11
+ \endhead
12
+ \hline\hline
13
+ \endfoot
14
+
15
+ %% Here is the loop for the body of the table, which starts with
16
+ %% x one step beyond 0 and pre-computes some of the functions
17
+ {:0.upto(100).each do |x| :}
18
+ {:= "\\mathversion{bold}$%0.4f$" % x :}&
19
+ {:= "$%0.8f$" % Math.sqrt(x) :}\\
20
+ {:end:}
21
+ %% End the table and document---this version comes to 315 pages!
22
+ \end{longtable}
23
+ \end{document}
@@ -0,0 +1,23 @@
1
+ \documentclass{article}
2
+ \usepackage[mathbf]{euler}
3
+ \usepackage{longtable}
4
+
5
+ \begin{document}
6
+ \begin{longtable}[c]{r|r}
7
+ \hline\hline
8
+ \multicolumn{1}{c|}{\mathversion{bold}$x$}&
9
+ \multicolumn{1}{c}{\mathversion{bold}\rule{0pt}{12pt}$\sqrt{x}$}\\
10
+ \hline\hline
11
+ \endhead
12
+ \hline\hline
13
+ \endfoot
14
+
15
+ %% Here is the loop for the body of the table, which starts with
16
+ %% x one step beyond 0 and pre-computes some of the functions
17
+ {:0.upto(100).each do |x| :}
18
+ {:= "\\mathversion{bold}$%0.4f$" % x :}&
19
+ {:= "$%0.8f$" % Math.sqrt(x) :}\\
20
+ {:end:}
21
+ %% End the table and document---this version comes to 315 pages!
22
+ \end{longtable}
23
+ \end{document}
@@ -18,6 +18,16 @@ module ErbTeX
18
18
  -recorder -shell-escape -src-specials cr,display,hbox,math,par
19
19
  -translate-file willy -version &myformat file_name.tex.erb
20
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
+ )
21
31
  @argv_with_invoke_and_file =
22
32
  %w(
23
33
  --invoke=lualatex
@@ -69,6 +79,22 @@ module ErbTeX
69
79
  EOS
70
80
  end
71
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
+
72
98
  it 'parse command line with invoke and file name' do
73
99
  cl = CommandLine.new(@argv_with_invoke_and_file)
74
100
  expect(cl.erbtex_name).to eq('erbtex')
@@ -120,54 +146,5 @@ module ErbTeX
120
146
  EOS
121
147
  end
122
148
  end
123
-
124
- describe 'expand input file' do
125
- before :all do
126
- unless Dir.exist?('tmp')
127
- FileUtils.mkdir_p('tmp')
128
- end
129
- end
130
-
131
- before :each do
132
- FileUtils.rm_f Dir.glob('tmp/*')
133
- end
134
-
135
- after :all do
136
- FileUtils.rm_rf('tmp')
137
- end
138
-
139
- it 'expand file name with no extension and .tex existing' do
140
- FileUtils.touch('tmp/junk.tex')
141
- expect(CommandLine.expand_input_file('tmp/junk')).to eq('tmp/junk.tex')
142
- end
143
-
144
- it 'expand file name with no extension and .tex.erb existing' do
145
- FileUtils.touch('tmp/junk.tex.erb')
146
- expect(CommandLine.expand_input_file('tmp/junk'))
147
- .to eq('tmp/junk.tex.erb')
148
- end
149
-
150
- it 'expand file name with no extension and .erb existing' do
151
- FileUtils.touch('tmp/junk.erb')
152
- expect(CommandLine.expand_input_file('tmp/junk'))
153
- .to eq('tmp/junk.erb')
154
- end
155
-
156
- it 'expand file name with .tex extension and existing' do
157
- FileUtils.touch('tmp/junk.tex')
158
- expect(CommandLine.expand_input_file('tmp/junk'))
159
- .to eq('tmp/junk.tex')
160
- end
161
-
162
- it 'expand file name with .tex extension and not existing' do
163
- expect(CommandLine.expand_input_file('tmp/junk.tex'))
164
- .to eq('tmp/junk.tex')
165
- end
166
-
167
- it 'expand file name with funny extension and not existing' do
168
- expect(CommandLine.expand_input_file('tmp/junk.arb'))
169
- .to eq('tmp/junk.arb')
170
- end
171
- end
172
149
  end
173
150
  end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ module ErbTeX
4
+ describe 'expand input file' do
5
+ before :all do
6
+ unless Dir.exist?('tmp')
7
+ FileUtils.mkdir_p('tmp')
8
+ end
9
+ end
10
+
11
+ before :each do
12
+ FileUtils.rm_f Dir.glob('tmp/*')
13
+ end
14
+
15
+ after :all do
16
+ FileUtils.rm_rf('tmp')
17
+ end
18
+
19
+ it 'expand file name with no extension and .tex existing' do
20
+ FileUtils.touch('tmp/junk.tex')
21
+ expect(ErbTeX.expand_input_file('tmp/junk')).to eq('tmp/junk.tex')
22
+ end
23
+
24
+ it 'expand file name with no extension and .tex.erb existing' do
25
+ FileUtils.touch('tmp/junk.tex.erb')
26
+ expect(ErbTeX.expand_input_file('tmp/junk'))
27
+ .to eq('tmp/junk.tex.erb')
28
+ end
29
+
30
+ it 'expand file name with no extension and .erb existing' do
31
+ FileUtils.touch('tmp/junk.erb')
32
+ expect(ErbTeX.expand_input_file('tmp/junk'))
33
+ .to eq('tmp/junk.erb')
34
+ end
35
+
36
+ it 'expand file name with no extension and .tex existing' do
37
+ FileUtils.touch('tmp/junk.tex')
38
+ expect(ErbTeX.expand_input_file('tmp/junk'))
39
+ .to eq('tmp/junk.tex')
40
+ end
41
+
42
+ it 'expand file name with .tex extension and .tex existing' do
43
+ FileUtils.touch('tmp/junk.tex')
44
+ expect(ErbTeX.expand_input_file('tmp/junk.tex'))
45
+ .to eq('tmp/junk.tex')
46
+ end
47
+
48
+ it 'expand file name with .tex extension and not existing' do
49
+ FileUtils.rm_rf('tmp/junk.tex') if File.exist?('tmp/junk.tex')
50
+ expect(ErbTeX.expand_input_file('tmp/junk.tex'))
51
+ .to eq('tmp/junk.tex')
52
+ end
53
+
54
+ it 'expand file name with funny extension and not existing' do
55
+ expect(ErbTeX.expand_input_file('tmp/junk.arb'))
56
+ .to eq('tmp/junk.arb')
57
+ end
58
+ end
59
+ 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.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
@@ -137,11 +137,11 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: |-
140
- Create a local link called pdflatex to erbtex and it will
141
- act just like pdflatex except that it will process ruby fragments
142
- between {: and :} markers, greatly expanding the ability to generate
140
+ erbtex will act just like pdflatex except that it will
141
+ process ruby fragments between {: and :} markers,
142
+ greatly expanding the ability to generate
143
143
  automated TeX and LaTeX documents.
144
- email: ded-erbtex@ddoherty.net
144
+ email: ded@ddoherty.net
145
145
  executables:
146
146
  - erbtex
147
147
  extensions: []
@@ -165,11 +165,15 @@ files:
165
165
  - examples/testbind.tex
166
166
  - lib/erbtex.rb
167
167
  - lib/erbtex/command_line.rb
168
+ - lib/erbtex/file_names.rb
168
169
  - lib/erbtex/runner.rb
169
170
  - lib/erbtex/version.rb
171
+ - spec/example_files/roots.tex
172
+ - spec/example_files/roots.tex.erb
170
173
  - spec/lib/command_line_spec.rb
174
+ - spec/lib/file_names_spec.rb
171
175
  - spec/spec_helper.rb
172
- homepage: ''
176
+ homepage: https://github.com/ddoherty03/erbtex
173
177
  licenses: []
174
178
  metadata: {}
175
179
  post_install_message: