runtex 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/lib/Code_zum_Pluendern_rtex4newrtex.rb +275 -0
  2. data/lib/catch_output.rb +99 -0
  3. data/lib/runtex.rb +221 -0
  4. data/lib/runtex_bibtex.rb +111 -0
  5. data/lib/runtex_job_chain.rb +371 -0
  6. data/lib/runtex_latex.rb +373 -0
  7. data/lib/runtex_makeindex.rb +114 -0
  8. data/lib/runtex_pathes.yaml +59 -0
  9. data/lib/runtex_rail.rb +116 -0
  10. data/lib/runtex_splitindex.rb +78 -0
  11. data/lib/runtex_tool.rb +128 -0
  12. data/lppl.txt +416 -0
  13. data/readme +73 -0
  14. data/unittest/expected/test_bibliography_babelbib.debug1.txt +31 -0
  15. data/unittest/expected/test_bibliography_babelbib.debug2.txt +16 -0
  16. data/unittest/expected/test_bibliography_babelbib.tex.runtex_summary.txt +19 -0
  17. data/unittest/expected/test_bibliography_babelbib_1.txt +15 -0
  18. data/unittest/expected/test_bibliography_babelbib_2.txt +11 -0
  19. data/unittest/expected/test_bibliography_plain.debug1.txt +45 -0
  20. data/unittest/expected/test_bibliography_plain.debug2.txt +16 -0
  21. data/unittest/expected/test_bibliography_plain.tex.runtex_summary.txt +18 -0
  22. data/unittest/expected/test_bibliography_plain_1.txt +19 -0
  23. data/unittest/expected/test_bibliography_plain_2.txt +11 -0
  24. data/unittest/expected/test_error.debug1.txt +22 -0
  25. data/unittest/expected/test_error.debug2.txt +12 -0
  26. data/unittest/expected/test_error.tex.runtex_summary.txt +15 -0
  27. data/unittest/expected/test_error_1.txt +15 -0
  28. data/unittest/expected/test_error_2.txt +12 -0
  29. data/unittest/expected/test_gloss.debug1.txt +45 -0
  30. data/unittest/expected/test_gloss.debug2.txt +16 -0
  31. data/unittest/expected/test_gloss.tex.runtex_summary.txt +18 -0
  32. data/unittest/expected/test_gloss_1.txt +19 -0
  33. data/unittest/expected/test_gloss_2.txt +11 -0
  34. data/unittest/expected/test_gloss_newgloss.debug1.txt +58 -0
  35. data/unittest/expected/test_gloss_newgloss.debug2.txt +20 -0
  36. data/unittest/expected/test_gloss_newgloss.tex.runtex_summary.txt +24 -0
  37. data/unittest/expected/test_gloss_newgloss_1.txt +23 -0
  38. data/unittest/expected/test_gloss_newgloss_2.txt +13 -0
  39. data/unittest/expected/test_glossaries.debug1.txt +56 -0
  40. data/unittest/expected/test_glossaries.debug2.txt +28 -0
  41. data/unittest/expected/test_glossaries.tex.runtex_summary.txt +30 -0
  42. data/unittest/expected/test_glossaries_1.txt +24 -0
  43. data/unittest/expected/test_glossaries_2.txt +19 -0
  44. data/unittest/expected/test_index.debug1.txt +35 -0
  45. data/unittest/expected/test_index.debug2.txt +18 -0
  46. data/unittest/expected/test_index.tex.runtex_summary.txt +24 -0
  47. data/unittest/expected/test_index2.debug1.txt +58 -0
  48. data/unittest/expected/test_index2.debug2.txt +29 -0
  49. data/unittest/expected/test_index2.tex.runtex_summary.txt +27 -0
  50. data/unittest/expected/test_index2_1.txt +23 -0
  51. data/unittest/expected/test_index2_2.txt +17 -0
  52. data/unittest/expected/test_index_1.txt +21 -0
  53. data/unittest/expected/test_index_2.txt +17 -0
  54. data/unittest/expected/test_makeindex.debug1.txt +35 -0
  55. data/unittest/expected/test_makeindex.debug2.txt +18 -0
  56. data/unittest/expected/test_makeindex.tex.runtex_summary.txt +18 -0
  57. data/unittest/expected/test_makeindex_1.txt +15 -0
  58. data/unittest/expected/test_makeindex_2.txt +11 -0
  59. data/unittest/expected/test_packagedoc_dtx.debug1.txt +54 -0
  60. data/unittest/expected/test_packagedoc_dtx.debug2.txt +27 -0
  61. data/unittest/expected/test_packagedoc_dtx.dtx.runtex_summary.txt +31 -0
  62. data/unittest/expected/test_packagedoc_dtx_1.txt +18 -0
  63. data/unittest/expected/test_packagedoc_dtx_2.txt +13 -0
  64. data/unittest/expected/test_rail.debug1.txt +35 -0
  65. data/unittest/expected/test_rail.debug2.txt +12 -0
  66. data/unittest/expected/test_rail.tex.runtex_summary.txt +12 -0
  67. data/unittest/expected/test_rail_1.txt +13 -0
  68. data/unittest/expected/test_rail_2.txt +9 -0
  69. data/unittest/expected/test_rail_error.debug1.txt +37 -0
  70. data/unittest/expected/test_rail_error.debug2.txt +35 -0
  71. data/unittest/expected/test_rail_error.tex.runtex_summary.txt +18 -0
  72. data/unittest/expected/test_rail_error_1.txt +18 -0
  73. data/unittest/expected/test_rail_error_2.txt +18 -0
  74. data/unittest/expected/test_splitindex.debug1.txt +64 -0
  75. data/unittest/expected/test_splitindex.debug2.txt +32 -0
  76. data/unittest/expected/test_splitindex.tex.runtex_summary.txt +31 -0
  77. data/unittest/expected/test_splitindex_1.txt +21 -0
  78. data/unittest/expected/test_splitindex_2.txt +15 -0
  79. data/unittest/expected/test_test.debug1.txt +32 -0
  80. data/unittest/expected/test_test.debug2.txt +12 -0
  81. data/unittest/expected/test_test.tex.runtex_summary.txt +12 -0
  82. data/unittest/expected/test_test_1.txt +15 -0
  83. data/unittest/expected/test_test_2.txt +9 -0
  84. data/unittest/expected/test_test_bibliography.debug1.txt +31 -0
  85. data/unittest/expected/test_test_gloss.debug1.txt +45 -0
  86. data/unittest/expected/test_test_gloss_newgloss.debug1.txt +58 -0
  87. data/unittest/expected/test_test_glossaries.debug1.txt +48 -0
  88. data/unittest/expected/test_test_index.debug1.txt +35 -0
  89. data/unittest/expected/test_test_index2.debug1.txt +58 -0
  90. data/unittest/expected/test_test_makeindex.debug1.txt +35 -0
  91. data/unittest/expected/test_test_rail.debug1.txt +35 -0
  92. data/unittest/expected/test_test_splitindex.debug1.txt +64 -0
  93. data/unittest/expected/test_test_test.debug1.txt +32 -0
  94. data/unittest/testcases.yaml +427 -0
  95. data/unittest/unittest_catch_output.rb +66 -0
  96. data/unittest/unittest_runtex.rb +282 -0
  97. metadata +149 -0
@@ -0,0 +1,111 @@
1
+ #
2
+ # This file is part of the runtex-bundle
3
+ #
4
+
5
+ module RunTeX
6
+ #Actions to handle bibliographies with bibTeX.
7
+ #
8
+ #Also supported:
9
+ #Glossaries with gloss.sty.
10
+ #Instead gloss.sty I recommend glossaries.sty (uses makeindex/xindy).
11
+ #
12
+ class BibTeX < Tool
13
+ def initialize(job, options = {})
14
+ super(job, options,
15
+ :source => "#{job.basename}.aux",
16
+ :target => "#{job.basename}.bbl",
17
+ :log => "#{job.basename}.blg"
18
+ )
19
+ @options.keys.each{|key|
20
+ case key
21
+ when :source
22
+ if @options[:source] !~ /\.aux/
23
+ @job.log.error( "#{@step} #{self.class}: Source is no aux-file (#{@options[:source]})" ) if @job.log.error?
24
+ end
25
+ when :target
26
+ if @options[:target] !~ /\.bbl/
27
+ @job.log.error( "#{@step} #{self.class}: Target is no bbl-file (#{@options[:target]})" ) if @job.log.error?
28
+ end
29
+ when :log
30
+ if @options[:log] !~ /\.blg/
31
+ @job.log.error( "#{@step} #{self.class}: Log is no blg-file (#{@options[:log]})" ) if @job.log.error?
32
+ end
33
+ else
34
+ @job.log.error( "#{@step} #{self.class}: Unknown option #{key}" ) if @job.log.error?
35
+ end
36
+ }
37
+ end #initialize
38
+ #Take the aux-file (source) and create the bbl-file.
39
+ def execute( step )
40
+ super(step)
41
+ @result = {
42
+ :error => [],
43
+ :warning => [],
44
+ :info => [],
45
+ }
46
+ #~ Logger.add( 5, self.class, "Execute #{Configuration.bibtex}for \"#{@filename}\"" )
47
+ if File.exist?( @options[:source])
48
+ @job.add2zip( @options[:source] )
49
+ end
50
+ if File.exist?( @options[:target])
51
+ @job.add2zip( @options[:target] )
52
+ bblold = File.readlines(@options[:target])
53
+ end
54
+
55
+ subrc = nil
56
+ cmd = build_cmd('bibtex', @options)
57
+ @job.log.debug( "#{@step} Call #{cmd}") if @job.log.debug?
58
+ stdout, stderr = catch_screen_output{ subrc = system( cmd ) }
59
+ #~ Logger.add_file( @filename + '.blg' ) if @logInclude
60
+ if ! subrc
61
+ @job.log.error( "#{@step} Error executing #{cmd}")
62
+ end
63
+ if File.exist?( @options[:target])
64
+ @job.add2zip( @options[:target] )
65
+ bblnew = File.readlines(@options[:target])
66
+ else
67
+ @job.log.error( "#{@step} No result after executing #{cmd}")
68
+ end
69
+ if bblold != bblnew
70
+ @job.please_rerun('Bibliography changed')
71
+ end
72
+
73
+ @job.helpfiles << @options[:source]
74
+ @job.helpfiles << @options[:target]
75
+ @job.helpfiles << "#{@job.basename}-blx.bib" #This is an auxiliary file used by the 'biblatex' package.
76
+ @job.logfiles << @options[:log]
77
+
78
+
79
+ if File.exist?( @options[:log])
80
+ @job.add2zip( @options[:log] )
81
+ File.readlines(@options[:log]).each{ |logline|
82
+ case logline
83
+ when /Database file #(.*): (.*)/
84
+ @result[:info] << "Database file #{$2} used"
85
+ when /Warning--I didn't find a database entry for "(.*)"/
86
+ @result[:warning] << "Databaseentry #{$1} missing"
87
+ #~ when /Warning--Empty definition in (.*)/
88
+ #~ result[:warning] << "Empty definition #{$1}"
89
+ when /Warning--(.*)/
90
+ @result[:warning] << "#{$1}"
91
+ when /I couldn't open (.*) file (.*)/
92
+ @result[:error] << "#{$1} #{$2} not found"
93
+ when /I found no (.*) commands---while reading file(.*)/
94
+ @result[:warning] << "found no #{$1} in #{$2}"
95
+ when /(.*)---line (.*) of file(.*)/
96
+ #line-number ist unsinnig
97
+ @result[:error] << "#{$1} in #{$3}"
98
+ end
99
+ }
100
+ else
101
+ @job.log.error( "#{@step} No BibTeX-Log found #{@options[:log]}")
102
+ end
103
+ return @result
104
+ end #execute
105
+ #Used in logger
106
+ def inspect()
107
+ "BibTeX<#{@options[:target]}>"
108
+ end
109
+ end #BibTeX
110
+
111
+ end #module RunTeX
@@ -0,0 +1,371 @@
1
+ #
2
+ # This file is part of the runtex-bundle
3
+ #
4
+
5
+ module RunTeX
6
+
7
+ # This class defines a process chain to translate a tex-File.
8
+ #
9
+ # The process chain starts with a TeX-tool (LaTeX, TeX, PDFLaTeX...).
10
+ #
11
+ # Postprocessors (dvi2ps, ps2pdf...) can be integrated here
12
+ class Job_chain
13
+
14
+ #
15
+ MAX_TEX_RUN = 5 #Stop for infinite TeX-runs
16
+ #The configuration defines:
17
+ #- the programm to call
18
+ #- post processes
19
+ File.open(RunTeX::CONFIGURATION){|f|
20
+ Configuration = YAML.load(f)
21
+ }
22
+ #Default options for TeX-Jobs.
23
+ #Used by Job_chain#new and Job_chain#help.
24
+ DEFAULT_OPTIONS = {
25
+ :format => :pdflatex,
26
+ :delete_logfiles => true,
27
+ :delete_helpfiles => true,
28
+ :zip_helpfiles => true,
29
+ :keep_summary => true,
30
+ :overfull => 100, #report overfull boxes > this value
31
+ :underfull => 9000, #report underfull boxes > this badness
32
+ }
33
+
34
+ def self.help()
35
+ return <<help
36
+ Help for RunTeX::Jobchain
37
+ Codeexample>>>>>Start>>>>>>>
38
+ require 'runtex'
39
+ #~ puts RunTeX::Job_chain.help()
40
+ tex = RunTeX::Job_chain.new('filename', {
41
+ #{DEFAULT_OPTIONS.map{|key, value| " #{key.inspect} => #{value.inspect}" }.join(",\n")}}
42
+ })
43
+ tex.start
44
+ require 'runtex'
45
+ #~ tex.start( 'pdflatex' )
46
+ Codeexample<<<<<<End<<<<<<<
47
+ help
48
+ #~ Available formats and programms:
49
+ #~ #{Configuration.keys.map{|k| k =~ /tex/ ? k : nil }.compact.to_yaml}
50
+ end
51
+
52
+
53
+ #
54
+ #Create a job and define the parameters.
55
+ #To execute it, use Job_chain#start()
56
+ def initialize( filename, options = {} )
57
+ @options = DEFAULT_OPTIONS.merge(options)
58
+
59
+ @logfiles = []
60
+ @helpfiles = []
61
+
62
+ @log = Log4r::Logger.new( File.basename(filename) )
63
+ @log.level = Log4r::DEBUG
64
+ @log.outputters = Log4r::StdoutOutputter.new('log_stdout', :level => Log4r::INFO )
65
+ @logfiles << "#{filename}.runtex.log"
66
+ @log.add(Log4r::FileOutputter.new('log_file', :filename => "#{@logfiles.last}", :level => Log4r::DEBUG ) )
67
+
68
+ self.file= filename
69
+
70
+ (options.keys - DEFAULT_OPTIONS.keys).each{|key|
71
+ @log.warn( "#{self.inspect}: Unknown option-key #{key}" ) if @log.warn?
72
+ }
73
+
74
+ end
75
+ #Main document. This document is to be converted.
76
+ attr_reader :filename
77
+ #Main document without extension.
78
+ attr_reader :basename
79
+ #List with log-files. Used for Job_chain#delete_helpfiles
80
+ attr_reader :logfiles
81
+ #List with help-files. Used for Job_chain#delete_helpfiles
82
+ attr_reader :helpfiles
83
+
84
+ #Define the TeX-file
85
+ def file=( filename )
86
+ @dirname = File.dirname( filename)
87
+ @filename = File.basename( filename )
88
+ #~ @basename = File.basename( filename, ".tex" )
89
+ @basename = @filename.sub(/\.(tex|dtx)$/, '')
90
+ Dir.chdir(@dirname){
91
+ if ! File.exist?( @filename )
92
+ @log.fatal("File #{@filename } not found (looking in #{Dir.pwd()})") if @log.fatal?
93
+ end
94
+ }
95
+ end
96
+
97
+ #Start the job chain.
98
+ def start( format = @options[:format] )
99
+ puts "Start job chain for #{@filename }"
100
+ @log.info( "Start job chain for #{@dirname}/#{@filename }") if @log.info?
101
+
102
+ @texrun = 0
103
+ @rerun = [ nil ] #Flag, if an additional texrun is necessary (nil, so compact can delete it again)
104
+ @stop_rerun = {} #Set a Rerun-Stop in case of serious problems.
105
+ zipfilename = "#{@basename}.log.zip"
106
+ summary = nil
107
+ #Don't use "#{filename}.runtex.log", Thats already the log.
108
+ jobreport = "#{filename}.runtex_summary.txt"
109
+
110
+ Dir.chdir(@dirname){
111
+ if ! File.exist?( @filename )
112
+ @log.error( "File #{@filename} missing (dir #{@dirname})" ) if @log.error?
113
+ return false
114
+ end
115
+
116
+ if File.exist?( zipfilename )
117
+ #Extract previous help files
118
+ Zip::ZipFile.open( zipfilename, Zip::ZipFile::CREATE ){|zip|
119
+ zip.each{|f| f.extract if File.dirname("#{f}") == '.' and ! File.exist?("#{f}")}
120
+ }
121
+ File.delete( zipfilename)#Delete zip file. Easier then rebuild the zip.
122
+ @log.debug( "Re-Create log/help-zip #{zipfilename}") if @log.debug?
123
+ else
124
+ @log.debug( "Create log/help-zip #{zipfilename}") if @log.debug?
125
+ end
126
+ @zip = Zip::ZipFile.new( zipfilename, Zip::ZipFile::CREATE )
127
+
128
+ configuration = Configuration["#{format}"]
129
+ @log.fatal("No configuration for #{format}") if ! configuration and @log.fatal
130
+
131
+ while ! @rerun.empty? and @texrun < MAX_TEX_RUN
132
+ #Write the message only, if it is the 2nd run (-> test with compact).
133
+ @log.info( "%02i--- Rerun necessary (#{@rerun.join(', ')})" % @texrun ) if @log.info? and ! @rerun.compact.empty?
134
+ @rerun = []
135
+ texresult = run( LaTeX.new( self, {
136
+ :format => configuration['call'],
137
+ :overfull => @options[:overfull],
138
+ :underfull => @options[:underfull],
139
+ }
140
+ ) )
141
+ texresult = {} unless texresult
142
+ #jobreport/summary for each step
143
+ summary = build_summary( texresult, jobreport, format )
144
+ @zip.add("%02i/#{jobreport}" % @texrun, jobreport )
145
+ #The deletion is done with the end-summary
146
+
147
+ end
148
+ if @texrun >= MAX_TEX_RUN
149
+ @log.warn( "Stop after #{MAX_TEX_RUN} tex runs") if @log.warn?
150
+ end
151
+
152
+ ##################
153
+ #fixme - postprocesses
154
+ ##################
155
+ configuration['post'].each{|post|
156
+ @log.error( "Post-process #{post} undefined") if @log.error?
157
+ } if configuration['post']
158
+
159
+ @helpfiles.uniq!
160
+ #Save all helpfiles to the zip file.
161
+ #In a later run, this helpfiles are extracted again.
162
+ if @options[:zip_helpfiles]
163
+ @log.debug( "Zip help files for later use (#{@helpfiles.join(', ')})") if @log.debug?
164
+ @helpfiles.each{|filename|
165
+ #~ @log.debug( "Zip #{filename} for later use") if @log.debug?
166
+ @zip.add( filename, filename ) if File.exist?(filename)
167
+ }
168
+ end
169
+
170
+ #fixme - I would like to add the log - does not work
171
+ #~ filename = @log.outputters[1].filename
172
+ #~ @log.outputters[1].close
173
+ #~ @log.remove[1]
174
+ #~ @zip.add( filename, filename )
175
+
176
+ #build the summary and save it
177
+ summary = build_summary( texresult, jobreport, format )
178
+ @zip.add(jobreport, jobreport)
179
+ @logfiles << jobreport unless @options[:keep_summary]
180
+
181
+ #Close must be done before the files are deleted.
182
+ @zip.close
183
+
184
+ #Delete logfiles if requested
185
+ if @options[:delete_logfiles]
186
+ @logfiles.delete_if{|filename| ! File.exist?(filename) } #delete for log
187
+ @log.debug( "Delete log files #{@logfiles.join(', ')}") if @log.debug?
188
+ @logfiles.each{|filename|
189
+ #~ @log.debug( "Delete #{filename}") if @log.debug?
190
+ begin; File.delete(filename) if File.exist?(filename)
191
+ rescue Errno::EACCES => err
192
+ @log.error( "Delete #{filename}: #{err}") if @log.error?
193
+ end
194
+ }
195
+ end
196
+ #Delete helpfiles if requested
197
+ if @options[:delete_helpfiles]
198
+ @helpfiles.delete_if{|filename| ! File.exist?(filename) } #delete for log
199
+ @log.debug( "Delete helpfiles #{@helpfiles.join(', ')}") if @log.debug?
200
+ @helpfiles.each{|filename|
201
+ #~ @log.debug( "Delete #{filename}") if @log.debug?
202
+ begin; File.delete(filename) if File.exist?(filename)
203
+ rescue Errno::EACCES => err
204
+ #Happens with rail.exe at xxx.rai-file
205
+ @log.error( "Delete #{filename}: #{err}") if @log.error?
206
+ end
207
+ }
208
+ end
209
+
210
+ } #Dir.chdir(@dirname)
211
+ puts summary
212
+ puts "More Details see #{jobreport} or #{zipfilename}"
213
+ return summary #for other usages (e.g.runtex_gui.rb..)
214
+ end #start
215
+ #
216
+ #Build the summary and store it in file jobreport
217
+ #
218
+ def build_summary( texresult, jobreport, format )
219
+ #Get main data (filename, number of pages, size...)
220
+ summary = texresult[:fileinfo].to_yaml
221
+ #Get more data
222
+ [ [:error, 'Errors'],
223
+ [:warning,'Warnings'],
224
+ [:overfull, "Overfull boxes > #{@options[:overfull]}"],
225
+ [:underfull, "Underfull boxes with badness > #{@options[:underfull]}"],
226
+ ].each{|key, text|
227
+ next unless texresult[key]
228
+ next if texresult[key].empty?
229
+ summary << "#{text}:\n"
230
+ summary << texresult[key].to_yaml.sub(/--- \n/, '')
231
+ }
232
+
233
+ #Save the summary to a file
234
+ File.open(jobreport, 'w'){| file |
235
+
236
+ file << <<header
237
+ ==================================================
238
+ | Report for TeX-Job #{filename}"
239
+ | #{Time.now.strftime('%Y-%m-%d %H:%M')}, TeX-run #{@texrun}
240
+ ==================================================
241
+
242
+ header
243
+ file << "#{'='*50}\n"
244
+ file << "LaTeX (#{format})\n"
245
+ file << "#{'='*50}\n"
246
+ file << summary
247
+ @nextsteps.each{|step|
248
+ file << "\n#{'='*50}\n"
249
+ file << "#{step.inspect}\n"
250
+ file << "#{'='*50}\n"
251
+ file << step.summary
252
+ summary << "#{step.inspect}: #{step.summary(:count)}\n"
253
+ }#@nextsteps
254
+ @stop_rerun.each{|tool, reasons|
255
+ summary << "!! Rerun-Stopp for #{tool}!"
256
+ file << "\n#{'='*50}\n"
257
+ file << "!! Rerun-Stopp for #{tool}"
258
+ file << "\n#{'='*50}\n"
259
+ reasons.each{|reason|
260
+ file << "- #{reason}\n"
261
+ }
262
+ }#@stop_rerun
263
+ } #open file
264
+ return summary
265
+ end #build_summary( summary, jobreport )
266
+
267
+ #Counter for the texrun.
268
+ attr_reader :texrun
269
+
270
+ #Access to the logger
271
+ attr_reader :log
272
+
273
+
274
+ #Start a run with LaTeX. Required additional tools are added with << during the TeX-run.
275
+ def run( latex )
276
+
277
+ if ! latex.is_a?(LaTeX)
278
+ @log.fatal( "Run with a non-LaTeX-tool") if @log.fatal?
279
+ end
280
+
281
+ @texrun += 1
282
+ @nextsteps = []
283
+
284
+ #Run LaTeX
285
+ @latex = latex #store it for log in <<
286
+ @log.info( "%02i Start TeX-run #{@texrun}" % @texrun ) if @log.info?
287
+ texresult = latex.execute(1)
288
+ @log.debug( "#{latex.step} -> #{prepare_result(texresult)}") if @log.debug?
289
+
290
+ #Run the necessary tools
291
+ @nextsteps.each_with_index{|step, index|
292
+ result = step.execute( index + 2 ) #TeX is step 1
293
+ @log.debug( "#{step.step} -> #{prepare_result(result)}") if @log.debug? and !result.empty?
294
+ }
295
+ #Print the end statistic
296
+ return texresult
297
+
298
+ end
299
+ #Delete result hash form empty arrays and zero-counters, build an ordered string.
300
+ #Sort messages by importance
301
+ def prepare_result( result )
302
+ result.delete_if{|key,val| ( val.is_a?(Array) and val.empty? ) or val == 0 }
303
+ string = []
304
+ string << "File: #{result[:fileinfo].join(', ')}" if result[:fileinfo] #List with filename, size , number of errors...
305
+ string << "Errors: #{result[:error].join(', ')}" if result[:error]
306
+ string << "Warnings: #{result[:warning].join(', ')}" if result[:warning]
307
+ string << "Info: #{result[:info].join(', ')}" if result[:info]
308
+ (result.keys - [:fileinfo, :file, :size, :pages, :error, :warnings, :info ]).each{|key|
309
+ if result[key].respond_to?(:join)
310
+ string << "#{result[key]}: #{result[key].join(', ')}"
311
+ else
312
+ string << "#{result[key]}: #{result[key]}"
313
+ end
314
+ }
315
+ string.join('; ')
316
+ end
317
+ #Add a reason, why an additional TeX-run is necessary.
318
+ def please_rerun( reason )
319
+ @log.debug( "%02i Rerun necessary (#{reason})" % @texrun) if @log.debug?
320
+ @rerun << reason
321
+ end #please_rerun
322
+ #Set a Rerun-Stop in case of serious problems.
323
+ #Contains Symbols with name of the tool which should be blocked.
324
+ def stop_rerun( tool, reason )
325
+ @stop_rerun[tool] = [] unless @stop_rerun[tool]
326
+ @stop_rerun[tool] << reason
327
+ end
328
+ #Is there a rerun-stop for a special tool?
329
+ def stop_rerun?( tool )
330
+ return @stop_rerun.keys.include?(tool)
331
+ end
332
+ #Add a new step for the next step.
333
+ def << (step)
334
+ @log.debug( "#{@latex.step} Add new step #{step.inspect}" % @texrun ) if @log.debug?
335
+
336
+ case step
337
+ when Splitindex
338
+ @log.debug( "#{@latex.step} Replace Makeindex by Splitindex" ) if @log.debug?
339
+ @nextsteps.pop if @nextsteps.last.is_a?(Makeindex)
340
+ when Makeindex
341
+ if step.options[:name] =~ /Index2/ and
342
+ @nextsteps.last.is_a?(Makeindex) and
343
+ @nextsteps.last.options[:name] == 'Index'
344
+ @log.debug( "#{@latex.step} Replace Makeindex by #{step.options[:name]}" ) if @log.debug?
345
+ @nextsteps.pop if @nextsteps.last.is_a?(Makeindex)
346
+ end
347
+ when Rail
348
+ #Execute Rail only once
349
+ @nextsteps.each{|lstep| return false if lstep.is_a?(Rail) }
350
+ end
351
+ @nextsteps << step
352
+ end #Job_chain#<<
353
+
354
+ #Add the given file to the log-zip
355
+ def add2zip(filename)
356
+ zipname = "%02i/%s" % [@texrun, filename]
357
+
358
+ count = 1
359
+ while @zip.find_entry(zipname)
360
+ count += 1
361
+ zipname = "%02i/%s.%i" % [@texrun, filename, count]
362
+ end
363
+ @zip.add( zipname, filename )
364
+
365
+ end #add2zip
366
+
367
+ def inspect()
368
+ return "<RunTeX::Job_chain #{@filename}>"
369
+ end
370
+ end #Job_chain
371
+ end #module RunTeX