Skip to content
Browse files

Removing lot's of whitespace.

  • Loading branch information...
1 parent c6f5156 commit 07b56d1a2607558ad151628f7d14ab8620f1bccf @forrest committed
View
2 Appraisals
@@ -4,4 +4,4 @@ end
appraise "prawn0.6.3" do
gem "prawn", '0.6.3'
-end
+end
View
14 README.rdoc
@@ -19,15 +19,15 @@ In your <code>Gemfile</code>:
gem "prawnto_2", :require => "prawnto"
Then run:
-
+
bundle install
Now make a view:
<action name>.pdf.prawn
-
+
---
-
+
= Usage
More Details will be coming to {wiki}[http://github.com/forrest/prawnto/wiki].
@@ -35,11 +35,11 @@ More Details will be coming to {wiki}[http://github.com/forrest/prawnto/wiki].
=== As View in Controller
Simply create additional views that end with <code>.pdf.prawn</code> and rails will use the Prawnto template handler to render it properly. The beta has combined the regular <code>.prawn</code> and <code>.prawn_dsl</code> extensions. Now you won't get tired of typing <code>pdf.method</code>, but instance variables get used. There are a number of options available which are detailed in the wiki (or will be soon).
-
+
=== As Attachment to Email
You can render PDF's as an attachment to an email very simply with Prawnto.
-
+
class PdfEmailer < ActionMailer::Base
default from: "from@example.com"
@@ -82,10 +82,10 @@ While layouts and partials aren't yet supported, helper methods can be called fr
prawnto uses appraisal to run tests for different versions of prawn. In order to
run the specs you first need to install the dependencies for each appraisal:
-
+
rake appraisal:install
-Then you can run the tests for a specifc version of prawn (only 0.12.0 and
+Then you can run the tests for a specifc version of prawn (only 0.12.0 and
0.6.3, but you can add your own version) or all versions:
rake appraisal:prawn0.12.0 spec
View
6 lib/prawnto.rb
@@ -11,11 +11,11 @@ module Prawnto
module TemplateHandlers
autoload :Renderer, 'prawnto/template_handlers/renderer'
-
+
autoload :Base, 'prawnto/template_handlers/base'
autoload :Dsl, 'prawnto/template_handlers/dsl'
end
-
+
autoload :ModelRenderer, 'prawnto/model_renderer'
-
+
end
View
8 lib/prawnto/action_controller_mixin.rb
@@ -1,7 +1,7 @@
module Prawnto
module ActionControllerMixin
DEFAULT_PRAWNTO_OPTIONS = {:inline=>true}
-
+
def self.included(base)
base.send :attr_reader, :prawnto_options
base.class_attribute :prawn_hash, :prawnto_hash
@@ -11,14 +11,14 @@ def self.included(base)
end
module ClassMethods
-
+
# This is the class setter. It lets you set default options for all prawn actions within a controller.
def prawnto(options)
prawn_options, prawnto_options = breakdown_prawnto_options options
self.prawn_hash = prawn_options
self.prawnto_hash = DEFAULT_PRAWNTO_OPTIONS.dup.merge(prawnto_options)
end
-
+
private
# splits the :prawn key out into a seperate hash
@@ -28,7 +28,7 @@ def breakdown_prawnto_options(options)
[prawn_options, prawnto_options]
end
end
-
+
# Sets the prawn options. Use in the controller method.
#
# respond_to {|format|
View
8 lib/prawnto/model_renderer.rb
@@ -1,6 +1,6 @@
module Prawnto
module ModelRenderer
-
+
class CustomController < ApplicationController
def initialize
super
@@ -9,7 +9,7 @@ def initialize
self.params = {:format => :pdf}
end
end
-
+
# template : invoices/show.pdf
# instance_variables : {"@account" => account} - variables set in before filters
def self.to_string(template, calling_object = nil)
@@ -18,9 +18,9 @@ def self.to_string(template, calling_object = nil)
if calling_object
instance.prawnto :inline => true, :instance_variables_from => calling_object
end
-
+
return instance.render_to_string(:action => template, :template => false, :formats => [:pdf]).html_safe
end
end
-end
+end
View
20 lib/prawnto/template_handlers/renderer.rb
@@ -7,38 +7,38 @@ def initialize(view_context, calling_object = nil)
set_instance_variables
@pdf = Prawn::Document.new(@prawnto_options[:prawn]);
end
-
+
def to_pdf(&block)
instance_eval(&block)
@pdf.render.html_safe
end
-
+
private
-
+
def set_instance_variables
@calling_object ||= @view_context
copy_instance_variables_from @calling_object
-
+
if @prawnto_options[:instance_variables_from]
copy_instance_variables_from @prawnto_options[:instance_variables_from]
end
end
-
+
def pdf
@pdf
end
-
+
# This was removed in Rails 3.1
def copy_instance_variables_from(object, exclude = [])
vars = object.instance_variables.map(&:to_s) - exclude.map(&:to_s)
vars.each { |name| instance_variable_set(name, object.instance_variable_get(name)) }
end
-
+
def push_instance_variables_to(object, exclude = [])
vars = instance_variables.map(&:to_s) - exclude.map(&:to_s)
vars.each { |name| object.instance_variable_set(name, instance_variable_get(name)) }
end
-
+
# This method is a little hacky with pushing the instance variables back. I would prefer to use bindings, but wasn't having much luck.
def method_missing(m, *args, &block)
begin
@@ -61,8 +61,8 @@ def method_missing(m, *args, &block)
end
end
end
-
+
end
end
end
-
+
View
1 prawnto.gemspec
@@ -1,4 +1,3 @@
-
Gem::Specification.new do |s|
s.name = "prawnto_2"
s.version = '0.2.3'

0 comments on commit 07b56d1

Please sign in to comment.
Something went wrong with that request. Please try again.