rails-latex 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4a58a2e53aa24c145c576d73874442e6799dd68
4
- data.tar.gz: 9d906c68f010aa291ce64f8e1ab6c35e8919c816
3
+ metadata.gz: ff4b9c5a6f0d50ff945189a640d587d3d4bb0370
4
+ data.tar.gz: fc784e7d27ecaeb386118b7d95137d4056594978
5
5
  SHA512:
6
- metadata.gz: efbf6f4dae0cf37ddc6e43f927864f4fa7f00b388ad5e1de478940ec7efd5e4b9f9cadae401bb3b9677b677ff4d35ebae5cdcdca308a1c5fd1c1ca2db9882eda
7
- data.tar.gz: 99dbca3cd469ffcd4b5285b97c115bf753d84c3b30326394fbe0dae0328744b84e4ca872f8d4a90ca4efe8a72033cdcf8181fcac7a914af166343cbf2b7bc37c
6
+ metadata.gz: e122d3d60fa0d5a8949f0d897c6a6929ec40fa74f880ca99abf9bffe446090d62fbbefcd9ccc613029f1a1ef37b6693b3613c10b6633ff05e9327ce0c87df53d
7
+ data.tar.gz: 91a9be775b3a09802e7b0eae7c3b47b384fb9aef0aafe26e8e749e2a52e86d36de82bc2a141e1a584ae261d76590734467c962581b90194fbe8311d5107c55e6
@@ -7,7 +7,7 @@
7
7
 
8
8
  == Description
9
9
 
10
- rails-latex is a renderer for rails 3 which allows tex files with erb to be turned into an inline pdf.
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
@@ -1,2 +1,3 @@
1
1
  require "rails-latex/version"
2
+ require "rails-latex/errors"
2
3
  require "rails-latex/erb_latex"
@@ -0,0 +1,10 @@
1
+ module RailsLatex
2
+ class ProcessingError < StandardError
3
+ attr_reader :src, :log
4
+ def initialize(msg = 'RailsLatex processing failed.', src = '', log = '')
5
+ @src = src
6
+ @log = log
7
+ super(msg)
8
+ end
9
+ end
10
+ end
@@ -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 "rails-latex failed: See #{input.sub(/\.tex$/,'.log')} for details"
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
@@ -1,3 +1,3 @@
1
1
  module RailsLatex
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
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.0
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: 2016-10-03 00:00:00.000000000 Z
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.2.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.