rails-latex 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.swp
1
2
  *.gem
2
3
  .bundle
3
4
  Gemfile.lock
@@ -9,4 +10,4 @@ rdoc
9
10
  examples/rails-latex-demo/log
10
11
  examples/rails-latex-demo/tmp
11
12
  *#*#
12
- .#*
13
+ .#*
data/README.rdoc CHANGED
@@ -1,7 +1,7 @@
1
1
  = Rails-LaTeX
2
2
 
3
- * Git: http://github.com/jacott/rails-latex
4
- * Author: Geoff Jacobsen
3
+ * Git: http://github.com/baierjan/rails-latex
4
+ * Original author: Geoff Jacobsen
5
5
  * Copyright: 2009-2010
6
6
  * License: MIT-LICENSE
7
7
 
@@ -40,13 +40,13 @@ config/initializers/mime_types.rb:
40
40
  Only the file containing the \\documentclass should be of type: .pdf.erbtex . Partials and views (when there is a layout)
41
41
  should be of type .pdf.erb .
42
42
 
43
- If a LaTeX package requires two parses then add the following to the .pdf.erbtex file:
43
+ If a LaTeX package requires more than one parser run add the following to the .pdf.erbtex file:
44
44
 
45
- <% @latex_config={:parse_twice => true} %>
45
+ <% @latex_config={:parse_runs => 3} %>
46
46
 
47
47
  You can override the defaults like so:
48
48
 
49
- LatexToPdf.config.merge! :command => 'xetex', :arguments => ['-etex'], :parse_twice => true
49
+ LatexToPdf.config.merge! :command => 'xetex', :arguments => ['-etex'], :parse_runs => 2
50
50
 
51
51
  or to change just the arguments:
52
52
 
@@ -55,10 +55,12 @@ or to change just the arguments:
55
55
  The defaults are:
56
56
  command: 'pdflatex'
57
57
  arguments: ['-halt-on-error']
58
- parse_twice: false
58
+ parse_runs: 1
59
59
 
60
- The last log file is moved to tmp/rails-latex/input.log . If the PDF is not produced the build directory is not removed;
61
- an archive script should be written to occasionally clean up the tmp/rails-latex directory.
60
+ The last log file is moved to tmp/rails-latex/input.log , and the corresponding
61
+ source TeX file to tmp/rails-latex/input.tex . If the PDF is not produced the
62
+ build directory is not removed; an archive script should be written to
63
+ occasionally clean up the tmp/rails-latex directory.
62
64
 
63
65
  See the rails application under examples/rails-latex-demo/ for a working example.
64
66
 
@@ -101,5 +103,6 @@ Developing rails-latex requires bundler and RedCloth
101
103
 
102
104
  == Contributions
103
105
 
106
+ * Geoff Jacobsen
104
107
  * Tommaso Patrizi
105
- * Klaus Reske
108
+ * Klaus Reske
@@ -1,6 +1,7 @@
1
+ # -*- coding: utf-8 -*-
1
2
  class LatexToPdf
2
3
  def self.config
3
- @config||={:command => 'pdflatex', :arguments => ['-halt-on-error'], :parse_twice => false}
4
+ @config||={:command => 'pdflatex', :arguments => ['-halt-on-error'], :parse_twice => false, :parse_runs => 1}
4
5
  end
5
6
 
6
7
  # Converts a string of LaTeX +code+ into a binary string of PDF.
@@ -10,17 +11,19 @@ class LatexToPdf
10
11
  #
11
12
  # The config argument defaults to LatexToPdf.config but can be overridden using @latex_config.
12
13
  #
13
- # The parse_twice argument is deprecated in favor of using config[:parse_twice] instead.
14
+ # The parse_twice argument and using config[:parse_twice] is deprecated in favor of using config[:parse_runs] instead.
14
15
  def self.generate_pdf(code,config,parse_twice=nil)
15
16
  config=self.config.merge(config)
16
- parse_twice=config[:parse_twice] if parse_twice.nil?
17
+ parse_twice=config[:parse_twice] if parse_twice.nil? # deprecated
18
+ parse_runs=[config[:parse_runs], (parse_twice ? 2 : config[:parse_runs])].max
19
+ puts "Running Latex #{parse_runs} times..."
17
20
  dir=File.join(Rails.root,'tmp','rails-latex',"#{Process.pid}-#{Thread.current.hash}")
18
21
  input=File.join(dir,'input.tex')
19
22
  FileUtils.mkdir_p(dir)
20
23
  # copy any additional supporting files (.cls, .sty, ...)
21
24
  supporting = config[:supporting]
22
- if supporting.class == String or supporting.class == Array and supporting.length > 0
23
- FileUtils.cp(supporting, dir)
25
+ if supporting.kind_of?(String) or supporting.kind_of?(Pathname) or (supporting.kind_of?(Array) and supporting.length > 0)
26
+ FileUtils.cp_r(supporting, dir)
24
27
  end
25
28
  File.open(input,'wb') {|io| io.write(code) }
26
29
  Process.waitpid(
@@ -30,7 +33,9 @@ class LatexToPdf
30
33
  original_stdout, original_stderr = $stdout, $stderr
31
34
  $stderr = $stdout = File.open("input.log","a")
32
35
  args=config[:arguments] + %w[-shell-escape -interaction batchmode input.tex]
33
- system config[:command],'-draftmode',*args if parse_twice
36
+ (parse_runs-1).times do
37
+ system config[:command],'-draftmode',*args
38
+ end
34
39
  exec config[:command],*args
35
40
  rescue
36
41
  File.open("input.log",'a') {|io|
@@ -42,6 +47,7 @@ class LatexToPdf
42
47
  end
43
48
  end)
44
49
  if File.exist?(pdf_file=input.sub(/\.tex$/,'.pdf'))
50
+ FileUtils.mv(input,File.join(dir,'..','input.tex'))
45
51
  FileUtils.mv(input.sub(/\.tex$/,'.log'),File.join(dir,'..','input.log'))
46
52
  result=File.read(pdf_file)
47
53
  FileUtils.rm_rf(dir)
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Latex
3
- VERSION = "1.0.12"
3
+ VERSION = "1.0.13"
4
4
  end
5
5
  end
data/rails-latex.gemspec CHANGED
@@ -5,11 +5,12 @@ require "rails-latex/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "rails-latex"
7
7
  s.version = Rails::Latex::VERSION
8
- s.authors = ["Geoff Jacobsen"]
9
- s.email = ["geoffjacobsen@gmail.com"]
10
- s.homepage = "http://github.com/jacott/rails-latex"
8
+ s.authors = ["Jan Baier", "Geoff Jacobsen"]
9
+ s.email = ["jan.baier@amagical.net"]
10
+ s.homepage = "http://github.com/baierjan/rails-latex"
11
11
  s.summary = %q{A LaTeX to pdf rails 3 renderer.}
12
12
  s.description = %q{rails-latex is a renderer for rails 3 which allows tex files with erb to be turned into an inline pdf.}
13
+ #s.licence = "MIT"
13
14
 
14
15
  s.files = `git ls-files`.split("\n")
15
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -68,6 +68,16 @@ class TestLatexToPdf < Test::Unit::TestCase
68
68
  assert_equal ["#{TMP_DIR}/tmp/rails-latex/input.log"], Dir["#{TMP_DIR}/tmp/rails-latex/*"]
69
69
  end
70
70
 
71
+ def test_generate_pdf_parse_runs
72
+ pdf_file=write_pdf do
73
+ LatexToPdf.config[:parse_runs]=2
74
+ LatexToPdf.generate_pdf(IO.read(File.expand_path('../test_doc.tex',__FILE__)),{})
75
+ end
76
+ assert_equal "The last page is 1.\n\n1\n\n\f", `pdftotext #{pdf_file} -`
77
+
78
+ assert_equal ["#{TMP_DIR}/tmp/rails-latex/input.log"], Dir["#{TMP_DIR}/tmp/rails-latex/*"]
79
+ end
80
+
71
81
  def test_doc_log_written
72
82
  begin
73
83
  LatexToPdf.generate_pdf(IO.read(File.expand_path('../test_doc.tex',__FILE__)),{})
metadata CHANGED
@@ -1,47 +1,53 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-latex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.13
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
8
+ - Jan Baier
7
9
  - Geoff Jacobsen
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2013-12-09 00:00:00.000000000 Z
13
+ date: 2015-01-22 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: rails
15
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
16
19
  requirements:
17
- - - '>='
20
+ - - ! '>='
18
21
  - !ruby/object:Gem::Version
19
22
  version: 3.0.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
23
27
  requirements:
24
- - - '>='
28
+ - - ! '>='
25
29
  - !ruby/object:Gem::Version
26
30
  version: 3.0.0
27
31
  - !ruby/object:Gem::Dependency
28
32
  name: RedCloth
29
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
30
35
  requirements:
31
- - - '>='
36
+ - - ! '>='
32
37
  - !ruby/object:Gem::Version
33
38
  version: 4.2.7
34
39
  type: :development
35
40
  prerelease: false
36
41
  version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
37
43
  requirements:
38
- - - '>='
44
+ - - ! '>='
39
45
  - !ruby/object:Gem::Version
40
46
  version: 4.2.7
41
47
  description: rails-latex is a renderer for rails 3 which allows tex files with erb
42
48
  to be turned into an inline pdf.
43
49
  email:
44
- - geoffjacobsen@gmail.com
50
+ - jan.baier@amagical.net
45
51
  executables: []
46
52
  extensions: []
47
53
  extra_rdoc_files:
@@ -93,32 +99,29 @@ files:
93
99
  - test/test_broken_doc.tex
94
100
  - test/test_doc.tex
95
101
  - test/test_latex_to_pdf.rb
96
- homepage: http://github.com/jacott/rails-latex
102
+ homepage: http://github.com/baierjan/rails-latex
97
103
  licenses: []
98
- metadata: {}
99
104
  post_install_message:
100
105
  rdoc_options:
101
106
  - --main=README.rdoc
102
107
  require_paths:
103
108
  - lib
104
109
  required_ruby_version: !ruby/object:Gem::Requirement
110
+ none: false
105
111
  requirements:
106
- - - '>='
112
+ - - ! '>='
107
113
  - !ruby/object:Gem::Version
108
114
  version: '0'
109
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
+ none: false
110
117
  requirements:
111
- - - '>='
118
+ - - ! '>='
112
119
  - !ruby/object:Gem::Version
113
120
  version: '0'
114
121
  requirements: []
115
122
  rubyforge_project:
116
- rubygems_version: 2.0.3
123
+ rubygems_version: 1.8.23
117
124
  signing_key:
118
- specification_version: 4
125
+ specification_version: 3
119
126
  summary: A LaTeX to pdf rails 3 renderer.
120
- test_files:
121
- - test/helper.rb
122
- - test/test_broken_doc.tex
123
- - test/test_doc.tex
124
- - test/test_latex_to_pdf.rb
127
+ test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 184a55dac5d356018d4dc5d476c3a8110ec64f6c
4
- data.tar.gz: e5976e30e07475083badf5c781b84cb9b34fa7a4
5
- SHA512:
6
- metadata.gz: 0081962be9aa3cc1f8efb61af0793e49e9b05ae2f67f7661896132afa564447ab9e800323906ce02a0f2e38004cb1b89f488d3dff2e5fbe373f7dde60f92c698
7
- data.tar.gz: 4f9887516749dd1c74517c30cade07e517f132c543ca8d515752cb2276831952c0f937228253ebee567d488f76f7a6706cc2fdb70c44d715688e0d3a634017b9