rails-latex 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -44,6 +44,9 @@ If a LaTeX package requires two parses then add the following to the .pdf.erbtex
44
44
 
45
45
  <% @latex_parse_twice=true %>
46
46
 
47
+ The last log file is moved to tmp/rails-latex/input.log . If the PDF is no produced the build directory is not removed;
48
+ a archive script should be written to occasionally clean up the tmp/rails-latex directory.
49
+
47
50
  See the rails application under examples/rails-latex-demo/ for a working example.
48
51
 
49
52
  == Requirements
data/lib/latex_to_pdf.rb CHANGED
@@ -9,11 +9,16 @@ class LatexToPdf
9
9
  FileUtils.mkdir_p(dir)
10
10
  File.open(input,'wb') {|io| io.write(code) }
11
11
  (parse_twice ? 2 : 1).times {
12
- system('pdflatex','-output-directory',dir,'-interaction','batchmode',input,
13
- :umask => 7,:out => :close, :err => :close, :in => :close)
12
+ system('pdflatex','-output-directory',dir,'-interaction','batchmode',input)
13
+ # :umask => 7,:out => :close, :err => :close, :in => :close) # not supported in ruby 1.8
14
14
  }
15
- result=File.read(input.sub(/\.tex$/,'.pdf'))
16
- FileUtils.rm_rf(dir)
15
+ FileUtils.mv(input.sub(/\.tex$/,'.log'),File.join(dir,'..','input.log'))
16
+ if File.exist?(pdf_file=input.sub(/\.tex$/,'.pdf'))
17
+ result=File.read(pdf_file)
18
+ FileUtils.rm_rf(dir)
19
+ else
20
+ raise "pdflatex failed: See #{input.sub(/\.tex$/,'.log')} for details"
21
+ end
17
22
  result
18
23
  end
19
24
 
data/test/helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- require 'test/unit'
2
+ require 'test/unit/full'
3
3
 
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -2,7 +2,7 @@ require 'helper'
2
2
  require 'erb_latex'
3
3
  require 'ostruct'
4
4
 
5
- Rails=OpenStruct.new(:root => File.dirname(TMP_DIR=File.expand_path(File.dirname(__FILE__),'tmp')))
5
+ Rails=OpenStruct.new(:root => TMP_DIR=File.expand_path("../tmp",__FILE__))
6
6
 
7
7
  class TestLatexToPdf < Test::Unit::TestCase
8
8
  def test_escape
@@ -15,9 +15,10 @@ class TestLatexToPdf < Test::Unit::TestCase
15
15
  def test_generate_pdf
16
16
  FileUtils.mkdir_p(TMP_DIR)
17
17
  File.open(pdf_file=File.join(TMP_DIR,'out.pdf'),'wb') do |wio|
18
- wio.write(LatexToPdf.generate_pdf(IO.read(File.expand_path(File.dirname(__FILE__),'test_doc.tex'))))
18
+ wio.write(LatexToPdf.generate_pdf(IO.read(File.expand_path('../test_doc.tex',__FILE__))))
19
19
  end
20
20
  assert_equal "hello world\n\n1\n\n\f", `pdftotext #{pdf_file} -`
21
- assert_equal [], Dir["#{TMP_DIR}/rails-latex/*"]
21
+
22
+ assert_equal ["#{TMP_DIR}/rails-latex/input.log"], Dir["#{TMP_DIR}/rails-latex/*"]
22
23
  end
23
24
  end
data/test/tmp/out.pdf ADDED
Binary file
@@ -0,0 +1,72 @@
1
+ entering extended mode
2
+ This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) (format=pdflatex 2010.10.5) 21 JAN 2011 13:37
3
+ entering extended mode
4
+ restricted \write18 enabled.
5
+ %&-line parsing enabled.
6
+ **/home/geoffj/src/rails-latex/test/tmp/rails-latex/8021-2486817462074625061/in
7
+ put.tex
8
+
9
+ (/home/geoffj/src/rails-latex/test/tmp/rails-latex/8021-2486817462074625061/inp
10
+ ut.tex
11
+ LaTeX2e <2009/09/24>
12
+ Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
13
+ yphenation, farsi, arabic, croatian, bulgarian, ukrainian, russian, czech, slov
14
+ ak, danish, dutch, finnish, french, basque, ngerman, german, german-x-2009-06-1
15
+ 9, ngerman-x-2009-06-19, ibycus, monogreek, greek, ancientgreek, hungarian, san
16
+ skrit, italian, latin, latvian, lithuanian, mongolian2a, mongolian, bokmal, nyn
17
+ orsk, romanian, irish, coptic, serbian, turkish, welsh, esperanto, uppersorbian
18
+ , estonian, indonesian, interlingua, icelandic, kurmanji, slovenian, polish, po
19
+ rtuguese, spanish, galician, catalan, swedish, ukenglish, pinyin, loaded.
20
+ (/usr/share/texmf-texlive/tex/latex/base/article.cls
21
+ Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
22
+ (/usr/share/texmf-texlive/tex/latex/base/size10.clo
23
+ File: size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
24
+ )
25
+ \c@part=\count79
26
+ \c@section=\count80
27
+ \c@subsection=\count81
28
+ \c@subsubsection=\count82
29
+ \c@paragraph=\count83
30
+ \c@subparagraph=\count84
31
+ \c@figure=\count85
32
+ \c@table=\count86
33
+ \abovecaptionskip=\skip41
34
+ \belowcaptionskip=\skip42
35
+ \bibindent=\dimen102
36
+ )
37
+ No file input.aux.
38
+ \openout1 = `input.aux'.
39
+
40
+ LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 3.
41
+ LaTeX Font Info: ... okay on input line 3.
42
+ LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 3.
43
+ LaTeX Font Info: ... okay on input line 3.
44
+ LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 3.
45
+ LaTeX Font Info: ... okay on input line 3.
46
+ LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 3.
47
+ LaTeX Font Info: ... okay on input line 3.
48
+ LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 3.
49
+ LaTeX Font Info: ... okay on input line 3.
50
+ LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 3.
51
+ LaTeX Font Info: ... okay on input line 3.
52
+ [1
53
+
54
+ {/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]
55
+ (/home/geoffj/src/rails-latex/test/tmp/rails-latex/8021-2486817462074625061/inp
56
+ ut.aux) )
57
+ Here is how much of TeX's memory you used:
58
+ 199 strings out of 493848
59
+ 2612 string characters out of 1152823
60
+ 47808 words of memory out of 3000000
61
+ 3563 multiletter control sequences out of 15000+50000
62
+ 3640 words of font info for 14 fonts, out of 3000000 for 9000
63
+ 714 hyphenation exceptions out of 8191
64
+ 23i,4n,17p,211b,107s stack positions out of 5000i,500n,10000p,200000b,50000s
65
+ </usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr10.pfb>
66
+ Output written on /home/geoffj/src/rails-latex/test/tmp/rails-latex/8021-248681
67
+ 7462074625061/input.pdf (1 page, 11949 bytes).
68
+ PDF statistics:
69
+ 10 PDF objects out of 1000 (max. 8388607)
70
+ 0 named destinations out of 1000 (max. 500000)
71
+ 1 words of extra memory for PDF output out of 10000 (max. 10000000)
72
+
@@ -0,0 +1,72 @@
1
+ This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) (format=pdflatex 2010.10.5) 16 FEB 2011 09:29
2
+ entering extended mode
3
+ restricted \write18 enabled.
4
+ %&-line parsing enabled.
5
+ **/home/geoffj/src/rails-latex/test/tmp/tmp/rails-latex/6834--33678256374036541
6
+ 29/input.tex
7
+
8
+ (/home/geoffj/src/rails-latex/test/tmp/tmp/rails-latex/6834--336782563740365412
9
+ 9/input.tex
10
+ LaTeX2e <2009/09/24>
11
+ Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
12
+ yphenation, farsi, arabic, croatian, bulgarian, ukrainian, russian, czech, slov
13
+ ak, danish, dutch, finnish, french, basque, ngerman, german, german-x-2009-06-1
14
+ 9, ngerman-x-2009-06-19, ibycus, monogreek, greek, ancientgreek, hungarian, san
15
+ skrit, italian, latin, latvian, lithuanian, mongolian2a, mongolian, bokmal, nyn
16
+ orsk, romanian, irish, coptic, serbian, turkish, welsh, esperanto, uppersorbian
17
+ , estonian, indonesian, interlingua, icelandic, kurmanji, slovenian, polish, po
18
+ rtuguese, spanish, galician, catalan, swedish, ukenglish, pinyin, loaded.
19
+ (/usr/share/texmf-texlive/tex/latex/base/article.cls
20
+ Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
21
+ (/usr/share/texmf-texlive/tex/latex/base/size10.clo
22
+ File: size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
23
+ )
24
+ \c@part=\count79
25
+ \c@section=\count80
26
+ \c@subsection=\count81
27
+ \c@subsubsection=\count82
28
+ \c@paragraph=\count83
29
+ \c@subparagraph=\count84
30
+ \c@figure=\count85
31
+ \c@table=\count86
32
+ \abovecaptionskip=\skip41
33
+ \belowcaptionskip=\skip42
34
+ \bibindent=\dimen102
35
+ )
36
+ No file input.aux.
37
+ \openout1 = `input.aux'.
38
+
39
+ LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 3.
40
+ LaTeX Font Info: ... okay on input line 3.
41
+ LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 3.
42
+ LaTeX Font Info: ... okay on input line 3.
43
+ LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 3.
44
+ LaTeX Font Info: ... okay on input line 3.
45
+ LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 3.
46
+ LaTeX Font Info: ... okay on input line 3.
47
+ LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 3.
48
+ LaTeX Font Info: ... okay on input line 3.
49
+ LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 3.
50
+ LaTeX Font Info: ... okay on input line 3.
51
+ [1
52
+
53
+ {/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]
54
+ (/home/geoffj/src/rails-latex/test/tmp/tmp/rails-latex/6834--336782563740365412
55
+ 9/input.aux) )
56
+ Here is how much of TeX's memory you used:
57
+ 199 strings out of 493848
58
+ 2647 string characters out of 1152823
59
+ 47808 words of memory out of 3000000
60
+ 3563 multiletter control sequences out of 15000+50000
61
+ 3640 words of font info for 14 fonts, out of 3000000 for 9000
62
+ 714 hyphenation exceptions out of 8191
63
+ 23i,4n,17p,216b,107s stack positions out of 5000i,500n,10000p,200000b,50000s
64
+ </usr/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr10.pf
65
+ b>
66
+ Output written on /home/geoffj/src/rails-latex/test/tmp/tmp/rails-latex/6834--3
67
+ 367825637403654129/input.pdf (1 page, 11949 bytes).
68
+ PDF statistics:
69
+ 10 PDF objects out of 1000 (max. 8388607)
70
+ 0 named destinations out of 1000 (max. 500000)
71
+ 1 words of extra memory for PDF output out of 10000 (max. 10000000)
72
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 1
9
- version: 1.0.1
8
+ - 2
9
+ version: 1.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Geoff Jacobsen
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-19 00:00:00 +13:00
17
+ date: 2011-02-16 00:00:00 +13:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -49,6 +49,9 @@ files:
49
49
  - test/helper.rb
50
50
  - test/test_doc.tex
51
51
  - test/test_latex_to_pdf.rb
52
+ - test/tmp/out.pdf
53
+ - test/tmp/rails-latex/input.log
54
+ - test/tmp/tmp/rails-latex/input.log
52
55
  - README.rdoc
53
56
  - examples/rails-latex-demo/app/controllers/application_controller.rb
54
57
  - examples/rails-latex-demo/app/controllers/latex_example_controller.rb