rake4latex 0.1.0 → 0.1.1

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.
Files changed (47) hide show
  1. data/{call_rake4latex.rb → bin/call_rake4latex.rb} +6 -3
  2. data/{readme_call_rake4latex.txt → bin/readme_call_rake4latex.txt} +0 -0
  3. data/lib/rake4latex.rb +106 -42
  4. data/lib/rake4latex/analyse_texfile.rb +375 -0
  5. data/lib/rake4latex/base.rb +40 -10
  6. data/lib/rake4latex/latexrunner.rb +20 -7
  7. data/lib/rake4latex/rake4latex.yaml +4 -0
  8. data/lib/rake4latex/rules.rb +59 -26
  9. data/lib/rake4latex/tex_statistic.rb +405 -375
  10. data/lib/rake4latex_dtx.rb +83 -0
  11. data/readme.html +150 -28
  12. data/readme.txt +118 -20
  13. data/test/_expected/bibtex_test_build_rakefile.txt +49 -0
  14. data/test/_expected/dtx_test.txt +12 -0
  15. data/test/_expected/dtx_test_sty.txt +2 -0
  16. data/test/_expected/error_test.txt +4 -0
  17. data/test/_expected/error_test_ignore_error.txt +5 -0
  18. data/test/_expected/error_test_overview.txt +16 -0
  19. data/test/_expected/error_test_statistic.txt +3 -0
  20. data/test/_expected/gloss_test_build_rakefile.txt +56 -0
  21. data/test/_expected/includes_test_build_rakefile.txt +55 -0
  22. data/test/_expected/{rail_test_error.txt → rail_error_test.txt} +0 -0
  23. data/test/_expected/splitindex_test_build_rakefile.txt +56 -0
  24. data/test/_expected/supertabular_test_statistic.txt +2 -29
  25. data/test/_expected/varioref_test.txt +6 -0
  26. data/test/_expected/varioref_test_ignore_error.txt +11 -0
  27. data/test/_expected/z_complex_test_overview.txt +62 -0
  28. data/test/_expected/z_complex_test_statistic.txt +9 -0
  29. data/test/bibtex/rakefile.rb +6 -0
  30. data/test/dtx/rakefile.rb +31 -0
  31. data/test/error/rakefile.rb +32 -0
  32. data/test/error/testdocument.tex +14 -0
  33. data/test/gloss/rakefile.rb +9 -1
  34. data/test/includes/rakefile.rb +6 -0
  35. data/test/rail/rakefile.rb +1 -5
  36. data/test/rail_error/rakefile.rb +38 -0
  37. data/test/{rail → rail_error}/testrail_error.tex +0 -0
  38. data/test/splitindex/rakefile.rb +8 -1
  39. data/test/supertabular/rakefile.rb +2 -2
  40. data/test/unittest_rake4latex.rb +61 -72
  41. data/test/unittest_rake4latex_testcases.rb +79 -0
  42. data/test/varioref/rakefile.rb +37 -0
  43. data/test/varioref/testdocument.tex +33 -0
  44. data/test/z_complex/rakefile.rb +3 -1
  45. metadata +42 -10
  46. data/lib/rake4latex/latexdependencies.rb +0 -105
  47. data/lib/rake4latex/template.rb +0 -60
@@ -0,0 +1,32 @@
1
+ #
2
+ # Test error
3
+ #
4
+ Dir.chdir('../../lib'){ require 'rake4latex'}
5
+
6
+ task :basefile => 'testdocument.tex'
7
+ task :touch => 'testdocument.tex' #Zeitstempel anpassen/Kompilation erzwingen
8
+
9
+ task :ignore_error do
10
+ Rake4LaTeX.set_latexrunner_default(:texerrors_allowed, true)
11
+ end
12
+
13
+ task :default => :touch
14
+ #~ task :default => 'testdocument.dvi'
15
+ task :default => 'testdocument.pdf'
16
+ task :default => :clean
17
+
18
+ desc "Testtask for Unittest"
19
+ task :test => [ :touch, 'testdocument.pdf' ]
20
+ task :test_ignore_error => [ :touch, :ignore_error, 'testdocument.pdf' ]
21
+ task :test_statistic => [ :statistic ]
22
+ task :test_overview => [ :log_overview ]
23
+
24
+ if $0 == __FILE__
25
+ app = Rake.application
26
+ #~ app[:default].invoke
27
+ app[:test_ignore_error].invoke
28
+ app[:log_archive].invoke
29
+ app[:log_overview].invoke
30
+ end
31
+
32
+
@@ -0,0 +1,14 @@
1
+ \documentclass[ngerman]{scrartcl}
2
+ \usepackage{babel}
3
+ \usepackage[ansinew]{inputenc}
4
+ \usepackage{blindtext}
5
+ \usepackage{hyperref}
6
+ % ----------------------------------------------------------------
7
+ \begin{document}
8
+ \blindtext
9
+
10
+ \undefinedcommand
11
+
12
+ \blindtext
13
+ \end{document}
14
+ % ----------------------------------------------------------------
@@ -47,11 +47,19 @@ task :touch_bib do
47
47
  FileUtils.touch('test_gloss.bib')
48
48
  end
49
49
 
50
+ task :build_rakefile do
51
+ puts Rake4LaTeX.build_rakefile('testdocument.tex', :dvi, :pdf, :gloss ).sub(Date.today.to_s, '<<today>>')
52
+ end
53
+ task :test_build_rakefile => [ :build_rakefile ]
54
+
55
+
50
56
  if $0 == __FILE__
51
57
  app = Rake.application
52
58
  #~ Rake4LaTeX.set_latexrunner_default(:maxruns, 1)
53
59
  #~ Rake4LaTeX.set_latexrunner_default(:loglevel, Log4r::DEBUG)
54
- app[:default].invoke
60
+ #~ app[:default].invoke
61
+
62
+ app[:test_build_rakefile ].invoke
55
63
 
56
64
  #~ app[:clean].invoke
57
65
 
@@ -20,6 +20,7 @@ file 'testdocument.pdf' => deps
20
20
  task :basefile => 'testdocument.tex'
21
21
  task :touch => 'testdocument.tex' #Zeitstempel anpassen/Kompilation erzwingen
22
22
 
23
+
23
24
  task :default => :touch
24
25
  #~ task :default => 'testdocument.dvi'
25
26
  task :default => 'testdocument.pdf'
@@ -28,6 +29,11 @@ task :default => :clean
28
29
  desc "Testtask for Unittest"
29
30
  task :test => [ :touch, 'testdocument.pdf' ]
30
31
 
32
+ task :build_rakefile do
33
+ puts Rake4LaTeX.build_rakefile('testdocument.tex', :dvi, :pdf, :dependecies ).sub(Date.today.to_s, '<<today>>')
34
+ end
35
+ task :test_build_rakefile => [ :build_rakefile ]
36
+
31
37
  if $0 == __FILE__
32
38
  app = Rake.application
33
39
  app[:default].invoke
@@ -12,9 +12,7 @@ Dir.chdir('../../lib'){ require 'rake4latex'}
12
12
  #~ file 'testrail.dvi' => LaTeXRunner.find_included_files( 'testrail.tex' ).flatten.uniq
13
13
 
14
14
  task :basefile => 'testrail.tex'
15
- task :basefile => 'testrail_error.tex'
16
15
  task :touch => 'testrail.tex' #Zeitstempel anpassen/Kompilation erzwingen
17
- task :touch => 'testrail_error.tex' #Zeitstempel anpassen/Kompilation erzwingen
18
16
 
19
17
  task :default => :touch
20
18
  #~ task :default => 'testrail.dvi'
@@ -28,15 +26,13 @@ task :default => :clean
28
26
 
29
27
  desc "Testtask for Unittest"
30
28
  task :test => [ :touch, 'testrail.pdf' ]
31
- task :test_error => [ :touch, 'testrail_error.pdf' ]
32
29
 
33
30
 
34
31
  if $0 == __FILE__
35
32
  app = Rake.application
36
33
  #~ Rake4LaTeX.set_latexrunner_default(:loglevel, Log4r::DEBUG)
37
34
  #~ Rake4LaTeX.set_latexrunner_default(:texerrors_allowed, true)
38
- app[:default].invoke
35
+ #~ app[:default].invoke
39
36
  #~ app[:test].invoke
40
- #~ app[:test_error].invoke
41
37
  #~ app[:clean].invoke
42
38
  end
@@ -0,0 +1,38 @@
1
+ #
2
+ #Test rail_error
3
+ #
4
+ Dir.chdir('../../lib'){ require 'rake4latex'}
5
+
6
+ #~ deps = [
7
+ #~ 'testrail.tex'
8
+ #~ ]
9
+ #~ file 'testrail.dvi' => deps
10
+ #~ file 'testrail.pdf' => deps
11
+
12
+ #~ file 'testrail.dvi' => LaTeXRunner.find_included_files( 'testrail.tex' ).flatten.uniq
13
+
14
+ task :basefile => 'testrail_error.tex'
15
+ task :touch => 'testrail_error.tex' #Zeitstempel anpassen/Kompilation erzwingen
16
+
17
+ task :default => :touch
18
+ #~ task :default => 'testrail.dvi'
19
+ task :default => 'testrail_error.pdf'
20
+ task :default => :clean
21
+
22
+ #~ task :clean do
23
+ #~ puts CLEAN.inspect
24
+ #~ puts CLOBBER.inspect
25
+ #~ end
26
+
27
+ desc "Testtask for Unittest"
28
+ task :test => [ :touch, 'testrail_error.pdf' ]
29
+
30
+
31
+ if $0 == __FILE__
32
+ app = Rake.application
33
+ #~ Rake4LaTeX.set_latexrunner_default(:loglevel, Log4r::DEBUG)
34
+ #~ Rake4LaTeX.set_latexrunner_default(:texerrors_allowed, true)
35
+ #~ app[:default].invoke
36
+ #~ app[:test].invoke
37
+ #~ app[:clean].invoke
38
+ end
@@ -20,7 +20,7 @@ CLEAN.add("testdocument-*") #splitidx-helpfiles
20
20
  task :default => :touch
21
21
  #~ task :default => 'testdocument.dvi'
22
22
  task :default => 'testdocument.pdf'
23
- task :default => :clean
23
+ #~ task :default => :clean
24
24
 
25
25
  #~ task :clean do
26
26
  #~ puts CLEAN.inspect
@@ -30,7 +30,14 @@ task :default => :clean
30
30
  desc "Testtask for Unittest"
31
31
  task :test => [ :touch, 'testdocument.pdf' ]
32
32
 
33
+ task :build_rakefile do
34
+ puts Rake4LaTeX.build_rakefile('testdocument.tex', :pdf, :splitindex ).sub(Date.today.to_s, '<<today>>')
35
+ end
36
+ task :test_build_rakefile => [ :build_rakefile ]
37
+
38
+
33
39
  if $0 == __FILE__
34
40
  app = Rake.application
35
41
  app[:default].invoke
42
+ app[:test_build_rakefile].invoke
36
43
  end
@@ -42,7 +42,7 @@ if $0 == __FILE__
42
42
  app = Rake.application
43
43
  Rake4LaTeX.set_latexrunner_default(:loglevel, Log4r::DEBUG)
44
44
  #~ app[:default].invoke
45
- app[:test].invoke
45
+ #~ app[:test].invoke
46
46
  app[:test_statistic].invoke
47
- app[:clobber].invoke
47
+ #~ app[:clobber].invoke
48
48
  end
@@ -1,7 +1,12 @@
1
+ #
2
+ #Unit tests without TeX-Calls (see unittest_rake4latex_testcases.rb for thos tests.)
3
+ #
4
+
1
5
  require 'test/unit'
2
- require 'assert_equal_filecontent'
6
+ #~ require 'assert_equal_filecontent'
3
7
 
4
- Dir.chdir('../lib'){ require 'rake4latex'}
8
+ $: << '../lib' if $0 == __FILE__
9
+ require 'rake4latex'
5
10
  include Rake4LaTeX
6
11
 
7
12
  class Test_LaTeXRunner < Test::Unit::TestCase
@@ -100,83 +105,67 @@ class Test_LaTeXRunner_Programms < Test::Unit::TestCase
100
105
  end
101
106
  end #Test_LaTeXRunner_Programms
102
107
 
103
- class Test_LaTeXDependencies < Test::Unit::TestCase
108
+ class Test_analyse < Test::Unit::TestCase
104
109
  def test_initialize()
105
110
 
106
- assert_raise(ArgumentError){ LaTeXDependencies.new( 'not_existing_document.tex' ) }
111
+ assert_raise(ArgumentError){ TeXfile.new( 'not_existing_document.tex' ) }
107
112
 
108
113
  end
109
- def test_find_included_files()
110
-
114
+
115
+ def test_includes()
111
116
  Dir.chdir('includes'){
112
- testfile = LaTeXDependencies.new( 'testdocument.tex' )
113
- assert_equal(['testdocument.tex'], testfile.get_dependecies())
114
- assert_raise(ArgumentError){testfile.get_dependecies(:undefined)}
115
-
116
- assert_equal([
117
- 'testdocument.tex',
118
- 'testincludes/testinclude1.tex', 'testincludes/testinclude2.tex',
119
- ], testfile.get_dependecies(:inputs, :flat))
120
-
121
- #~ assert_equal(testfile.get_dependecies(:inputs).first, testfile.find_included_files )
122
-
123
- assert_equal(['testdocument.tex', [
124
- 'testincludes/testinclude1.tex', ['testincludes/testinclude2.tex'],
125
- 'testincludes/testinclude1.tex', ['testincludes/testinclude2.tex'],
126
- ]], testfile.get_dependecies(:inputs))
127
-
128
- assert_equal([
129
- 'testincludes/testinclude1.tex', ['testincludes/testinclude2.tex'],
130
- 'testincludes/testinclude1.tex', ['testincludes/testinclude2.tex'],
131
- ], testfile.find_included_files )
132
- } #dir includes
133
- #More checks:
134
- #Exception on recursive include
117
+ testfile = TeXfile.new('testdocument.tex')
118
+ assert_equal( ["testdocument.tex",
119
+ ["testincludes/testinclude1.tex", ["testincludes/testinclude2.tex"]],
120
+ ["testincludes/testinclude1.tex", ["testincludes/testinclude2.tex"]]],
121
+ testfile.tree )
122
+ assert_equal( ["testincludes/testinclude1.tex", "testincludes/testinclude1.tex"], testfile.includes )
123
+ assert_equal( ["testincludes/testinclude1.tex"], testfile.includes(:uniq) )
124
+ assert_equal( ["testincludes/testinclude1.tex", "testincludes/testinclude2.tex" ], testfile.includes(:recursive) )
125
+ #~ assert_equal( ["testdocument.tex", "testincludes/testinclude1.tex", "testincludes/testinclude2.tex" ], testfile.includes(:recursive) )
126
+ }
135
127
  end
136
- end
137
-
138
- class Test_testdocument < Test::Unit::TestCase
139
- #Test all testcases.
140
- def mytest_testcase( dir )
141
- assert_equal( true, File.directory?(dir))
142
- Dir.chdir(dir){
143
- assert_equal( true, File.exist?('rakefile.rb'), "No rakefile in #{dir}")
144
- #clean and check if test directory is empty in advance.
145
- `call rake clobber`
146
- assert_equal( true, Dir['*.{aux,log}'].empty?, "<#{dir}> contains old testdata")
147
-
148
- #Logger umh�ngen auf file
149
- #~ LaTeXRunner.logger.outputters = Log4r::FileOutputter.new("#{dir}.log4r")
128
+ def test_bibtex()
129
+ Dir.chdir('bibtex'){
130
+ testfile = TeXfile.new('testdocument.tex')
131
+ assert_equal( ['testdocument.tex'], testfile.tree )
132
+ assert_equal( ['./testdocument.bib'], testfile.bibliography )
133
+ assert_equal( {}, testfile.gloss )
134
+ }
135
+
136
+ testfile = Rake4LaTeX::TeXfile.new(:dummy)
137
+ testfile.analyse(<<'xx'
138
+ \bibliography{dd}
139
+ \bibliography{testdocument}
140
+ xx
141
+ )
142
+ assert_equal( ['dd.bib', 'testdocument.bib'], testfile.bibliography )
143
+
144
+ testfile = Rake4LaTeX::TeXfile.new(:dummy)
145
+ testfile.analyse(<<'xx'
146
+ \bibliography{dd,testdocument}
147
+ xx
148
+ )
149
+ assert_equal( ['dd.bib', 'testdocument.bib'], testfile.bibliography )
150
150
 
151
- LaTeXRunner::DEFAULT_SETTINGS[:loglevel] = Log4r::INFO
152
- #testcases: test (test1 test2 ...)
153
- testcase = nil
154
- File.open('rakefile.rb'){|rakefile|
155
- rakefile_content = rakefile.read
156
- assert_match(/^\s*task\s*:basefile\s*=>/, rakefile_content, "Missing basefile-task in Test #{dir}")
157
- rakefile_content.scan(/^task\s*:(test\S*)\s*=>/){|hit|
158
- testcase = hit.first
159
- stdout = `call rake #{testcase}`
160
- stdout.sub!(/\(in .*?$/,'') #delete first line from rake (depends on directory the test runs).
161
- assert_equal_filecontent( "../_expected/#{dir}_#{testcase}.txt", stdout,
162
- "../_failure#{Date.today}"
163
- )
164
- }#loop on test-tasks
165
- }#File rakefile
166
- assert_not_nil(testcase, "No testcase found in <#{dir}>")
167
-
168
- #~ `call rake clean`
169
- `call rake clobber` #PDFs not really needed after the test.
151
+ end
152
+ def test_gloss()
153
+ Dir.chdir('gloss'){
154
+ testfile = TeXfile.new('testdocument.tex')
155
+ assert_equal( ['testdocument.tex'], testfile.tree )
156
+ assert_equal( [], testfile.bibliography )
157
+ assert_equal( {"gls"=>["./test_gloss.bib"], "[animals]"=>["./test_gloss.bib"]}, testfile.gloss )
158
+ }
159
+ end
160
+ def test_splitindex()
161
+ Dir.chdir('splitindex'){
162
+ testfile = TeXfile.new('testdocument.tex')
163
+ assert_equal( ['testdocument.tex'], testfile.tree )
164
+ assert_equal( {"veg"=>"[Index of Vegetables]",
165
+ "ani"=>"[Index of Animals]",
166
+ "idx"=>"[GeneralIndex]",
167
+ "fru"=>"[Index of Fruits]"},
168
+ testfile.splitindex )
170
169
  }
171
170
  end
172
- Dir['*/'].each{|dir| #get all directories
173
- next if dir =~ /^_/ #files for assert_equal_filecontent
174
- dir.chop! #delete trailing /
175
- class_eval <<code
176
- def test_#{dir}
177
- mytest_testcase( '#{dir}')
178
- end
179
- code
180
- }
181
171
  end
182
-
@@ -0,0 +1,79 @@
1
+ #
2
+ #Checks the test cases (May take some time, makes a lot TeX-runs).
3
+ #
4
+ require 'test/unit'
5
+ require 'assert_equal_filecontent'
6
+
7
+ $: << '../lib' if $0 == __FILE__
8
+ require 'rake4latex'
9
+ include Rake4LaTeX
10
+
11
+
12
+ class Test_testdocument < Test::Unit::TestCase
13
+ #Test all testcases.
14
+ def mytest_testcase( dir )
15
+ assert_equal( true, File.directory?(dir))
16
+
17
+ Dir.chdir(dir){
18
+ assert_equal( true, File.exist?('rakefile.rb'), "No rakefile in #{dir}")
19
+ #clean and check if test directory is empty in advance.
20
+ `call rake clobber`
21
+ assert_equal( true, Dir['*.{aux,log}'].empty?, "<#{dir}> contains old testdata")
22
+
23
+ #Logger umh�ngen auf file
24
+ #~ LaTeXRunner.logger.outputters = Log4r::FileOutputter.new("#{dir}.log4r")
25
+
26
+ LaTeXRunner::DEFAULT_SETTINGS[:loglevel] = Log4r::INFO
27
+ #testcases: test (test1 test2 ...)
28
+ testcase = nil
29
+ File.open('rakefile.rb'){|rakefile|
30
+ rakefile_content = rakefile.read
31
+ assert_match(/^\s*task\s*:basefile\s*=>/, rakefile_content, "Missing basefile-task in Test #{dir}")
32
+ #Get all test cases
33
+ rakefile_content.scan(/^task\s*:(test\S*)\s*=>(.*)$/){|hit|
34
+ testcase = hit.first
35
+ dircontent = Dir['*'] #Remember the directory content before the task
36
+ result = `call rake #{testcase}`
37
+ result.sub!(/\(in .*?$/,'') #delete first line from rake (depends on directory the test runs).
38
+
39
+ #Take a look on the prerequisites
40
+ case hit[1]
41
+ #Special test with :log_overview.
42
+ #Don't test stdout, but content of the overview-file
43
+ when /:log_overview/
44
+ assert_equal( 1, Dir['*'].size - dircontent.size , 'No log-overview created' ) #One file created
45
+ (Dir['*'] - dircontent).each{|logfile|
46
+ result = File.read(logfile)
47
+ }
48
+ end
49
+
50
+ assert_equal_filecontent( "../_expected/#{dir}_#{testcase}.txt", result,
51
+ "../_failure#{Date.today}"
52
+ )
53
+ }#loop on test-tasks
54
+ }#File rakefile
55
+ assert_not_nil(testcase, "No testcase found in <#{dir}>")
56
+
57
+ #Check overview file
58
+ #~
59
+ #~ `call rake log_overview`
60
+
61
+ #~ `call rake clean`
62
+ `call rake clobber` #PDFs not really needed after the test.
63
+ }
64
+ end
65
+ Dir['*/'].each{|dir| #get all directories
66
+ next if dir =~ /^_/ #files for assert_equal_filecontent
67
+
68
+ #~ next unless dir =~ /complex/
69
+ #~ next unless dir =~ /vario/
70
+ #~ next unless dir =~ /error/
71
+
72
+ dir.chop! #delete trailing /
73
+ class_eval <<code
74
+ def test_#{dir}
75
+ mytest_testcase( '#{dir}')
76
+ end
77
+ code
78
+ }
79
+ end
@@ -0,0 +1,37 @@
1
+ #
2
+ #Test varioref
3
+ #
4
+ #-> ! Package varioref Error: \vref at page boundary 1-2 (may loop).
5
+ Dir.chdir('../../lib'){ require 'rake4latex'}
6
+
7
+ task :basefile => 'testdocument.tex'
8
+ task :touch => 'testdocument.tex' #Zeitstempel anpassen/Kompilation erzwingen
9
+
10
+ task :default => [:touch]
11
+ #~ task :default => 'testdocument.dvi'
12
+ task :default => 'testdocument.pdf'
13
+ task :default => :statistic
14
+ task :default => :log_overview
15
+ #~ task :default => :clean
16
+
17
+ task :ignore_error do
18
+ Rake4LaTeX.set_latexrunner_default(:texerrors_allowed, true)
19
+ end
20
+
21
+
22
+ #~ task :clean do
23
+ #~ puts CLEAN.inspect
24
+ #~ puts CLOBBER.inspect
25
+ #~ end
26
+
27
+ desc "Testtask for Unittest"
28
+ task :test => [ :touch, 'testdocument.pdf', :statistic ]
29
+ task :test_ignore_error => [ :clobber, :touch, :ignore_error, 'testdocument.pdf', :statistic ]
30
+
31
+
32
+ if $0 == __FILE__
33
+ app = Rake.application
34
+ #~ Rake4LaTeX.set_latexrunner_default(:loglevel, Log4r::DEBUG)
35
+ Rake4LaTeX.set_latexrunner_default(:texerrors_allowed, true)
36
+ app[:default].invoke
37
+ end