rails-latex 2.2.0 → 2.2.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.
- checksums.yaml +4 -4
- data/README.rdoc +9 -2
- data/lib/rails-latex.rb +1 -0
- data/lib/rails-latex/errors.rb +10 -0
- data/lib/rails-latex/latex_to_pdf.rb +9 -5
- data/lib/rails-latex/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff4b9c5a6f0d50ff945189a640d587d3d4bb0370
|
4
|
+
data.tar.gz: fc784e7d27ecaeb386118b7d95137d4056594978
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e122d3d60fa0d5a8949f0d897c6a6929ec40fa74f880ca99abf9bffe446090d62fbbefcd9ccc613029f1a1ef37b6693b3613c10b6633ff05e9327ce0c87df53d
|
7
|
+
data.tar.gz: 91a9be775b3a09802e7b0eae7c3b47b384fb9aef0aafe26e8e749e2a52e86d36de82bc2a141e1a584ae261d76590734467c962581b90194fbe8311d5107c55e6
|
data/README.rdoc
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
== Description
|
9
9
|
|
10
|
-
rails-latex is a renderer for rails
|
10
|
+
rails-latex is a renderer for rails, which allows tex files with erb to be turned into an inline pdf.
|
11
11
|
|
12
12
|
== Synopsis
|
13
13
|
|
@@ -85,10 +85,15 @@ Then in your mailer:
|
|
85
85
|
mail( .... )
|
86
86
|
end
|
87
87
|
|
88
|
+
=== Exception handling and debugging
|
89
|
+
|
90
|
+
When LaTeX render fails, +RailsLatex::ProcessingError+ is thrown. In your code, you can catch it and react according to your
|
91
|
+
needs. To make your life easier, TeX source and log are attached to the exception as instance variables +src+ and +log+.
|
92
|
+
|
88
93
|
== Requirements
|
89
94
|
|
90
95
|
* ruby 1.8 or 1.9
|
91
|
-
* rails 3
|
96
|
+
* rails 3 or later
|
92
97
|
|
93
98
|
== Install
|
94
99
|
|
@@ -106,3 +111,5 @@ Developing rails-latex requires bundler and RedCloth
|
|
106
111
|
* Geoff Jacobsen
|
107
112
|
* Tommaso Patrizi
|
108
113
|
* Klaus Reske
|
114
|
+
* Jan Baier
|
115
|
+
* Jakub Cerny
|
data/lib/rails-latex.rb
CHANGED
@@ -5,7 +5,6 @@ class LatexToPdf
|
|
5
5
|
:recipe => [
|
6
6
|
# {
|
7
7
|
# :command => 'pdflatex',
|
8
|
-
# :input => 'input.tex',
|
9
8
|
# :arguments => ['-halt-on-error', '-shell-escape', '-interaction=batchmode'],
|
10
9
|
# :extra_arguments => [],
|
11
10
|
# :runs => 1
|
@@ -58,7 +57,7 @@ class LatexToPdf
|
|
58
57
|
recipe.each do |item|
|
59
58
|
command = item[:command] || config[:command]
|
60
59
|
runs = item[:runs] || config[:parse_runs]
|
61
|
-
args = item[:arguments] || config[:arguments]
|
60
|
+
args = item[:arguments] || config[:arguments] + config[:default_arguments]
|
62
61
|
args += item[:extra_arguments].to_a + ['input']
|
63
62
|
kwargs = {:out => ["input.log", "a"]}
|
64
63
|
Rails.logger.info "Running #{command} #{args.join(' ')} #{runs} times..."
|
@@ -67,7 +66,8 @@ class LatexToPdf
|
|
67
66
|
begin
|
68
67
|
Dir.chdir dir
|
69
68
|
(runs - 1).times do
|
70
|
-
system command, *args, **kwargs
|
69
|
+
clean_exit = system command, *args, **kwargs
|
70
|
+
Process.exit! 1 unless clean_exit
|
71
71
|
end
|
72
72
|
exec command, *args, **kwargs
|
73
73
|
rescue
|
@@ -82,13 +82,17 @@ class LatexToPdf
|
|
82
82
|
end
|
83
83
|
|
84
84
|
# Finish
|
85
|
-
if File.exist?(pdf_file=input.sub(/\.tex$/,'.pdf'))
|
85
|
+
if $?.exitstatus.zero? && File.exist?(pdf_file=input.sub(/\.tex$/,'.pdf'))
|
86
86
|
FileUtils.mv(input, File.join(dir, '..', 'input.tex'))
|
87
87
|
FileUtils.mv(input.sub(/\.tex$/,'.log'), File.join(dir, '..', 'input.log'))
|
88
88
|
result = File.read(pdf_file)
|
89
89
|
FileUtils.rm_rf(dir)
|
90
90
|
else
|
91
|
-
raise
|
91
|
+
raise RailsLatex::ProcessingError.new(
|
92
|
+
"rails-latex failed: See #{input.sub(/\.tex$/,'.log')} for details",
|
93
|
+
File.open(input).read,
|
94
|
+
File.open(input.sub(/\.tex$/,'.log')).read
|
95
|
+
)
|
92
96
|
end
|
93
97
|
result
|
94
98
|
end
|
data/lib/rails-latex/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-latex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Baier
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- examples/rails-latex-demo/public/robots.txt
|
161
161
|
- lib/rails-latex.rb
|
162
162
|
- lib/rails-latex/erb_latex.rb
|
163
|
+
- lib/rails-latex/errors.rb
|
163
164
|
- lib/rails-latex/latex_to_pdf.rb
|
164
165
|
- lib/rails-latex/version.rb
|
165
166
|
- rails-latex.gemspec
|
@@ -183,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
184
|
version: '0'
|
184
185
|
requirements: []
|
185
186
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.5.2
|
187
188
|
signing_key:
|
188
189
|
specification_version: 4
|
189
190
|
summary: A LaTeX to PDF rails renderer.
|