rtex 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ module RTeX
4
4
 
5
5
  # Escape text using +replacements+
6
6
  def escape(text)
7
- replacements.inject(text) do |corpus, (pattern, replacement)|
7
+ replacements.inject(text.to_s) do |corpus, (pattern, replacement)|
8
8
  corpus.gsub(pattern, replacement)
9
9
  end
10
10
  end
@@ -25,6 +25,12 @@ module RTeX
25
25
  if defined?(@view)
26
26
  @view.template_format = :pdf
27
27
  end
28
+ # Tag for RTeX
29
+ # TODO: Move options into TemplateHandler from Controller
30
+ # (need to handle send_file)
31
+ def @view.rendered_with_rtex
32
+ true
33
+ end
28
34
  end
29
35
  end
30
36
 
@@ -35,7 +41,7 @@ module RTeX
35
41
 
36
42
  def render_with_rtex(options=nil, *args, &block)
37
43
  result = render_without_rtex(options, *args, &block)
38
- if result.is_a?(String) && @template.template_format == :pdf
44
+ if result.is_a?(String) && @template.respond_to?(:rendered_with_rtex)
39
45
  options ||= {}
40
46
  ::RTeX::Document.new(result, options.merge(:processed => true)).to_pdf do |filename|
41
47
  serve_file = Tempfile.new('rtex-pdf')
@@ -65,7 +65,7 @@ module RTeX
65
65
 
66
66
  MAJOR = 2
67
67
  MINOR = 0
68
- TINY = 3
68
+ TINY = 4
69
69
 
70
70
  # The current version as a Version instance
71
71
  CURRENT = new(MAJOR, MINOR, TINY)
@@ -1,18 +1,18 @@
1
1
 
2
- # Gem::Specification for Rtex-2.0.3
2
+ # Gem::Specification for Rtex-2.0.4
3
3
  # Originally generated by Echoe
4
4
 
5
5
  --- !ruby/object:Gem::Specification
6
6
  name: rtex
7
7
  version: !ruby/object:Gem::Version
8
- version: 2.0.3
8
+ version: 2.0.4
9
9
  platform: ruby
10
10
  authors:
11
11
  - Bruce Williams, Wiebe Cazemier
12
12
  autorequire:
13
13
  bindir: bin
14
14
 
15
- date: 2008-08-27 00:00:00 -05:00
15
+ date: 2008-09-20 00:00:00 -06:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -11,11 +11,23 @@ class DocumentTest < Test::Unit::TestCase
11
11
  should "have a to_pdf method" do
12
12
  assert document(:first).respond_to?(:to_pdf)
13
13
  end
14
-
15
- should "escape characters" do
16
- assert_equal '\textbackslash{}\textasciitilde{}', RTeX::Document.escape('\~')
14
+
15
+ context "when escaping" do
16
+ setup do
17
+ @obj = Object.new
18
+ def @obj.to_s
19
+ '\~'
20
+ end
21
+ @escaped = '\textbackslash{}\textasciitilde{}'
22
+ end
23
+ should "escape character" do
24
+ assert_equal @escaped, RTeX::Document.escape(@obj.to_s)
25
+ end
26
+ should "convert argument to string before attempting escape" do
27
+ assert_equal @escaped, RTeX::Document.escape(@obj)
28
+ end
17
29
  end
18
-
30
+
19
31
  should "use a to_pdf block to move a file to a relative path" do
20
32
  begin
21
33
  path = File.expand_path(File.dirname(__FILE__) << '/tmp/this_is_relative_to_pwd.pdf')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtex
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruce Williams, Wiebe Cazemier
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-27 00:00:00 -05:00
12
+ date: 2008-09-20 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency