rake4latex 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/bin/{call_rake4latex.rb → rake4latex.rb} +5 -1
  3. data/bin/{readme_call_rake4latex.txt → readme_rake4latex.txt} +0 -0
  4. data/lib/rake4latex.rb +6 -8
  5. data/lib/rake4latex/base.rb +60 -15
  6. data/lib/rake4latex/clean.rb +37 -32
  7. data/lib/rake4latex/glossaries.rb +3 -4
  8. data/lib/rake4latex/latexrunner.rb +9 -4
  9. data/lib/rake4latex/rail.rb +80 -0
  10. data/lib/rake4latex/rules.rb +25 -56
  11. data/lib/rake4latex/splitindex.rb +7 -7
  12. data/lib/rake4latex_dtx.rb +6 -4
  13. data/lib/rake4latex_dvipdfm.rb +3 -10
  14. data/lib/rake4latex_ps2pdf.rb +4 -8
  15. data/readme.html +37 -12
  16. data/readme.txt +23 -8
  17. data/test/_expected/bibtex_test.txt +0 -1
  18. data/test/_expected/bibtex_test_bib.txt +0 -1
  19. data/test/_expected/bibtex_test_build_rakefile.txt +0 -1
  20. data/test/_expected/dtx_test.txt +0 -1
  21. data/test/_expected/dtx_test_sty.txt +0 -1
  22. data/test/_expected/dvipdfm_test.txt +0 -1
  23. data/test/_expected/error_test.txt +0 -1
  24. data/test/_expected/error_test_ignore_error.txt +0 -1
  25. data/test/_expected/error_test_overview.txt +11 -12
  26. data/test/_expected/error_test_statistic.txt +0 -1
  27. data/test/_expected/gloss_test.txt +0 -1
  28. data/test/_expected/gloss_test_bib.txt +0 -1
  29. data/test/_expected/gloss_test_build_rakefile.txt +0 -1
  30. data/test/_expected/glossaries_test.txt +0 -1
  31. data/test/_expected/includes_test.txt +0 -1
  32. data/test/_expected/includes_test_build_rakefile.txt +1 -2
  33. data/test/_expected/index_test.txt +0 -1
  34. data/test/_expected/longtable_test.txt +0 -1
  35. data/test/_expected/minitoc_test.txt +0 -1
  36. data/test/_expected/ps2pdf_test.txt +0 -1
  37. data/test/_expected/rail_error_test.txt +2 -3
  38. data/test/_expected/rail_test.txt +0 -1
  39. data/test/_expected/splitindex_test.txt +0 -1
  40. data/test/_expected/splitindex_test_build_rakefile.txt +0 -1
  41. data/test/_expected/supertabular_test.txt +0 -1
  42. data/test/_expected/supertabular_test_statistic.txt +1 -2
  43. data/test/_expected/two_tasks_test.txt +0 -1
  44. data/test/_expected/two_tasks_test_statistic.txt +0 -1
  45. data/test/_expected/varioref_test.txt +0 -1
  46. data/test/_expected/varioref_test_ignore_error.txt +1 -2
  47. data/test/_expected/z_complex_test.txt +0 -1
  48. data/test/_expected/z_complex_test_overview.txt +58 -58
  49. data/test/_expected/z_complex_test_overview_file.txt +0 -1
  50. data/test/_expected/z_complex_test_statistic.txt +0 -1
  51. data/test/bibtex/rakefile.rb +4 -9
  52. data/test/gloss/rakefile.rb +0 -7
  53. data/test/glossaries/rakefile.rb +4 -5
  54. data/test/rake4latex_testhelper.rb +76 -0
  55. data/test/test_extract.rb +29 -0
  56. data/test/unittest_rail.rb +154 -0
  57. data/test/unittest_rake4latex.rb +1 -0
  58. data/test/unittest_rake4latex_testcases.rb +96 -63
  59. data/test/unittest_splitindex.rb +14 -3
  60. metadata +89 -117
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f429ae0c2dc08880faa5a81e45ce31778aa77ee2
4
+ data.tar.gz: dd0dbff35d547ab8b45bbf33e26f340c0fd7eee4
5
+ SHA512:
6
+ metadata.gz: 3a498a5bcafd842caf4307e87535f323126ca6f95bc936bd562f441492bdf9aeb5deba5c4dd4d3b19548e06a6d28781c23fa7c50070095a26442f7dca48949cf
7
+ data.tar.gz: 515d8ea74215c693581c55120a9ecc949dadde7c2973345877e9f17ae5a78bb4c35b2b6968077c5ad353373cc1fdcc33640e97cc65d01134cd6689efe975acd0
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env ruby
1
2
  =begin rdoc
2
3
  call_rake4latex.rb offers an easy and fast interface
3
4
  to rake4latex.
@@ -172,7 +173,10 @@ app = Rake.application
172
173
  app[:default].invoke
173
174
 
174
175
  if $0 == __FILE__
175
- if STDIN.tty?
176
+ if ARGV.empty?
177
+ puts "Usage: rake4latex.rb [options] filename"
178
+ puts "For more help use: rake4latex.rb -h"
179
+ else STDIN.tty?
176
180
  puts "Finished, please enter any key"
177
181
  STDOUT.flush
178
182
  STDIN.getc
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env ruby
1
2
  =begin rdoc
2
3
  ==Introduction
3
4
  This file contains definitions to build a rakefile for LaTeX-documents.
@@ -309,7 +310,7 @@ There are additional packages requiring additonal runs.
309
310
  #
310
311
  #Load the base functions and load subfiles.
311
312
  #
312
- require 'rake4latex/base'
313
+ require_relative 'rake4latex/base'
313
314
 
314
315
  #
315
316
  #Define the pdf-creation via pdflatex
@@ -344,13 +345,11 @@ rule '.pdf' => '.ps' do |t|
344
345
  t.application.latexrunner.logger.info("Call ps2pdf for <#{t.source}>") if t.application.latexrunner
345
346
  cmd = Rake4LaTeX.build_cmd( 'ps2pdf', :filename => t.source )
346
347
 
347
- stdout, stderr = catch_screen_output{
348
- sh "ps2pdf #{t.source}"
348
+ stdin, stdout, stderr, wait_thr = Open3.popen3("ps2pdf #{t.source}")
349
+ if wait_thr.value.exitstatus != 0
349
350
  #stdout -> empty
350
351
  #stderr -> "ps2pdf testdocument.ps"
351
- }
352
- if $? != 0
353
- t.application.latexrunner.logger.fatal("There where ps2pdf errors. \n#{stdout}")
352
+ t.application.latexrunner.logger.fatal("There where ps2pdf errors. \n#{stdout.readlines.join}")
354
353
  end
355
354
  end
356
355
 
@@ -360,8 +359,7 @@ if $0 == __FILE__
360
359
  #~ require 'yaml'
361
360
  #~ puts LaTeXRunner.find_included_files( 'test/testdocument.tex' ).to_yaml
362
361
 
363
- task :acroread => 'test/testdocument.pdf'
364
- #~ task :default => :acroread
362
+ #~ task :pdfview => 'test/testdocument.pdf'
365
363
 
366
364
  #~ app = Rake.application
367
365
  #~ app[:default].invoke
@@ -8,13 +8,30 @@ require 'rake'
8
8
  case RUBY_VERSION
9
9
  when /1.8/;
10
10
  require 'md5' # defines MD5 and Digest::MD5
11
- when /1.9/;
11
+ when /1.9/, /^2./
12
12
  require 'digest/md5' #defines Digest::MD5
13
13
  require 'yaml'
14
- else; raise "Undefined ruby version #{RUBY_VERSION}"
14
+ else
15
+ raise "Undefined ruby version #{RUBY_VERSION}"
15
16
  end
16
17
 
17
18
  require 'log4r' #1.0.5
19
+ #Some Tools have screen output.
20
+ #Rake4LaTeX should run silent in background, so we have to redirect the output.
21
+ require "open3"
22
+ =begin
23
+ stdin, stdout, stderr, wait_thr = Open3.popen3(@cmd)
24
+ @stdout = stdout.readlines.join
25
+ @stderr = stderr.readlines.join
26
+ if wait_thr.value.exitstatus != 0
27
+
28
+ stdin, stdout, stderr, wait_thr = Open3.popen3(cmd)
29
+ if wait_thr.value.exitstatus != 0
30
+ task.texrunner.logger.fatal("...\n#{stdout.readlines.join}")
31
+ end
32
+
33
+ =end
34
+
18
35
 
19
36
  module Rake
20
37
  class Task
@@ -27,9 +44,11 @@ and can be used by the tex_postrule.
27
44
  end
28
45
  end
29
46
 
30
-
31
47
  module Rake4LaTeX
32
- VERSION = '0.1.3'
48
+ VERSION = '0.1.5'
49
+ #Collect descriptions for tasks. See #mk_taskdescriptions
50
+ TASK_DESCRIPTION = true
51
+ TASK_DESCRIPTIONS = {}
33
52
 
34
53
  #With this creation we define the constants Log4r::DEBUG...
35
54
  Logger = Log4r::Logger.new("LaTeXRunner")
@@ -98,6 +117,25 @@ Load the Programs with parameters for Rake4LaTeX.build_cmd.
98
117
  end
99
118
 
100
119
  =begin rdoc
120
+ Define all descriptions for tasks.
121
+
122
+ This defines the descriptions:
123
+ rake basefile # Set the basefile - needed for clean and statistic
124
+ rake clean[basename] # Remove any temporary products
125
+ rake clobber # Remove any generated file
126
+ rake log_archive # Archive all log-files to zip-file
127
+ rake log_overview # Show the log-overview
128
+ rake log_overview_file # Build a log-overview file
129
+ rake pdfview # Show compiled PDF in Reader
130
+ rake statistic # Build a statistic for all TeX project
131
+ rake touch # Touch - reset timestamp
132
+ =end
133
+ def self.mk_taskdescriptions
134
+ TASK_DESCRIPTIONS.each{|taskname, descr|
135
+ Rake.application[taskname].comment = descr
136
+ }
137
+ end
138
+ =begin rdoc
101
139
  Build the command line to call a tool.
102
140
 
103
141
  Bases is the configuration in Programms.
@@ -143,7 +181,8 @@ Set the file for clean/clobber, offers the possibility to set defaults,
143
181
  define a logger.
144
182
  =end
145
183
  class Basefile
146
-
184
+ #needed for Rake-version >= 0.9.1
185
+ include Rake::DSL if defined? Rake::DSL
147
186
  @@all = {}
148
187
 
149
188
  =begin rdoc
@@ -206,20 +245,20 @@ Defines document specific tasks (statistic, set clean and clobber)
206
245
  def define_tasks()
207
246
 
208
247
  namespace @basename do
209
- desc "Create the statistic for #{@basename}"
248
+ desc "Create the statistic for #{@basename}" if Rake4LaTeX::TASK_DESCRIPTION
210
249
  task :statistic do
211
250
  stat = Rake4LaTeX::TeX_Statistic.new(@basename)
212
251
  puts "Statistic for #{@basename}:"
213
252
  puts stat.stat_summary.map{|e| " #{e}"}
214
253
  end
215
254
 
216
- desc "Build a log-overview for #{@basename}"
255
+ desc "Build a log-overview for #{@basename}" if Rake4LaTeX::TASK_DESCRIPTION
217
256
  task :log_overview do
218
257
  stat = Rake4LaTeX::TeX_Statistic.new(@basename)
219
258
  puts stat.overview()
220
259
  end
221
260
 
222
- desc "Build a log-overview file for #{@basename}"
261
+ desc "Build a log-overview file for #{@basename}" if Rake4LaTeX::TASK_DESCRIPTION
223
262
  task :log_overview_file do
224
263
  stat = Rake4LaTeX::TeX_Statistic.new(@basename)
225
264
  #Filename also used in set4clean
@@ -251,6 +290,7 @@ This method is called by task 'basename' (Basefile#initialize)
251
290
  cleanlist.add("#{@basename}.{ilg,idx,ind}") #Index
252
291
  cleanlist.add("#{@basename}-*.{ilg,idx,ind}") #splitindex.sty
253
292
  cleanlist.add("#{@basename}.{blg,bbl}") #BibTeX
293
+ cleanlist.add("#{@basename}.{bcf}") #BibLaTeX
254
294
  cleanlist.add("#{@basename}-blx.{bib}") #auxiliary file used by the 'biblatex' package
255
295
  cleanlist.add("#{@basename}.*.{blg,bbl,aux}") #gloss.sty
256
296
  cleanlist.add("#{@basename}.{maf,ptc*,mtc*,stc*}") #minitoc.sty (stc1, stc2...)
@@ -260,6 +300,8 @@ This method is called by task 'basename' (Basefile#initialize)
260
300
  cleanlist.add("#{@basename}.{tdo}") #tdo: todonotes.sty
261
301
  cleanlist.add("#{@basename}.{vrb}") #vrb: beamer.sty (verbatim)
262
302
  cleanlist.add("#{@basename}.{lox}") #lox: fixme.sty
303
+ cleanlist.add("#{@basename}.{run.xml}") #run.xml: TeXworks (editor)
304
+ cleanlist.add("#{@basename}.{upa,upb}") #pdfcomment.sty
263
305
 
264
306
  clobberlist = FileList.new("#{@basename}.{dvi,pdf,ps}")
265
307
  #The * is needed.else the filename is added always. With '*' it is checked for existence
@@ -270,7 +312,7 @@ This method is called by task 'basename' (Basefile#initialize)
270
312
 
271
313
  CLEAN.uniq!
272
314
  CLOBBER.uniq!
273
-
315
+
274
316
  end #set4clean
275
317
 
276
318
  =begin rdoc
@@ -357,9 +399,12 @@ end
357
399
  #
358
400
  #Load the sub-files
359
401
  #
360
- require 'rake4latex/clean' #modified rake/clean
361
- require 'rake4latex/latexrunner'
362
- require 'rake4latex/analyse_texfile'
363
- require 'rake4latex/splitindex'
364
- require 'rake4latex/rules'
365
- require 'rake4latex/tex_statistic'
402
+ require_relative 'clean' #modified rake/clean
403
+ require_relative 'latexrunner'
404
+ require_relative 'analyse_texfile'
405
+ require_relative 'splitindex'
406
+ require_relative 'rail'
407
+ require_relative 'rules'
408
+ require_relative 'tex_statistic'
409
+
410
+ #~ Rake4LaTeX.mk_taskdescriptions if Rake4LaTeX::TASK_DESCRIPTION
@@ -1,16 +1,16 @@
1
- #!/usr/bin/env ruby
2
-
3
- # The 'rake/clean' file defines two file lists (CLEAN and CLOBBER) and
4
- # two rake tasks (:clean and :clobber).
5
- #
6
- # [:clean] Clean up the project by deleting scratch files and backup
7
- # files. Add files to the CLEAN file list to have the :clean
8
- # target handle them.
9
- #
10
- # [:clobber] Clobber all generated and non-source files in a project.
11
- # The task depends on :clean, so all the clean files will
12
- # be deleted as well as files in the CLOBBER file list.
13
- # The intent of this task is to return a project to its
1
+ #!/usr/bin/env ruby
2
+
3
+ # The 'rake/clean' file defines two file lists (CLEAN and CLOBBER) and
4
+ # two rake tasks (:clean and :clobber).
5
+ #
6
+ # [:clean] Clean up the project by deleting scratch files and backup
7
+ # files. Add files to the CLEAN file list to have the :clean
8
+ # target handle them.
9
+ #
10
+ # [:clobber] Clobber all generated and non-source files in a project.
11
+ # The task depends on :clean, so all the clean files will
12
+ # be deleted as well as files in the CLOBBER file list.
13
+ # The intent of this task is to return a project to its
14
14
  # pristine, just unpacked state.
15
15
  #
16
16
  # This replaces the original clean.
@@ -19,38 +19,43 @@
19
19
  # * Use File.delete (avoid stderr-messages of rm_r)
20
20
  # * Use LaTeXRunner.logger if available.
21
21
  # * Use uniq to avoid warnings for just deleted files.
22
-
22
+ # * Add a parameter basefile
23
+ #
24
+
23
25
  require 'rake'
24
-
25
- CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"]
26
- CLEAN.clear_exclude.exclude { |fn|
27
- fn.pathmap("%f") == 'core' && File.directory?(fn)
28
- }
29
26
 
30
-
31
- desc "Remove any temporary products."
27
+ CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"]
28
+ CLEAN.clear_exclude.exclude { |fn|
29
+ fn.pathmap("%f") == 'core' && File.directory?(fn)
30
+ }
31
+
32
+ Rake4LaTeX::TASK_DESCRIPTIONS[:clean] = "Remove any temporary products. Optional parameter: Basefile"
32
33
  #~ task :clean do
33
- task :clean do
34
+ task :clean, :basename do |t, args|
34
35
  Rake4LaTeX::Basefile.each{|file| file.set4clean } #late call is necessary. doc. says FileList would work without...
36
+ if args[:basename]
37
+ Rake4LaTeX::Basefile.set(args[:basename]).set4clean #add given parameter to be deleted.
38
+ end
35
39
 
36
- logger = Rake4LaTeX::Logger
40
+ logger = Rake4LaTeX::Logger
37
41
  logger.info("Clean: delete helpfiles #{CLEAN.inspect}") if logger.info?
38
42
  CLEAN.uniq.each { |fn|
39
43
  #~ rm_r fn rescue nil
40
44
  #~ logger.debug("Clean: delete #{fn}") if logger
41
45
  File.delete(fn) rescue ( logger.warn("Clean: #{fn} not deleted") if logger )
42
- }
43
- end
44
-
45
- CLOBBER = Rake::FileList.new
46
-
47
- desc "Remove any generated file."
48
- task :clobber => :clean do
46
+ CLEAN.delete(fn) #avoid warning if clean is called twice.
47
+ }
48
+ end
49
+
50
+ CLOBBER = Rake::FileList.new
51
+
52
+ Rake4LaTeX::TASK_DESCRIPTIONS[:clobber] = "Remove any generated file."
53
+ task :clobber => :clean do
49
54
  logger = Rake4LaTeX::Logger
50
55
  logger.info("Clobber: delete helpfiles #{(CLEAN + CLOBBER).inspect}") if logger.info?
51
56
  CLOBBER.uniq.each { |fn|
52
57
  #~ rm_r fn rescue nil
53
58
  #~ logger.debug("Clobber: delete #{fn}") if logger
54
59
  File.delete(fn) rescue ( logger.warn("Clobber: #{fn} not deleted") if logger )
55
- }
56
- end
60
+ }
61
+ end
@@ -1,3 +1,4 @@
1
+ #encoding: utf-8
1
2
  =begin rdoc
2
3
  Define tasks for usage of rake4latex with glossaries.sty
3
4
 
@@ -27,7 +28,7 @@ Statt ind/idx werden
27
28
  - glsext_in => glsext_out (selbstdefiniert)
28
29
  verwendet.
29
30
 
30
- Zus�tzlich Index-file ist.
31
+ Zusätzlich Index-file ist.
31
32
  =end
32
33
 
33
34
 
@@ -92,9 +93,7 @@ tex_postrule '.gls' => '.glo' do | t |
92
93
  )
93
94
  #~ puts cmd
94
95
  Rake4LaTeX::Logger.debug("Call #{cmd}")
95
- stdout, stderr = catch_screen_output{
96
- sh cmd
97
- }
96
+ stdin, stdout, stderr, wait_thr = Open3.popen3(cmd)
98
97
  CLEAN.include(FileList.new("#{t.name.ext()}.{#{par[:in]},#{par[:out]},#{par[:log]}}"))
99
98
  }#$gls.each
100
99
  CLEAN.include(FileList.new(t.texrunner.glossaries_format)) if t.texrunner.glossaries_format
@@ -268,10 +268,15 @@ Defaults are defined in Rake4LaTeX::Basefile#settings4LaTeXRunner
268
268
  #One of the sources of post_prereq changes
269
269
  @logger.info("Call target #{post_prereq.name} (#{reason4call})" )
270
270
  post_prereq.invoke()
271
- File.open(post_prereq.name){|f|
272
- @rerun_necessary = ( Digest::MD5.hexdigest(f.read) != checksums[f.path])
273
- @logger.info("Rerun necessary (#{f.path} changed)" ) if @rerun_necessary
274
- } unless @rerun_necessary #check not necessary, if we already need an additional run
271
+ if File.exist?(post_prereq.name)
272
+ File.open(post_prereq.name){|f|
273
+ @rerun_necessary = ( Digest::MD5.hexdigest(f.read) != checksums[f.path])
274
+ @logger.info("Rerun necessary (#{f.path} changed)" ) if @rerun_necessary
275
+ } unless @rerun_necessary #check not necessary, if we already need an additional run
276
+ else
277
+ @logger.info("Rerun necessary (#{post_prereq.name} did not exist)" )
278
+ @rerun_necessary = true
279
+ end
275
280
  break #Only one call necessary
276
281
  end #source changed
277
282
  } ##prerequisites of post_prereq
@@ -0,0 +1,80 @@
1
+ module Rake4LaTeX
2
+ =begin rdoc
3
+ Support rail-diagramms in LaTeX.
4
+
5
+ Details for the rail package see http://www.ctan.org/tex-archive/support/rail/
6
+
7
+ =end
8
+ class Rail
9
+ def initialize(source, logger = Log4r::Logger.new('log'))
10
+ @source = source
11
+ @log = logger
12
+ @cmd = Rake4LaTeX.build_cmd( 'rail', :railfile => source )
13
+ end
14
+ #Command line to start rail
15
+ attr_reader :cmd
16
+ attr_reader :stdout
17
+ attr_reader :stderr
18
+ =begin rdoc
19
+ Execute rail and returns the result.
20
+
21
+ rail.exe does not support filenames longer with 8 characters.
22
+ So we use stdin:
23
+
24
+ rail < input.rai
25
+
26
+ Returns successcode (true/false)
27
+
28
+ =end
29
+ def execute
30
+ #execute
31
+ @log.debug("Call rail: #{@cmd}")
32
+ stdin, stdout, stderr, wait_thr = Open3.popen3(@cmd)
33
+
34
+ #analyse result
35
+ success = true
36
+ #check return code
37
+ if wait_thr.value.exitstatus != 0
38
+ @log.fatal("There where Rail errors.")
39
+ success = false
40
+ end
41
+ @stdout = stdout.readlines.join
42
+ @stderr = stderr.readlines.join
43
+ #check errors
44
+ @stderr.each_line{|errline|
45
+ @log.error("Rail error: #{errline.strip}")
46
+ success = false
47
+ }
48
+
49
+ if ! success
50
+ @log.warn("No rail diagramms generated")
51
+ end
52
+
53
+ #Now we have to save the result and delete some stuff.
54
+ if @stdout
55
+ @stdout.sub!(/^(This is Rail.*)/, '') #%This is Rail, Version 1.1 #0
56
+ @stdout.sub!(/^(\(stdin.*)/, '')
57
+ @stdout.sub!(/^\)/, '') #last line
58
+ @stdout.strip!
59
+ end
60
+
61
+ success
62
+ end #execute
63
+ end #class Rail
64
+ end #module Rake4LaTeX
65
+
66
+
67
+ if $0 == __FILE__
68
+ require_relative '../rake4latex'
69
+ @@testrai_file = '_tmp_.rai'
70
+ File.open(@@testrai_file, 'w'){|f|
71
+ f << "\\rail@i{1}{ block1 : ( lbrace | 'begin' ) ( ( '|' ( variable + ',' ) '|' ) | [Keine Blockvariablen] ) comm ( rbrace | 'end' ) ; }"
72
+ f << "\\rail@i{1}{ block1 : ( lbrace | "
73
+ }
74
+ @rail = Rake4LaTeX::Rail.new(@@testrai_file)
75
+ p @rail.cmd
76
+ p @rail.execute
77
+ p @rail.stdout
78
+ p @rail.stderr
79
+
80
+ end
@@ -1,3 +1,4 @@
1
+ #encoding: utf-8
1
2
  =begin rdoc
2
3
  Collection of rules to build a LaTeX-project.
3
4
 
@@ -26,15 +27,9 @@ This may be done via different ways. You can select your version on your own:
26
27
  #~ Dir['../rake4latex_*'].each{|x| puts "* #{x}" }
27
28
 
28
29
 
29
- #Some Tools have screen output.
30
- #Rake4LaTeX should run silent in background, so we have to redirect the output.
31
- require 'knut_tools/catch_output'
32
- include Catch_output
33
-
34
- desc "Show compiled source in Adobe Acrobat Reader."
35
- task :acroread do |t|
30
+ Rake4LaTeX::TASK_DESCRIPTIONS[:pdfview] = "Show compiled PDF in Reader."
31
+ task :pdfview do |t|
36
32
  t.prerequisites.each{|pre|
37
- #~ sh "acroread #{pre.ext('pdf')}"
38
33
  #Problem: rake process waits until reader is closed
39
34
  sh "call #{pre.ext('pdf')}"
40
35
  }
@@ -43,7 +38,7 @@ end
43
38
  =begin
44
39
  Alternative definition instead Rake4LaTeX::Basefile.set(filename)
45
40
  =end
46
- desc "Set the basefile - needed for clean and statistic"
41
+ Rake4LaTeX::TASK_DESCRIPTIONS[:basefile] = "Set the basefile - needed for clean and statistic"
47
42
  task :basefile do |task|
48
43
  task.prerequisites.each{|pre|
49
44
  #~ puts "Set basefile #{pre.inspect}"
@@ -55,7 +50,7 @@ end
55
50
  #
56
51
  #Reset the timestamp of a file (can be used to force the first compilation)
57
52
  #
58
- desc "Touch - reset timestamp"
53
+ Rake4LaTeX::TASK_DESCRIPTIONS[:touch] = "Touch - reset timestamp"
59
54
  task :touch do |task|
60
55
  task.prerequisites.each{|pre|
61
56
  FileUtils.touch(pre)
@@ -84,13 +79,9 @@ rule '.ps' => '.dvi' do |task|
84
79
  Rake4LaTeX::Basefile.set(task.source).logger.info("Call dvips for <#{task.source}>")
85
80
  cmd = Rake4LaTeX.build_cmd( 'dvips', :filename => task.source )
86
81
 
87
- stdout, stderr = catch_screen_output{
88
- sh cmd
89
- #stdout -> empty
90
- #stderr -> log.
91
- }
92
- if $? != 0
93
- Rake4LaTeX::Basefile.set(task.source).fatal("There where dvips errors. \n#{stdout}")
82
+ stdin, stdout, stderr, wait_thr = Open3.popen3(cmd)
83
+ if wait_thr.value.exitstatus != 0
84
+ task.texrunner.logger.fatal("There where dvips errors. \n#{stdout.readlines.join}")
94
85
  end
95
86
  end
96
87
 
@@ -106,9 +97,10 @@ tex_postrule '.ind' => '.idx' do |task|
106
97
  #makeindex writes to stderr -> catch it
107
98
  cmd = Rake4LaTeX.build_cmd( 'makeindex', { :file_in => task.source }, task )
108
99
  task.texrunner.logger.debug("\t#{cmd}")
109
- stdout, stderr = catch_screen_output{
110
- sh cmd
111
- }
100
+ stdin, stdout, stderr, wait_thr = Open3.popen3(cmd)
101
+ if wait_thr.value.exitstatus != 0
102
+ @logger.fatal("There where Makeindex errors.\n#{stderr.readlines.join}")
103
+ end
112
104
  else #splitidx used
113
105
  #call splitindex
114
106
  splitidx.execute()
@@ -139,7 +131,7 @@ tex_postrule_check '.bbl' do |args|
139
131
 
140
132
  #Check, if the bbl is missing.
141
133
  #may occur, if the bbl-file was deleted manual, but no change in aux...
142
- # fixme -- provoziert unn�tige bibtex-laeufe.
134
+ # fixme -- provoziert unnoetige bibtex-laeufe.
143
135
  #~ bblfile = args[:task].name.ext('bbl')
144
136
  #~ necessary = "#{bblfile} missing" unless File.exist?(bblfile)
145
137
 
@@ -173,45 +165,21 @@ end
173
165
  tex_postrule '.bbl' => '.aux' do |task|
174
166
  cmd = Rake4LaTeX.build_cmd( 'bibtex', {:source => task.source}, task )
175
167
  task.texrunner.logger.debug("Call bibTeX: #{cmd}")
176
- stdout, stderr = catch_screen_output{
177
- puts `#{cmd}`
178
- }
179
- if $? != 0
180
- task.texrunner.logger.fatal("There where BibTeX errors. \n#{stdout}")
168
+ stdin, stdout, stderr, wait_thr = Open3.popen3(cmd)
169
+ if wait_thr.value.exitstatus != 0
170
+ task.texrunner.logger.fatal("There where BibTeX errors. \n#{stdout.readlines.join}")
181
171
  end
182
172
  end
183
173
 
184
174
  =begin
185
175
  Call Rail
186
- http://www.ctan.org/tex-archive/support/rail/
176
+ Details see Rake4LaTeX::Rail
187
177
  =end
188
178
  desc "Call Rail"
189
179
  tex_postrule '.rao' => '.rai' do |task|
190
- #Rail works only with filenames with 8 characters.
191
- #So we use stdin.
192
- cmd = Rake4LaTeX.build_cmd( 'rail', :railfile => task.source )
193
- task.texrunner.logger.debug("Call rail: #{cmd}")
194
- stdout, stderr = catch_screen_output{
195
- puts `#{cmd}`
196
- }
197
-
198
- error = false
199
- if $? != 0
200
- task.texrunner.logger.fatal("There where Rail errors.")
201
- error = true
202
- end
203
- stderr.each_line{|errline|
204
- task.texrunner.logger.error("Rail error: #{errline.strip}")
205
- error = true
206
- }
207
- if error
208
- task.texrunner.logger.warn("No rail diagramms generated")
209
- else
210
- #Now we have to save the result and delete some stuff.
211
- stdout.sub!(/^(This is Rail.*)/, '%\1') #%This is Rail, Version 1.1 #0
212
- stdout.sub!(/^(\(stdin.*)/, '%\1')
213
- stdout.sub!(/^\)/, '%\1)') #last line
214
- File.open(task.source.ext('rao'), 'w'){|f| f << stdout }
180
+ rail = Rake4LaTeX::Rail.new(task.source, task.texrunner.logger)
181
+ if rail.execute
182
+ File.open(task.source.ext('rao'), 'w'){|f| f << rail.stdout }
215
183
  end
216
184
  CLEAN.include(task.source)
217
185
  CLEAN.include(task.name)
@@ -230,25 +198,26 @@ Build Statistic.
230
198
 
231
199
  The main action is defined in Rake4LaTeX::Basefile
232
200
  =end
233
- desc "Build a statistic for all TeX project"
201
+ desc nil #reset previous desc definitions
202
+ Rake4LaTeX::TASK_DESCRIPTIONS[:statistic] = "Build a statistic for all TeX project"
234
203
  task :statistic
235
204
 
236
205
  =begin
237
206
  Show the log-overview
238
207
  =end
239
- desc "Show the log-overview"
208
+ Rake4LaTeX::TASK_DESCRIPTIONS[:log_overview] = "Show the log-overview"
240
209
  task :log_overview
241
210
 
242
211
  =begin
243
212
  Build a log-overview file
244
213
  =end
245
- desc "Build a log-overview file"
214
+ Rake4LaTeX::TASK_DESCRIPTIONS[:log_overview_file] = "Build a log-overview file"
246
215
  task :log_overview_file
247
216
 
248
217
  =begin
249
218
  Archive all log-files to zip-file
250
219
  =end
251
- desc "Archive all log-files to zip-file"
220
+ Rake4LaTeX::TASK_DESCRIPTIONS[:log_archive] = "Archive all log-files to zip-file"
252
221
  task :log_archive do
253
222
  require 'zip/zipfilesystem'
254
223
  Zip::ZipFile.open("rake4latex_log_archive.zip", Zip::ZipFile::CREATE ){|zip|