icanhazpdf 0.0.4.2 → 0.0.5.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: 29d92c7f6514403cf7f58a68e1a41f6782da51a5
4
- data.tar.gz: 644f4818c62cf2cbd40b74f2f06bcd03ea68a5d2
3
+ metadata.gz: 2d8427a72b674a8353bec47f070bd4232d0b1e0d
4
+ data.tar.gz: d5dad796723b8afbada146405f1c6e696e69e83b
5
5
  SHA512:
6
- metadata.gz: 2fb4be6777b2a15d9bbedc61142e316fa3bb361b10e31438bf7fa825da838c16c15d0547468ed06ef07dc835bffced5b00115d624cb92b07a98f5ca3d6bc6441
7
- data.tar.gz: b8c7b365ef97751200cf79b36d21e086b88c17adb700ca4eaa627630a4db9b8f7fc9259c5f9e65cbef0ea6c089c9d4db00f98c8cbdf80a3defe2214569ce4592
6
+ metadata.gz: 5adc3f10d2657b07e22fa81d4d0cbc2c7d85dd9c3e203425a98e8b4ded523225fa5810ab45258a1b99960308bfad73486d15399001879c018c94643c2226e369
7
+ data.tar.gz: 5da95ba9b12e23f7c7d14b0ad2a23778d2266565d0fb51fbb4f6c6b9205fec4c0a4b73624873218a5f636b12002d086f93e00a3d517b94d928fa188e543b8040
data/README.md CHANGED
@@ -37,7 +37,7 @@ To render a pdf (send the file to the browser) from a url use the renderer modul
37
37
  include Icanhazpdf::Controller::Renderer
38
38
 
39
39
  def my_action
40
- render_pdf_from my_resource_url(resource), 'myfilename.pdf'
40
+ render_pdf_from my_resource_url(resource), {filename: 'myfilename.pdf'}
41
41
  end
42
42
  end
43
43
 
@@ -66,7 +66,7 @@ By default ICanHazPdf uses phantomjs to generate pdfs. You can also now choose t
66
66
  use wkhtmltopdf. To enable this you need to pass this option into the client or controller
67
67
  request. e.g.
68
68
 
69
- pdf_response = Icanhazpdf::Client.new.pdf_from_url my_resource_url(resource), true
69
+ pdf_response = Icanhazpdf::Client.new.pdf_from_url my_resource_url(resource), {use_wkhtmltopdf: true}
70
70
 
71
71
  ## Authentication
72
72
 
@@ -18,7 +18,7 @@ module Icanhazpdf
18
18
  end
19
19
 
20
20
  # generate a pdf from the url passed
21
- def pdf_from_url(full_url, use_wkhtmltopdf = false)
21
+ def pdf_from_url(full_url, options = {})
22
22
  uri = URI(full_url)
23
23
  params = URI.decode_www_form(uri.query || "") << ['icanhazpdf', Icanhazpdf::Client::api_key]
24
24
  uri.query = URI.encode_www_form(params)
@@ -28,7 +28,8 @@ module Icanhazpdf
28
28
  service_url = Icanhazpdf::Client.default_service_url
29
29
  end
30
30
  encoded_url = "#{service_url}?url=#{URI.encode(uri.to_s).gsub(':', '%3A').gsub('/', '%2F').gsub('?', '%3F').gsub('=', '%3D').gsub('&', '%26')}"
31
- encoded_url += "&use_wkhtmltopdf=true" if use_wkhtmltopdf
31
+ encoded_url += "&use_wkhtmltopdf=true" if options.has_key?(:use_wkhtmltopdf)
32
+ encoded_url += "&margin=#{options[:margin]}" if options.has_key?(:margin)
32
33
  HTTParty.get(encoded_url, :timeout => 10000)
33
34
  end
34
35
 
@@ -9,10 +9,9 @@ module Icanhazpdf
9
9
  module Renderer
10
10
 
11
11
  # generate and render a pdf from a url
12
- def render_pdf_from(url, filename = "", use_wkhtmltopdf = false)
13
- options = {}
14
- options[:filename] = filename if filename.present?
15
- render_response_for Icanhazpdf::Client.new.pdf_from_url(url, use_wkhtmltopdf), options
12
+ def render_pdf_from(url, options = {})
13
+ options.slice!(:filename, :use_wkhtmltopdf, :margin)
14
+ render_response_for Icanhazpdf::Client.new.pdf_from_url(url, options), options
16
15
  end
17
16
 
18
17
  # send the pdf to the user if its a valid file
@@ -1,3 +1,3 @@
1
1
  module Icanhazpdf
2
- VERSION = "0.0.4.2"
2
+ VERSION = "0.0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icanhazpdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.2
4
+ version: 0.0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nic Pillinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-14 00:00:00.000000000 Z
11
+ date: 2015-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler