prawn_cocktail_rails 0.1.0

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/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in prawn_cocktail.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # PrawnCocktailRails
2
+
3
+ Ruby on Rails integration for [PrawnCocktail](http://github.com/barsoom/prawn_cocktail).
4
+
5
+ NOTE: Work in progress; well used but untested.
6
+
7
+ ## TODO
8
+
9
+ * Tests
10
+
11
+ ## Usage
12
+
13
+ Please see [PrawnCocktail](http://github.com/barsoom/prawn_cocktail).
14
+
15
+ PrawnCocktailRails adds a `send_pdf` method to your controllers:
16
+
17
+ ``` ruby
18
+ class InvoicesController < ApplicationController
19
+ def show
20
+ invoice = Invoice.find(params[:id])
21
+ document = InvoiceDocument.new(invoice)
22
+ send_pdf document
23
+ end
24
+ end
25
+ ```
26
+
27
+
28
+ It configures PrawnCocktail to look for its views in `app/views/documents`.
29
+
30
+ It also adds `app/documents/helpers` to the Rails autoload path so you can put your PrawnCocktail helpers there.
31
+
32
+ We suggest putting your documents in `app/documents`.
33
+
34
+ And that's it. The rest is all [PrawnCocktail](http://github.com/barsoom/prawn_cocktail).
35
+
36
+ ## Installation
37
+
38
+ Add this line to your application's Gemfile:
39
+
40
+ gem 'prawn_cocktail_rails'
41
+
42
+ And then execute:
43
+
44
+ bundle
45
+
46
+ As this library depends on `prawn_cocktail`, you only need to list this one to get both.
47
+
48
+ ## License
49
+
50
+ Copyright (c) 2013 [Barsoom AB](http://barsoom.se)
51
+
52
+ MIT License
53
+
54
+ Permission is hereby granted, free of charge, to any person obtaining
55
+ a copy of this software and associated documentation files (the
56
+ "Software"), to deal in the Software without restriction, including
57
+ without limitation the rights to use, copy, modify, merge, publish,
58
+ distribute, sublicense, and/or sell copies of the Software, and to
59
+ permit persons to whom the Software is furnished to do so, subject to
60
+ the following conditions:
61
+
62
+ The above copyright notice and this permission notice shall be
63
+ included in all copies or substantial portions of the Software.
64
+
65
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
66
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
67
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
68
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
69
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
70
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
71
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ module PrawnCocktailRails
2
+ module Controller
3
+ private
4
+
5
+ def send_pdf(document)
6
+ send_data(
7
+ document.render,
8
+ type: "application/pdf",
9
+ disposition: "attachment",
10
+ filename: document.filename
11
+ )
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ require "rails"
2
+
3
+ module PrawnCocktailRails
4
+ class Railtie < Rails::Railtie
5
+ initializer "prawn_cocktail.autoload", before: :set_autoload_paths do |app|
6
+ app.config.autoload_paths << "#{app.config.root}/app/documents/helpers"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module PrawnCocktailRails
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,10 @@
1
+ require "prawn_cocktail_rails/version"
2
+ require "prawn_cocktail_rails/controller"
3
+ require "prawn_cocktail_rails/railtie"
4
+ require "prawn_cocktail"
5
+
6
+ class ActionController::Base
7
+ include PrawnCocktailRails::Controller
8
+ end
9
+
10
+ PrawnCocktail.template_root = "app/views/documents"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'prawn_cocktail_rails/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "prawn_cocktail_rails"
8
+ gem.version = PrawnCocktailRails::VERSION
9
+ gem.authors = ["Henrik Nyh"]
10
+ gem.email = ["henrik@barsoom.se"]
11
+ gem.summary = "PrawnCocktail on Rails."
12
+ gem.homepage = ""
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.require_paths = ["lib"]
18
+
19
+ gem.add_dependency "prawn_cocktail", ">=0.4.0"
20
+ gem.add_dependency "rails"
21
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prawn_cocktail_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Henrik Nyh
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: prawn_cocktail
16
+ requirement: &70330186124280 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.4.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70330186124280
25
+ - !ruby/object:Gem::Dependency
26
+ name: rails
27
+ requirement: &70330186123660 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70330186123660
36
+ description:
37
+ email:
38
+ - henrik@barsoom.se
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - README.md
46
+ - Rakefile
47
+ - lib/prawn_cocktail_rails.rb
48
+ - lib/prawn_cocktail_rails/controller.rb
49
+ - lib/prawn_cocktail_rails/railtie.rb
50
+ - lib/prawn_cocktail_rails/version.rb
51
+ - prawn_cocktail.gemspec
52
+ homepage: ''
53
+ licenses: []
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 1.8.5
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: PrawnCocktail on Rails.
76
+ test_files: []
77
+ has_rdoc: