latexpdf 0.4.5 → 0.4.6
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/lib/latexpdf.rb +3 -3
- data/lib/latexpdf/pdf_generator.rb +7 -3
- data/lib/latexpdf/version.rb +1 -1
- data/test/dummy/log/test.log +85 -0
- data/test/latexpdf/pdf_generator_test.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b280ff77af67b1a0243b77706d8e329310a1b01f
|
4
|
+
data.tar.gz: ad386b38a1859bee543bae875d41d7b5c67e7521
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 652368170359d89174ab5ddf1328200b35b9fa909662cdec48680472af2f5145532693bff8df0be63b2b671a4704e6d8bee1b08caeac2c3772cdf71d65ab89e6
|
7
|
+
data.tar.gz: 965da69beb40c5274c20492721787fd4140ac5f3c425c320745bd46b1dae3aab11b53c1c9de5996f65fd379ad214eb190bd96849f439c6603c4c36b8f580a012
|
data/lib/latexpdf.rb
CHANGED
@@ -36,11 +36,11 @@ module Latexpdf
|
|
36
36
|
@logger ||= configuration.logger
|
37
37
|
end
|
38
38
|
|
39
|
-
def self.compile(tex)
|
39
|
+
def self.compile(tex, target=nil)
|
40
40
|
generator = PdfGenerator.new(tex)
|
41
41
|
begin
|
42
|
-
generator.generate
|
43
|
-
generator.content
|
42
|
+
generator.generate target
|
43
|
+
generator.content unless target
|
44
44
|
ensure
|
45
45
|
generator.cleanup
|
46
46
|
end
|
@@ -6,13 +6,13 @@
|
|
6
6
|
# +errors+ will contain latex log on failure
|
7
7
|
module Latexpdf
|
8
8
|
class PdfGenerator
|
9
|
-
attr_reader :errors, :template, :pdf_file
|
9
|
+
attr_reader :errors, :template, :pdf_file
|
10
10
|
|
11
11
|
def initialize(tex)
|
12
12
|
@template = tex
|
13
13
|
end
|
14
14
|
|
15
|
-
def generate
|
15
|
+
def generate(target_file=nil)
|
16
16
|
write_tex
|
17
17
|
Latexpdf.configuration.passes.times do
|
18
18
|
run_tex
|
@@ -20,7 +20,7 @@ module Latexpdf
|
|
20
20
|
|
21
21
|
if pdf_exist?
|
22
22
|
@pdf_file = target_pdf_file
|
23
|
-
|
23
|
+
FileUtils.cp target_pdf_file, target_file if target_file
|
24
24
|
else
|
25
25
|
raise LatexpdfError.new "Tex failed: No PDF generated"
|
26
26
|
end
|
@@ -37,6 +37,10 @@ module Latexpdf
|
|
37
37
|
File.exist?(target_pdf_file)
|
38
38
|
end
|
39
39
|
|
40
|
+
def content
|
41
|
+
File.read(pdf_file) if pdf_exist?
|
42
|
+
end
|
43
|
+
|
40
44
|
protected
|
41
45
|
|
42
46
|
def build_path
|
data/lib/latexpdf/version.rb
CHANGED
data/test/dummy/log/test.log
CHANGED
@@ -100,3 +100,88 @@ Completed 200 OK in 1203ms (Views: 1202.9ms)
|
|
100
100
|
-------------------------------------------------------------
|
101
101
|
ConfigTest: test_Build_path_is_Rails_temporary_dir_by_default
|
102
102
|
-------------------------------------------------------------
|
103
|
+
-------------------------------------------------------------
|
104
|
+
ConfigTest: test_Build_path_is_Rails_temporary_dir_by_default
|
105
|
+
-------------------------------------------------------------
|
106
|
+
-----------------------------------------------------------
|
107
|
+
RenderingTest: test_Generate_PDF_on_the_fly_in_a_controller
|
108
|
+
-----------------------------------------------------------
|
109
|
+
Started GET "/tex/example.pdf" for 127.0.0.1 at 2016-06-02 17:36:51 +0200
|
110
|
+
Processing by TexController#example as PDF
|
111
|
+
Rendered tex/example.pdf.tex (3601.9ms)
|
112
|
+
Completed 200 OK in 3612ms (Views: 3611.2ms)
|
113
|
+
---------------------------------------------------------
|
114
|
+
RenderingTest: test_Generate_PDF_using_escaped_characters
|
115
|
+
---------------------------------------------------------
|
116
|
+
Started GET "/tex/example2.pdf" for 127.0.0.1 at 2016-06-02 17:36:55 +0200
|
117
|
+
Processing by TexController#example2 as PDF
|
118
|
+
Rendered tex/example2.pdf.tex (3158.4ms)
|
119
|
+
Completed 200 OK in 3161ms (Views: 3160.3ms)
|
120
|
+
-----------------------------------------------------------
|
121
|
+
RenderingTest: test_Generate_PDF_on_the_fly_in_a_controller
|
122
|
+
-----------------------------------------------------------
|
123
|
+
Started GET "/tex/example.pdf" for 127.0.0.1 at 2016-06-02 17:37:01 +0200
|
124
|
+
Processing by TexController#example as PDF
|
125
|
+
Rendered tex/example.pdf.tex (1211.0ms)
|
126
|
+
Completed 200 OK in 1218ms (Views: 1217.5ms)
|
127
|
+
---------------------------------------------------------
|
128
|
+
RenderingTest: test_Generate_PDF_using_escaped_characters
|
129
|
+
---------------------------------------------------------
|
130
|
+
Started GET "/tex/example2.pdf" for 127.0.0.1 at 2016-06-02 17:37:02 +0200
|
131
|
+
Processing by TexController#example2 as PDF
|
132
|
+
Rendered tex/example2.pdf.tex (1200.2ms)
|
133
|
+
Completed 200 OK in 1202ms (Views: 1201.6ms)
|
134
|
+
-------------------------------------------------------------
|
135
|
+
ConfigTest: test_Build_path_is_Rails_temporary_dir_by_default
|
136
|
+
-------------------------------------------------------------
|
137
|
+
-------------------------------------------------------------
|
138
|
+
ConfigTest: test_Build_path_is_Rails_temporary_dir_by_default
|
139
|
+
-------------------------------------------------------------
|
140
|
+
-----------------------------------------------------------
|
141
|
+
RenderingTest: test_Generate_PDF_on_the_fly_in_a_controller
|
142
|
+
-----------------------------------------------------------
|
143
|
+
Started GET "/tex/example.pdf" for 127.0.0.1 at 2016-06-02 17:39:02 +0200
|
144
|
+
Processing by TexController#example as PDF
|
145
|
+
Rendered tex/example.pdf.tex (2905.5ms)
|
146
|
+
Completed 200 OK in 2912ms (Views: 2911.8ms)
|
147
|
+
---------------------------------------------------------
|
148
|
+
RenderingTest: test_Generate_PDF_using_escaped_characters
|
149
|
+
---------------------------------------------------------
|
150
|
+
Started GET "/tex/example2.pdf" for 127.0.0.1 at 2016-06-02 17:39:05 +0200
|
151
|
+
Processing by TexController#example2 as PDF
|
152
|
+
Rendered tex/example2.pdf.tex (3204.8ms)
|
153
|
+
Completed 200 OK in 3208ms (Views: 3207.8ms)
|
154
|
+
-------------------------------------------------------------
|
155
|
+
ConfigTest: test_Build_path_is_Rails_temporary_dir_by_default
|
156
|
+
-------------------------------------------------------------
|
157
|
+
-----------------------------------------------------------
|
158
|
+
RenderingTest: test_Generate_PDF_on_the_fly_in_a_controller
|
159
|
+
-----------------------------------------------------------
|
160
|
+
Started GET "/tex/example.pdf" for 127.0.0.1 at 2016-06-02 17:52:30 +0200
|
161
|
+
Processing by TexController#example as PDF
|
162
|
+
Rendered tex/example.pdf.tex (1780.4ms)
|
163
|
+
Completed 200 OK in 1790ms (Views: 1789.4ms)
|
164
|
+
---------------------------------------------------------
|
165
|
+
RenderingTest: test_Generate_PDF_using_escaped_characters
|
166
|
+
---------------------------------------------------------
|
167
|
+
Started GET "/tex/example2.pdf" for 127.0.0.1 at 2016-06-02 17:52:32 +0200
|
168
|
+
Processing by TexController#example2 as PDF
|
169
|
+
Rendered tex/example2.pdf.tex (1813.8ms)
|
170
|
+
Completed 200 OK in 1816ms (Views: 1815.8ms)
|
171
|
+
-------------------------------------------------------------
|
172
|
+
ConfigTest: test_Build_path_is_Rails_temporary_dir_by_default
|
173
|
+
-------------------------------------------------------------
|
174
|
+
-----------------------------------------------------------
|
175
|
+
RenderingTest: test_Generate_PDF_on_the_fly_in_a_controller
|
176
|
+
-----------------------------------------------------------
|
177
|
+
Started GET "/tex/example.pdf" for 127.0.0.1 at 2016-06-02 17:53:29 +0200
|
178
|
+
Processing by TexController#example as PDF
|
179
|
+
Rendered tex/example.pdf.tex (1736.6ms)
|
180
|
+
Completed 200 OK in 1747ms (Views: 1746.4ms)
|
181
|
+
---------------------------------------------------------
|
182
|
+
RenderingTest: test_Generate_PDF_using_escaped_characters
|
183
|
+
---------------------------------------------------------
|
184
|
+
Started GET "/tex/example2.pdf" for 127.0.0.1 at 2016-06-02 17:53:31 +0200
|
185
|
+
Processing by TexController#example2 as PDF
|
186
|
+
Rendered tex/example2.pdf.tex (1788.7ms)
|
187
|
+
Completed 200 OK in 1791ms (Views: 1790.8ms)
|
@@ -45,8 +45,31 @@ module Latexpdf
|
|
45
45
|
assert_match (/Tex failed: No PDF generated/), e.message
|
46
46
|
end
|
47
47
|
|
48
|
+
def test_content_exists_until_cleanup
|
49
|
+
set_subject "minimal.tex"
|
50
|
+
assert_nil subject.generate
|
51
|
+
refute_nil subject.content
|
52
|
+
subject.cleanup
|
53
|
+
assert_nil subject.content
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_with_target_file
|
57
|
+
set_subject "minimal.tex"
|
58
|
+
assert_nil subject.generate tmp_file
|
59
|
+
assert File.file?(tmp_file)
|
60
|
+
reader = PDF::Reader.new(tmp_file)
|
61
|
+
assert_match (/Test latex document/), reader.pages.first.text
|
62
|
+
subject.cleanup
|
63
|
+
assert File.file?(tmp_file)
|
64
|
+
FileUtils.rm tmp_file
|
65
|
+
end
|
66
|
+
|
48
67
|
protected
|
49
68
|
|
69
|
+
def tmp_file
|
70
|
+
@tmp ||= File.join(__dir__, "..","dummy","tmp","#{SecureRandom.hex}.pdf")
|
71
|
+
end
|
72
|
+
|
50
73
|
def subject
|
51
74
|
@subject
|
52
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: latexpdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthijs Ooms
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|