crayfish 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/crayfish/action_controller.rb +4 -0
- data/lib/crayfish/action_view.rb +2 -0
- data/lib/crayfish/rails/pdf.rb +8 -3
- data/lib/crayfish/version.rb +1 -1
- data/test/crayfish_test.rb +4 -0
- data/test/pdf_test.rb +44 -0
- metadata +16 -14
data/lib/crayfish/action_view.rb
CHANGED
data/lib/crayfish/rails/pdf.rb
CHANGED
@@ -29,9 +29,14 @@ module Crayfish
|
|
29
29
|
attr_reader :options
|
30
30
|
|
31
31
|
def initialize(controller)
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
controller_options = controller.send(:options) || {}
|
33
|
+
@options = Crayfish::ActionController.options.merge(Hash[*controller_options.map{ |k,v| [k.to_sym,v] }.flatten])
|
34
|
+
|
35
|
+
if options[:html]
|
36
|
+
controller.response.content_type ||= Mime::HTML
|
37
|
+
else
|
38
|
+
controller.response.content_type ||= Mime::PDF
|
39
|
+
end
|
35
40
|
|
36
41
|
inline = options[:inline] ? 'inline' : 'attachment'
|
37
42
|
filename = options[:filename] ? "filename=#{options[:filename]}" : nil
|
data/lib/crayfish/version.rb
CHANGED
data/test/crayfish_test.rb
CHANGED
data/test/pdf_test.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright (c) 2012 Bingoentreprenøren AS
|
2
|
+
# Copyright (c) 2012 Patrick Hanevold
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'test_helper'
|
24
|
+
|
25
|
+
class PDFTest < ActiveSupport::TestCase
|
26
|
+
|
27
|
+
test 'merge options' do
|
28
|
+
response = mock('Response')
|
29
|
+
response.expects(:content_type).returns(nil)
|
30
|
+
response.expects(:content_type=).with(Mime::PDF)
|
31
|
+
|
32
|
+
headers = mock('Headers')
|
33
|
+
headers.expects(:[]=).with('Content-Disposition', 'inline')
|
34
|
+
|
35
|
+
controller = stub('Controller')
|
36
|
+
controller.stubs(:options).returns(:controller => :options)
|
37
|
+
controller.stubs(:response).returns(response)
|
38
|
+
controller.stubs(:headers).returns(headers)
|
39
|
+
|
40
|
+
pdf = Crayfish::Rails::PDF.new(controller)
|
41
|
+
assert_equal pdf.options, :inline=>true, :prawn=>{}, :controller=>:options
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crayfish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
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-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70342194319800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70342194319800
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: prawn
|
27
|
-
requirement: &
|
27
|
+
requirement: &70342194318480 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70342194318480
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: nokogiri
|
38
|
-
requirement: &
|
38
|
+
requirement: &70342194315580 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70342194315580
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: sqlite3
|
49
|
-
requirement: &
|
49
|
+
requirement: &70342194313980 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70342194313980
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: mocha
|
60
|
-
requirement: &
|
60
|
+
requirement: &70342194311060 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70342194311060
|
69
69
|
description: Crayfish - PDF templating for Rails
|
70
70
|
email:
|
71
71
|
- patrick.hanevold@gmail.com
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- test/dummy/public/favicon.ico
|
117
117
|
- test/dummy/script/rails
|
118
118
|
- test/html_test.rb
|
119
|
+
- test/pdf_test.rb
|
119
120
|
- test/test_helper.rb
|
120
121
|
homepage: http://github.com/patrickhno
|
121
122
|
licenses: []
|
@@ -131,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
132
|
version: '0'
|
132
133
|
segments:
|
133
134
|
- 0
|
134
|
-
hash:
|
135
|
+
hash: 122081209892541250
|
135
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
137
|
none: false
|
137
138
|
requirements:
|
@@ -140,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
141
|
version: '0'
|
141
142
|
segments:
|
142
143
|
- 0
|
143
|
-
hash:
|
144
|
+
hash: 122081209892541250
|
144
145
|
requirements: []
|
145
146
|
rubyforge_project:
|
146
147
|
rubygems_version: 1.8.15
|
@@ -180,4 +181,5 @@ test_files:
|
|
180
181
|
- test/dummy/public/favicon.ico
|
181
182
|
- test/dummy/script/rails
|
182
183
|
- test/html_test.rb
|
184
|
+
- test/pdf_test.rb
|
183
185
|
- test/test_helper.rb
|