princely 2.0.2 → 2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecbe6eb4cd59f1366cf933451913fa49d41cf4a7
4
- data.tar.gz: b8b90d69258223be3767d29c3ba26ca7d37e8886
3
+ metadata.gz: 159b0a9d3b1ad9903919bfd4c898f0efa167c2f7
4
+ data.tar.gz: 470467e6249ef9e6ddb11919680dade99dc6b1df
5
5
  SHA512:
6
- metadata.gz: dd793c59a46ba21953a10513bdbb2518d1b07b9b0c5075040c0f8a6311aa5b5bf83891359e5360bde61318593e85a4026e9d9e98811ded89e19577259b7952bb
7
- data.tar.gz: 355d7651285360c9e8136c769f9e54ff0667cc9e0220fd830ac0e56090e0e669128a57ac3e89ca9428fb3fa7c7abf0d39b4f9d1af2d4de994332556b8d5e8ee0
6
+ metadata.gz: 7999bd7330708be669aff4f59dd34efab71f9c0c1789aca60041a905cce3e53f20730f33a530db224338803e4b5e9458bb017365632f87a84ad5a73b87ffc76c
7
+ data.tar.gz: d089a1b16276f65763a8d8a26d08d0aecf761a3b04b3969f58d04bf962355536630db91e376b4e347b99724e02de517affde3d2337638104e0a1207d20b45fce
data/README.md CHANGED
@@ -20,6 +20,7 @@ class Provider::EstimatesController < Provider::BaseController
20
20
  :formats => %w[pdf],
21
21
  :stylesheets => %w[application prince],
22
22
  :layout => 'pdf',
23
+ :locals => { :foo => 'bar' },
23
24
  :disposition => 'inline', # PDF will be sent inline, means you can load it inside an iFrame or Embed
24
25
  :relative_paths => true # Modify asset paths to make them relative. See [the AssetSupport module](/lib/princely/asset_support.rb)
25
26
  end
@@ -40,6 +41,7 @@ The defaults for the render options are as follows:
40
41
 
41
42
  layout: false
42
43
  template: the template for the current controller/action
44
+ locals: none
43
45
  stylesheets: none
44
46
  disposition: attachment (created PDF file will be sent as download)
45
47
  relative_paths: true
@@ -51,6 +53,7 @@ The defaults for the render options are as follows:
51
53
 
52
54
  * Maintainer: Jared Fraser ([modsognir](https://github.com/modsognir))
53
55
  * Gemification and more: Nic Williams
56
+ * Based on code by: Seth B ([subimage](https://github.com/subimage))
54
57
  * [Other Contributors](https://github.com/mbleigh/princely/contributors)
55
58
 
56
59
  ## Resources
@@ -1,7 +1,8 @@
1
1
  # PrinceXML Ruby interface.
2
2
  # http://www.princexml.com
3
3
  #
4
- # Library by Subimage Interactive - http://www.subimage.com
4
+ # Original code by Seth @ Subimage LLC
5
+ # - http://subimage.com/blog/2007/05/29/html-css-to-pdf-using-ruby-on-rails/
5
6
  #
6
7
  #
7
8
  # USAGE
@@ -3,9 +3,14 @@ require 'princely/asset_support'
3
3
 
4
4
  module Princely
5
5
  module PdfHelper
6
-
7
6
  def self.included(base)
8
- base.send :alias_method_chain, :render, :princely
7
+ base.send :alias_method, :render_without_princely, :render
8
+ base.send :alias_method, :render, :render_with_princely
9
+ end
10
+
11
+ def self.prepended(base)
12
+ base.send :alias_method, :render_without_princely, :render
13
+ base.send :alias_method, :render, :render_with_princely
9
14
  end
10
15
 
11
16
  def render_with_princely(options = nil, *args, &block)
@@ -34,7 +39,7 @@ module Princely
34
39
  # Sets style sheets on PDF renderer
35
40
  prince.add_style_sheets(*options[:stylesheets].collect{|style| asset_file_path(style)})
36
41
 
37
- html_string = render_to_string(options.slice(:template, :layout, :handlers, :formats))
42
+ html_string = render_to_string(options.slice(:template, :layout, :handlers, :formats, :locals))
38
43
 
39
44
  html_string = localize_html_string(html_string, Rails.public_path) if options[:relative_paths]
40
45
 
@@ -4,7 +4,13 @@ if Mime::Type.lookup_by_extension(:pdf) != 'application/pdf'
4
4
  Mime::Type.register 'application/pdf', :pdf
5
5
  end
6
6
 
7
- ActionController::Base.send(:include, Princely::PdfHelper)
8
- ActionController::Base.send(:include, Princely::AssetSupport) if
9
- (Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR > 0) ||
10
- (Rails::VERSION::MAJOR >= 4)
7
+ if defined?(Rails)
8
+ if Rails::VERSION::MAJOR >= 5
9
+ ActionController::Base.send(:prepend, Princely::PdfHelper)
10
+ else
11
+ ActionController::Base.send(:include, Princely::PdfHelper)
12
+ end
13
+ ActionController::Base.send(:include, Princely::AssetSupport) if
14
+ (Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR > 0) ||
15
+ (Rails::VERSION::MAJOR >= 4)
16
+ end
@@ -2,7 +2,7 @@ module Princely
2
2
  class Version
3
3
  class << self
4
4
  def version
5
- '2.0.2'
5
+ '2.1.0'
6
6
  end
7
7
 
8
8
  def to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: princely
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh