awhyte-rtex 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/rtex CHANGED
@@ -41,12 +41,12 @@ opts = OptionParser.new do |opts|
41
41
  STDERR.puts "Could not find application at #{path}"
42
42
  exit 1
43
43
  end
44
- plugin_path = File.join(plugins, 'rtex')
45
- FileUtils.cp_r(File.dirname(__FILE__) << '/..', plugin_path)
46
- %w(Rakefile Manifest.txt bin tasks).each do |prune|
47
- FileUtils.rm_rf(File.join(plugin_path, prune)) rescue nil
48
- end
49
- STDERR.puts "Installed at #{plugin_path}"
44
+
45
+ dest_dir = FileUtils.mkdir_p(File.join(plugins, 'rtex'))
46
+ plugin_file = File.join(File.dirname(__FILE__), "..", "rails", "init.rb")
47
+ FileUtils.cp plugin_file, dest_dir
48
+
49
+ STDERR.puts "Installed at #{dest_dir}"
50
50
  exit
51
51
  end
52
52
 
@@ -51,6 +51,8 @@ module RTeX
51
51
  # [+:tmpdir+] Location of temporary directory (default: +Dir.getwd+)
52
52
  # [+:shell_redirect+] Option redirection for shell output,
53
53
  # e.g. +"> /dev/null 2>&1"+ (default: +nil+).
54
+ # [+:command_prefix+] String (or array) of environment variable settings
55
+ # for the +:processor+ and +:preprocessor+ commands.
54
56
  #
55
57
  def initialize(content, options={})
56
58
  @options = self.class.options.merge(options)
@@ -115,10 +117,13 @@ module RTeX
115
117
  :processor => 'pdflatex',
116
118
  :shell_redirect => nil,
117
119
  :tex_inputs => nil,
120
+ :command_prefix => nil,
118
121
  :tempdir => Dir.getwd # Current directory unless otherwise set
119
122
  }
120
123
  end
121
124
 
125
+ attr_reader :options
126
+
122
127
  private
123
128
 
124
129
  # Verify existence of executable in search path
@@ -155,16 +160,20 @@ module RTeX
155
160
  File.open(source_file, 'wb') { |f| f.puts input }
156
161
  end
157
162
 
163
+ def command(executable)
164
+ "#{environment_vars}#{executable} --output-directory='#{tempdir}' --interaction=nonstopmode '#{File.basename(source_file)}' #{@options[:shell_redirect]}"
165
+ end
166
+
158
167
  # Run LaTeX pre-processing step on the source file
159
168
  def preprocess!
160
- unless `#{environment_vars}#{preprocessor} --output-directory=#{tempdir} --interaction=nonstopmode '#{File.basename(source_file)}' #{@options[:shell_redirect]}`
169
+ unless `#{command(preprocessor)}`
161
170
  raise GenerationError, "Could not preprocess using #{preprocessor}"
162
171
  end
163
172
  end
164
173
 
165
174
  # Run LaTeX output generation step on the source file
166
175
  def process!
167
- unless `#{environment_vars}#{tex_inputs} #{processor} --output-directory=#{tempdir} --interaction=nonstopmode '#{File.basename(source_file)}' #{@options[:shell_redirect]}`
176
+ unless `#{command(processor)}`
168
177
  raise GenerationError, "Could not generate PDF using #{processor}"
169
178
  end
170
179
  end
@@ -197,6 +206,14 @@ module RTeX
197
206
  end
198
207
  end
199
208
 
209
+ # Produce a list of environment variables to prefix the process and
210
+ # preprocess commands.
211
+ #
212
+ def environment_vars
213
+ list = [tex_inputs, command_prefix].compact
214
+ list.empty? ? "" : list.join(" ") + " "
215
+ end
216
+
200
217
  # Compile list of extra directories to search for LaTeX packages, using
201
218
  # the file or array of files held in the :tex_inputs option.
202
219
  #
@@ -209,12 +226,24 @@ module RTeX
209
226
  end
210
227
  end
211
228
 
212
- # Produce a list of environment variables to prefix the process and
213
- # preprocess commands.
229
+ # Occasionally it is useful to be able to prefix the LaTeX commands with
230
+ # extra environment variables, for example the +rlatex+ program,
214
231
  #
215
- def environment_vars
216
- list = [tex_inputs].compact
217
- list.empty? ? "" : list.join(" ") + " "
232
+ # LATEXPRG=pdflatex rlatex [FILE...]
233
+ #
234
+ # which runs the command +pdflatex+ repeatedly until LaTeX is satisfied all
235
+ # cross-references etc. are stable.
236
+ #
237
+ # To achieve this with RTeX, use
238
+ #
239
+ # :processor => "rlatex", :command_prefix => "LATEXPRG=pdflatex"
240
+ #
241
+ def command_prefix
242
+ if prefix = @options[:command_prefix]
243
+ prefix = [prefix].flatten.join(" ")
244
+ else
245
+ nil
246
+ end
218
247
  end
219
248
 
220
249
  def source_file
@@ -65,7 +65,7 @@ module RTeX
65
65
 
66
66
  MAJOR = 2
67
67
  MINOR = 1
68
- TINY = 1
68
+ TINY = 3
69
69
 
70
70
  # The current version as a Version instance
71
71
  CURRENT = new(MAJOR, MINOR, TINY)
@@ -74,4 +74,4 @@ module RTeX
74
74
 
75
75
  end
76
76
 
77
- end
77
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rtex}
5
- s.version = "2.1.2"
5
+ s.version = "2.1.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Bruce Williams, Wiebe Cazemier"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awhyte-rtex
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruce Williams, Wiebe Cazemier