rails-latex 1.0.7 → 1.0.8
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 +11 -0
- data/examples/rails-latex-demo/app/views/latex_example/index.html.erb +2 -0
- data/examples/rails-latex-demo/config/environments/development.rb +1 -1
- data/examples/rails-latex-demo/config/routes.rb +1 -0
- data/lib/rails-latex/latex_to_pdf.rb +1 -1
- data/lib/rails-latex/version.rb +1 -1
- data/test/test_doc.tex +2 -1
- data/test/test_latex_to_pdf.rb +29 -7
- metadata +39 -43
@@ -5,4 +5,15 @@ class LatexExampleController < ApplicationController
|
|
5
5
|
def barcode
|
6
6
|
render :layout => 'barcode'
|
7
7
|
end
|
8
|
+
|
9
|
+
def barcode_as_string
|
10
|
+
old_formats = formats
|
11
|
+
self.formats = ['pdf']
|
12
|
+
@pdf=render_to_string(action: 'barcode', layout: "barcode")
|
13
|
+
File.open(file="#{Rails.root}/tmp/a.pdf",'w:binary') do |io|
|
14
|
+
io.write(@pdf)
|
15
|
+
end
|
16
|
+
self.formats = old_formats
|
17
|
+
render text: "wrote #{file}"
|
18
|
+
end
|
8
19
|
end
|
@@ -3,4 +3,6 @@
|
|
3
3
|
<li> <%= link_to "print", latex_example_path(:format => :pdf) %></li>
|
4
4
|
|
5
5
|
<li><%= link_to "print barcode", latex_example_barcode_path(:format => :pdf) %></li>
|
6
|
+
|
7
|
+
<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>
|
6
8
|
</ul>
|
@@ -11,7 +11,7 @@ RailsLatexDemo::Application.configure do
|
|
11
11
|
|
12
12
|
# Show full error reports and disable caching
|
13
13
|
config.consider_all_requests_local = true
|
14
|
-
config.action_view.debug_rjs = true
|
14
|
+
# config.action_view.debug_rjs = true
|
15
15
|
config.action_controller.perform_caching = false
|
16
16
|
|
17
17
|
# Don't care if the mailer can't send
|
@@ -1,6 +1,7 @@
|
|
1
1
|
RailsLatexDemo::Application.routes.draw do
|
2
2
|
match 'latex_example' => "latex_example#index"
|
3
3
|
match 'latex_example/barcode' => "latex_example#barcode"
|
4
|
+
match 'latex_example/barcode_as_string' => "latex_example#barcode_as_string"
|
4
5
|
|
5
6
|
root :to => "latex_example#index"
|
6
7
|
end
|
@@ -12,8 +12,8 @@ class LatexToPdf
|
|
12
12
|
#
|
13
13
|
# The parse_twice argument is deprecated in favor of using config[:parse_twice] instead.
|
14
14
|
def self.generate_pdf(code,config,parse_twice=nil)
|
15
|
-
parse_twice=config[:parse_twice] if parse_twice.nil?
|
16
15
|
config=self.config.merge(config)
|
16
|
+
parse_twice=config[:parse_twice] if parse_twice.nil?
|
17
17
|
dir=File.join(Rails.root,'tmp','rails-latex',"#{Process.pid}-#{Thread.current.hash}")
|
18
18
|
input=File.join(dir,'input.tex')
|
19
19
|
FileUtils.mkdir_p(dir)
|
data/lib/rails-latex/version.rb
CHANGED
data/test/test_doc.tex
CHANGED
data/test/test_latex_to_pdf.rb
CHANGED
@@ -5,6 +5,20 @@ require 'ostruct'
|
|
5
5
|
Rails=OpenStruct.new(:root => TMP_DIR=File.expand_path("../tmp",__FILE__))
|
6
6
|
|
7
7
|
class TestLatexToPdf < Test::Unit::TestCase
|
8
|
+
def teardown
|
9
|
+
LatexToPdf.instance_eval { @config=nil }
|
10
|
+
end
|
11
|
+
|
12
|
+
def write_pdf
|
13
|
+
FileUtils.mkdir_p(TMP_DIR)
|
14
|
+
pdf_file=File.join(TMP_DIR,'out.pdf')
|
15
|
+
File.delete(pdf_file) if File.exist?(pdf_file)
|
16
|
+
File.open(pdf_file,'wb') do |wio|
|
17
|
+
wio.write(yield)
|
18
|
+
end
|
19
|
+
pdf_file
|
20
|
+
end
|
21
|
+
|
8
22
|
def test_escape
|
9
23
|
assert_equal "dsf \\textless{} \\textgreater{} \\& ! @ \\# \\$ \\% \\textasciicircum{} \\textasciitilde{} \\textbackslash{} fds", LatexToPdf.escape_latex('dsf < > & ! @ # $ % ^ ~ \\ fds')
|
10
24
|
LatexToPdf.instance_eval{@latex_escaper=nil}
|
@@ -12,15 +26,23 @@ class TestLatexToPdf < Test::Unit::TestCase
|
|
12
26
|
assert_equal "dsf \\textless{} \\textgreater{} \\& ! @ \\# \\$ \\% \\^{} \\~{} \\textbackslash{} fds", LatexToPdf.escape_latex('dsf < > & ! @ # $ % ^ ~ \\ fds')
|
13
27
|
end
|
14
28
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
File.delete(pdf_file) if File.exist?(pdf_file)
|
19
|
-
File.open(pdf_file,'wb') do |wio|
|
20
|
-
wio.write(LatexToPdf.generate_pdf(IO.read(File.expand_path('../test_doc.tex',__FILE__)),{}))
|
29
|
+
def test_generate_pdf_one_parse
|
30
|
+
pdf_file=write_pdf do
|
31
|
+
LatexToPdf.generate_pdf(IO.read(File.expand_path('../test_doc.tex',__FILE__)),{})
|
21
32
|
end
|
22
|
-
assert_equal "
|
33
|
+
assert_equal "The last page is ??.\n\n1\n\n\f", `pdftotext #{pdf_file} -`
|
23
34
|
|
24
35
|
assert_equal ["#{TMP_DIR}/rails-latex/input.log"], Dir["#{TMP_DIR}/rails-latex/*"]
|
25
36
|
end
|
37
|
+
|
38
|
+
def test_generate_pdf_two_parse
|
39
|
+
pdf_file=write_pdf do
|
40
|
+
LatexToPdf.config[:parse_twice]=true
|
41
|
+
LatexToPdf.generate_pdf(IO.read(File.expand_path('../test_doc.tex',__FILE__)),{})
|
42
|
+
end
|
43
|
+
assert_equal "The last page is 1.\n\n1\n\n\f", `pdftotext #{pdf_file} -`
|
44
|
+
|
45
|
+
assert_equal ["#{TMP_DIR}/rails-latex/input.log"], Dir["#{TMP_DIR}/rails-latex/*"]
|
46
|
+
end
|
47
|
+
|
26
48
|
end
|
metadata
CHANGED
@@ -1,50 +1,48 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-latex
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.8
|
4
5
|
prerelease:
|
5
|
-
version: 1.0.7
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Geoff Jacobsen
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-12-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: rails
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &9711700 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
23
21
|
version: 3.0.0
|
24
22
|
type: :runtime
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: RedCloth
|
28
23
|
prerelease: false
|
29
|
-
|
24
|
+
version_requirements: *9711700
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: RedCloth
|
27
|
+
requirement: &9726320 !ruby/object:Gem::Requirement
|
30
28
|
none: false
|
31
|
-
requirements:
|
32
|
-
- -
|
33
|
-
- !ruby/object:Gem::Version
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
34
32
|
version: 4.2.7
|
35
33
|
type: :development
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *9726320
|
36
|
+
description: rails-latex is a renderer for rails 3 which allows tex files with erb
|
37
|
+
to be turned into an inline pdf.
|
38
|
+
email:
|
39
39
|
- geoffjacobsen@gmail.com
|
40
40
|
executables: []
|
41
|
-
|
42
41
|
extensions: []
|
43
|
-
|
44
|
-
extra_rdoc_files:
|
42
|
+
extra_rdoc_files:
|
45
43
|
- MIT-LICENSE
|
46
44
|
- README.rdoc
|
47
|
-
files:
|
45
|
+
files:
|
48
46
|
- .gitignore
|
49
47
|
- Gemfile
|
50
48
|
- MIT-LICENSE
|
@@ -91,30 +89,28 @@ files:
|
|
91
89
|
- test/test_latex_to_pdf.rb
|
92
90
|
homepage: http://github.com/jacott/rails-latex
|
93
91
|
licenses: []
|
94
|
-
|
95
92
|
post_install_message:
|
96
|
-
rdoc_options:
|
93
|
+
rdoc_options:
|
97
94
|
- --main=README.rdoc
|
98
|
-
require_paths:
|
95
|
+
require_paths:
|
99
96
|
- lib
|
100
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
98
|
none: false
|
102
|
-
requirements:
|
103
|
-
- -
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version:
|
106
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
104
|
none: false
|
108
|
-
requirements:
|
109
|
-
- -
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
version:
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
112
109
|
requirements: []
|
113
|
-
|
114
110
|
rubyforge_project:
|
115
|
-
rubygems_version: 1.8.
|
111
|
+
rubygems_version: 1.8.11
|
116
112
|
signing_key:
|
117
113
|
specification_version: 3
|
118
114
|
summary: A LaTeX to pdf rails 3 renderer.
|
119
115
|
test_files: []
|
120
|
-
|
116
|
+
has_rdoc:
|