icanhazpdf 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e3c30c84c3d9365171cfbac2fa8ce06df2f39ba
4
- data.tar.gz: b4203af5b4d792c4e6d9965b4481fdfeebc71450
3
+ metadata.gz: b5946da7cdb453bfb5c81b36a2db70ca140c08aa
4
+ data.tar.gz: f0380c04da4ec6e47dc9c91d6d80e466095204cc
5
5
  SHA512:
6
- metadata.gz: a7c0459fce0eb5c775659d2cff2e1f7db3bdde6016b2cb256898aedde7bbb77828a8bb668274d59bf32c4f6628ee8d1b533ee0987c3baf81c2c92f11e93b6583
7
- data.tar.gz: 4ddb25a90930ccf0b3dce7368321735ec97f573a646253c30f47d261094e6de538b13610d50fdea30d9f35a5e7d587b4b109b720c6cd310f6f58a79cd99fff3d
6
+ metadata.gz: 5249f12359b5469d0de2af37142c5cbf9d01936ecdb4ea97a85ef2ebefdbdc3b2298d09f9363fb47bc99e605bd1b922c4f0434aa870d346917125004007d0dcb
7
+ data.tar.gz: 36769713bce1a772d834d5f66de1ec826227e6ac4513b7baa18cc310163e30a99747f272543bbf0c57531b62105d1b56e6a5eb4dc98d14d3dadb25558b29df07
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- Icanhazpdf (0.0.2)
4
+ icanhazpdf (0.0.4)
5
5
  activesupport (~> 4.0)
6
6
  httparty (~> 0.13)
7
7
 
@@ -75,9 +75,9 @@ PLATFORMS
75
75
  ruby
76
76
 
77
77
  DEPENDENCIES
78
- Icanhazpdf!
79
78
  bundler (~> 1.6)
80
79
  guard-rspec (~> 4.3)
80
+ icanhazpdf!
81
81
  pry (~> 0.10)
82
82
  rake (~> 10.3)
83
83
  rspec (~> 3.0)
@@ -14,11 +14,11 @@ module Icanhazpdf
14
14
  end
15
15
 
16
16
  def self.default_service_url
17
- 'http://icanhazpdf.lsfapp.com'
17
+ 'http://icanhazpdf.lsfapp.com/generate_url'
18
18
  end
19
19
 
20
20
  # generate a pdf from the url passed
21
- def pdf_from_url(full_url)
21
+ def pdf_from_url(full_url, use_wkhtmltopdf = false)
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)
@@ -27,8 +27,8 @@ module Icanhazpdf
27
27
  rescue
28
28
  service_url = Icanhazpdf::Client.default_service_url
29
29
  end
30
- encoded_url = "#{service_url}/#{URI.encode(uri.to_s).gsub(':', '%3A').gsub('/', '%2F').gsub('?', '%3F').gsub('=', '%3D')}"
31
-
30
+ encoded_url = "#{service_url}?url=#{URI.encode(uri.to_s).gsub(':', '%3A').gsub('/', '%2F').gsub('?', '%3F').gsub('=', '%3D')}"
31
+ encoded_url += "&use_wkhtmltopdf=true" if use_wkhtmltopdf
32
32
  HTTParty.get(encoded_url, :timeout => 10000)
33
33
  end
34
34
 
@@ -9,10 +9,10 @@ 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 = "")
12
+ def render_pdf_from(url, filename = "", use_wkhtmltopdf = false)
13
13
  options = {}
14
14
  options[:filename] = filename if filename.present?
15
- render_response_for Icanhazpdf::Client.new.pdf_from_url(url), options
15
+ render_response_for Icanhazpdf::Client.new.pdf_from_url(url, use_wkhtmltopdf), options
16
16
  end
17
17
 
18
18
  # send the pdf to the user if its a valid file
@@ -1,3 +1,3 @@
1
1
  module Icanhazpdf
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -42,7 +42,14 @@ describe 'Icanhazpdf::Client' do
42
42
  @result = subject.pdf_from_url a_url
43
43
  end
44
44
 
45
- context 'no ocanhazpdf api key in the config' do
45
+ context 'use wkhtmltopdf is requested as engine' do
46
+ it 'sets the use_wkhtmltopdf param in the query string' do
47
+ expect(HTTParty).to receive(:get).with(include("use_wkhtmltopdf=true"), be_an(Hash))
48
+ @result = subject.pdf_from_url a_url, true
49
+ end
50
+ end
51
+
52
+ context 'no icanhazpdf api key in the config' do
46
53
  before(:each) do
47
54
  allow(rails_config).to receive(:icanhazpdf_api_key).and_raise("Undefined config value")
48
55
  end
@@ -31,7 +31,7 @@ describe "Icanhazpdf::Controller::Renderer" do
31
31
  end
32
32
 
33
33
  it 'requests the pdf from the client supplying the url' do
34
- expect(client).to receive(:pdf_from_url).with(url)
34
+ expect(client).to receive(:pdf_from_url).with(url, false)
35
35
  subject.render_pdf_from url, filename
36
36
  end
37
37
 
@@ -46,6 +46,13 @@ describe "Icanhazpdf::Controller::Renderer" do
46
46
  subject.render_pdf_from url
47
47
  end
48
48
  end
49
+
50
+ context 'wkhtmltopdf is requested as rendering engine' do
51
+ it 'calls render response with use_wkhtmltopdf value supplied' do
52
+ expect(client).to receive(:pdf_from_url).with(url, true)
53
+ subject.render_pdf_from url, "", true
54
+ end
55
+ end
49
56
  end
50
57
 
51
58
  describe 'rendering the response from the client' do
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.3
4
+ version: 0.0.4
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-09-23 00:00:00.000000000 Z
11
+ date: 2014-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler