renderpdfasview 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/renderpdfasview.rb +18 -0
- data/lib/renderpdfasview/version.rb +3 -0
- data/renderpdfasview.gemspec +20 -0
- data/test/integration/navigation_test.rb +25 -0
- data/test/pdf_renderer_test.rb +13 -0
- data/test/support/integration_case.rb +5 -0
- data/test/test_helper.rb +22 -0
- metadata +85 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Sadan Masroor
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Renderpdfasview
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'renderpdfasview'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install renderpdfasview
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "renderpdfasview/version"
|
2
|
+
|
3
|
+
module Renderpdfasview
|
4
|
+
require "action_controller"
|
5
|
+
|
6
|
+
Mime::Type.register "application/pdf",:pdf
|
7
|
+
|
8
|
+
require "prawn"
|
9
|
+
|
10
|
+
|
11
|
+
ActionController::Renderers.add :pdf do |filename,options|
|
12
|
+
|
13
|
+
pdf = Prawn::Document.new
|
14
|
+
pdf.text render_to_string(options)
|
15
|
+
send_data(pdf.render,:filename => "#{filename}.pdf",:type => "application/pdf",:disposition => "attachment")
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/renderpdfasview/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Sadan Masroor"]
|
6
|
+
gem.email = ["sadanmasroor87@gmail.com"]
|
7
|
+
gem.description = %q{A Ruby Gem to render views in PDF Format}
|
8
|
+
gem.summary = %q{A Ruby Gem to render views in PDF Format}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.add_dependency("capybara", "0.4.0")
|
12
|
+
gem.add_dependency("prawn","0.8.4")
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($\)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.name = "renderpdfasview"
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.version = Renderpdfasview::VERSION
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class NavigationTest < ActiveSupport::IntegrationCase
|
4
|
+
|
5
|
+
test "pdf request sends a pdf as file" do
|
6
|
+
|
7
|
+
visit home_path
|
8
|
+
click_link 'PDF'
|
9
|
+
|
10
|
+
assert_equal 'binary',headers['Content-Transfer-Encoding']
|
11
|
+
assert_equal 'attachment; filename="contents.pdf"',headers['Content-Disposition']
|
12
|
+
assert_equal 'application/pdf',headers['Content-Type']
|
13
|
+
assert_match /Prawn/,page.source
|
14
|
+
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def headers
|
21
|
+
page.response_headers
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Configure Rails Envinronment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
ActionMailer::Base.delivery_method = :test
|
8
|
+
ActionMailer::Base.perform_deliveries = true
|
9
|
+
ActionMailer::Base.default_url_options[:host] = "test.com"
|
10
|
+
|
11
|
+
Rails.backtrace_cleaner.remove_silencers!
|
12
|
+
|
13
|
+
# Configure capybara for integration testing
|
14
|
+
require "capybara/rails"
|
15
|
+
Capybara.default_driver = :rack_test
|
16
|
+
Capybara.default_selector = :css
|
17
|
+
|
18
|
+
# Run any available migration
|
19
|
+
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
20
|
+
|
21
|
+
# Load support files
|
22
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: renderpdfasview
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sadan Masroor
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-15 00:00:00.000000000 +05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: capybara
|
17
|
+
requirement: &20263164 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - =
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.4.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *20263164
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: prawn
|
28
|
+
requirement: &20262864 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - =
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.8.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *20262864
|
37
|
+
description: A Ruby Gem to render views in PDF Format
|
38
|
+
email:
|
39
|
+
- sadanmasroor87@gmail.com
|
40
|
+
executables: []
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- Gemfile
|
46
|
+
- LICENSE
|
47
|
+
- README.md
|
48
|
+
- Rakefile
|
49
|
+
- lib/renderpdfasview.rb
|
50
|
+
- lib/renderpdfasview/version.rb
|
51
|
+
- renderpdfasview.gemspec
|
52
|
+
- test/integration/navigation_test.rb
|
53
|
+
- test/pdf_renderer_test.rb
|
54
|
+
- test/support/integration_case.rb
|
55
|
+
- test/test_helper.rb
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: ''
|
58
|
+
licenses: []
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.5.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: A Ruby Gem to render views in PDF Format
|
81
|
+
test_files:
|
82
|
+
- test/integration/navigation_test.rb
|
83
|
+
- test/pdf_renderer_test.rb
|
84
|
+
- test/support/integration_case.rb
|
85
|
+
- test/test_helper.rb
|