icanhazpdf 0.0.4.1 → 0.0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +20 -1
- data/lib/icanhazpdf/client.rb +1 -1
- data/lib/icanhazpdf/version.rb +1 -1
- data/spec/lib/icanhazpdf/client_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29d92c7f6514403cf7f58a68e1a41f6782da51a5
|
4
|
+
data.tar.gz: 644f4818c62cf2cbd40b74f2f06bcd03ea68a5d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fb4be6777b2a15d9bbedc61142e316fa3bb361b10e31438bf7fa825da838c16c15d0547468ed06ef07dc835bffced5b00115d624cb92b07a98f5ca3d6bc6441
|
7
|
+
data.tar.gz: b8c7b365ef97751200cf79b36d21e086b88c17adb700ca4eaa627630a4db9b8f7fc9259c5f9e65cbef0ea6c089c9d4db00f98c8cbdf80a3defe2214569ce4592
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,17 @@ Makes using the icanhazpdf service in a Rails app simples
|
|
5
5
|
|
6
6
|
Add this line to your application's Gemfile:
|
7
7
|
|
8
|
-
gem 'icanhazpdf', '~> 0.0.
|
8
|
+
gem 'icanhazpdf', '~> 0.0.4'
|
9
|
+
|
10
|
+
## Rails configuration
|
11
|
+
|
12
|
+
You can configure some aspects of the client in your rails environment config
|
13
|
+
|
14
|
+
config.icanhazpdf_api_key = 'this needs to be configured to your api key'
|
15
|
+
config.icanhazpdf_url = 'http://use.this.to.override.the.service/endpoint'
|
16
|
+
|
17
|
+
if you dont override the service (and why would you?) it will hit the default
|
18
|
+
icanhazpdf service
|
9
19
|
|
10
20
|
## Client
|
11
21
|
|
@@ -40,6 +50,7 @@ To render a pdf using a previous response from the Client use:
|
|
40
50
|
class MyController < ApplicationController
|
41
51
|
include Icanhazpdf::Controller::Renderer
|
42
52
|
|
53
|
+
|
43
54
|
def my_action
|
44
55
|
pdf_response = Icanhazpdf::Client.new.pdf_from_url my_resource_url(resource)
|
45
56
|
|
@@ -49,6 +60,14 @@ To render a pdf using a previous response from the Client use:
|
|
49
60
|
end
|
50
61
|
end
|
51
62
|
|
63
|
+
## PDF Engine
|
64
|
+
|
65
|
+
By default ICanHazPdf uses phantomjs to generate pdfs. You can also now choose to
|
66
|
+
use wkhtmltopdf. To enable this you need to pass this option into the client or controller
|
67
|
+
request. e.g.
|
68
|
+
|
69
|
+
pdf_response = Icanhazpdf::Client.new.pdf_from_url my_resource_url(resource), true
|
70
|
+
|
52
71
|
## Authentication
|
53
72
|
|
54
73
|
Checks the current request being made is coming from the icanhazpdf service and
|
data/lib/icanhazpdf/client.rb
CHANGED
@@ -27,7 +27,7 @@ module Icanhazpdf
|
|
27
27
|
rescue
|
28
28
|
service_url = Icanhazpdf::Client.default_service_url
|
29
29
|
end
|
30
|
-
encoded_url = "#{service_url}?url=#{URI.encode(uri.to_s).gsub(':', '%3A').gsub('/', '%2F').gsub('?', '%3F').gsub('=', '%3D')}"
|
30
|
+
encoded_url = "#{service_url}?url=#{URI.encode(uri.to_s).gsub(':', '%3A').gsub('/', '%2F').gsub('?', '%3F').gsub('=', '%3D').gsub('&', '%26')}"
|
31
31
|
encoded_url += "&use_wkhtmltopdf=true" if use_wkhtmltopdf
|
32
32
|
HTTParty.get(encoded_url, :timeout => 10000)
|
33
33
|
end
|
data/lib/icanhazpdf/version.rb
CHANGED
@@ -3,7 +3,7 @@ require 'httparty'
|
|
3
3
|
|
4
4
|
describe 'Icanhazpdf::Client' do
|
5
5
|
|
6
|
-
let(:a_url) { "http://a.url.to/generate_a_pdf_from?with=querystring" }
|
6
|
+
let(:a_url) { "http://a.url.to/generate_a_pdf_from?with=querystring&language=english" }
|
7
7
|
subject { Icanhazpdf::Client.new }
|
8
8
|
|
9
9
|
describe 'generating a pdf from' do
|
@@ -33,7 +33,7 @@ describe 'Icanhazpdf::Client' do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'url encodes the address of the page to create a pdf from' do
|
36
|
-
expect(HTTParty).to receive(:get).with(include("http%3A%2F%2Fa.url.to%2Fgenerate_a_pdf_from%3Fwith%3Dquerystring"), be_an(Hash))
|
36
|
+
expect(HTTParty).to receive(:get).with(include("http%3A%2F%2Fa.url.to%2Fgenerate_a_pdf_from%3Fwith%3Dquerystring%26language%3Denglish"), be_an(Hash))
|
37
37
|
@result = subject.pdf_from_url a_url
|
38
38
|
end
|
39
39
|
|
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.
|
4
|
+
version: 0.0.4.2
|
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-
|
11
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|