rails-latex 1.0.9 → 1.0.10
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.
- data/examples/rails-latex-demo/Gemfile +1 -1
- data/examples/rails-latex-demo/app/controllers/latex_example_controller.rb +7 -5
- data/examples/rails-latex-demo/app/views/latex_example/index.html.erb +3 -0
- data/examples/rails-latex-demo/config/initializers/mime_types.rb +1 -1
- data/lib/rails-latex/latex_to_pdf.rb +17 -16
- data/lib/rails-latex/version.rb +1 -1
- data/test/test_latex_to_pdf.rb +2 -2
- metadata +17 -7
@@ -3,17 +3,19 @@ class LatexExampleController < ApplicationController
|
|
3
3
|
end
|
4
4
|
|
5
5
|
def barcode
|
6
|
-
render :layout => 'barcode'
|
6
|
+
render :layout => 'barcode', formats: [:pdf]
|
7
7
|
end
|
8
8
|
|
9
9
|
def barcode_as_string
|
10
|
-
|
11
|
-
|
12
|
-
@pdf=render_to_string(action: 'barcode', layout: "barcode")
|
10
|
+
|
11
|
+
old_content_type = self.content_type
|
12
|
+
@pdf=render_to_string(action: 'barcode', layout: "barcode", formats: [:pdf])
|
13
|
+
self.content_type = old_content_type # render_to_string changes content_type
|
14
|
+
|
13
15
|
File.open(file="#{Rails.root}/tmp/a.pdf",'w:binary') do |io|
|
14
16
|
io.write(@pdf)
|
15
17
|
end
|
16
|
-
|
18
|
+
|
17
19
|
render text: "wrote #{file}"
|
18
20
|
end
|
19
21
|
end
|
@@ -4,5 +4,8 @@
|
|
4
4
|
|
5
5
|
<li><%= link_to "print barcode", latex_example_barcode_path(:format => :pdf) %></li>
|
6
6
|
|
7
|
+
<li><%= link_to "print barcode - with no '.pdf' in url", latex_example_barcode_path %></li>
|
8
|
+
|
9
|
+
|
7
10
|
<li><%= link_to "generate barcode pdf as string", latex_example_barcode_as_string_path %> and write to <tt><%= "#{Rails.root}/tmp/a.pdf" %></tt> </li>
|
8
11
|
</ul>
|
@@ -3,4 +3,4 @@
|
|
3
3
|
# Add new mime types for use in respond_to blocks:
|
4
4
|
# Mime::Type.register "text/richtext", :rtf
|
5
5
|
# Mime::Type.register_alias "text/html", :iphone
|
6
|
-
Mime::Type.register "application/pdf", :pdf, ['text/pdf'], ['pdf']
|
6
|
+
# Mime::Type.register "application/pdf", :pdf, ['text/pdf'], ['pdf']
|
@@ -18,22 +18,23 @@ class LatexToPdf
|
|
18
18
|
input=File.join(dir,'input.tex')
|
19
19
|
FileUtils.mkdir_p(dir)
|
20
20
|
File.open(input,'wb') {|io| io.write(code) }
|
21
|
-
Process.waitpid(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
21
|
+
Process.waitpid(
|
22
|
+
fork do
|
23
|
+
begin
|
24
|
+
Dir.chdir dir
|
25
|
+
STDOUT.reopen("input.log","a")
|
26
|
+
STDERR.reopen(STDOUT)
|
27
|
+
args=config[:arguments] + %w[-shell-escape -interaction batchmode -halt-on-error input.tex]
|
28
|
+
system config[:command],'-draftmode',*args if parse_twice
|
29
|
+
exec config[:command],*args
|
30
|
+
rescue
|
31
|
+
File.open("input.log",'a') {|io|
|
32
|
+
io.write("#{$!.message}:\n#{$!.backtrace.join("\n")}\n")
|
33
|
+
}
|
34
|
+
ensure
|
35
|
+
Process.exit! 1
|
36
|
+
end
|
37
|
+
end)
|
37
38
|
if File.exist?(pdf_file=input.sub(/\.tex$/,'.pdf'))
|
38
39
|
FileUtils.mv(input.sub(/\.tex$/,'.log'),File.join(dir,'..','input.log'))
|
39
40
|
result=File.read(pdf_file)
|
data/lib/rails-latex/version.rb
CHANGED
data/test/test_latex_to_pdf.rb
CHANGED
@@ -32,7 +32,7 @@ class TestLatexToPdf < Test::Unit::TestCase
|
|
32
32
|
end
|
33
33
|
assert_equal "The last page is ??.\n\n1\n\n\f", `pdftotext #{pdf_file} -`
|
34
34
|
|
35
|
-
assert_equal ["#{TMP_DIR}/rails-latex/input.log"], Dir["#{TMP_DIR}/rails-latex/*"]
|
35
|
+
assert_equal ["#{TMP_DIR}/tmp/rails-latex/input.log"], Dir["#{TMP_DIR}/tmp/rails-latex/*"]
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_generate_pdf_two_parse
|
@@ -42,7 +42,7 @@ class TestLatexToPdf < Test::Unit::TestCase
|
|
42
42
|
end
|
43
43
|
assert_equal "The last page is 1.\n\n1\n\n\f", `pdftotext #{pdf_file} -`
|
44
44
|
|
45
|
-
assert_equal ["#{TMP_DIR}/rails-latex/input.log"], Dir["#{TMP_DIR}/rails-latex/*"]
|
45
|
+
assert_equal ["#{TMP_DIR}/tmp/rails-latex/input.log"], Dir["#{TMP_DIR}/tmp/rails-latex/*"]
|
46
46
|
end
|
47
47
|
|
48
48
|
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: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: RedCloth
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,7 +37,12 @@ dependencies:
|
|
32
37
|
version: 4.2.7
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 4.2.7
|
36
46
|
description: rails-latex is a renderer for rails 3 which allows tex files with erb
|
37
47
|
to be turned into an inline pdf.
|
38
48
|
email:
|
@@ -108,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
118
|
version: '0'
|
109
119
|
requirements: []
|
110
120
|
rubyforge_project:
|
111
|
-
rubygems_version: 1.8.
|
121
|
+
rubygems_version: 1.8.19
|
112
122
|
signing_key:
|
113
123
|
specification_version: 3
|
114
124
|
summary: A LaTeX to pdf rails 3 renderer.
|