caterpillar-ruby 0.1.0 → 0.2.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 +4 -4
- data/README.md +14 -14
- data/lib/caterpillar-ruby.rb +4 -0
- data/lib/caterpillar-ruby/version.rb +1 -1
- data/lib/generators/caterpillar/initializer.rb +0 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 12f0ab5f24fb15ddb5fe358d1c3dff0bc098352e
|
|
4
|
+
data.tar.gz: 90e4842c8916881151e41dff6791fb4670288fca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3816cc00fe2986d173e403a71d86a6c18dd418aee9e447f0feb86e78e3da505e65468c66f9923c7f519e689890ae098786d838b904998dfd8bf55e5832b2f8f4
|
|
7
|
+
data.tar.gz: a913ec5243e49ad948cbd58608f553e8fc1b269a003f9773f4d4a5bfdfdca0d7dacdb14dd6b2fb4f6ea983df30c8cb51602a39f0b445b3f04e2d350f8391e6e5
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Caterpillar
|
|
1
|
+
# Caterpillar
|
|
2
2
|
|
|
3
3
|
This Ruby gem is a simple wrapper around the Caterpillar API. [Caterpillar](https://caterpillar.io) is a web service that allows you to convert html to pdf.
|
|
4
4
|
|
|
@@ -23,22 +23,20 @@ Or install it yourself as:
|
|
|
23
23
|
Set the following attributes in you Ruby app:
|
|
24
24
|
|
|
25
25
|
```
|
|
26
|
-
Caterpillar.api_key = 'YOUR_CATERPILLAR_API_KEY'
|
|
27
|
-
Caterpillar.api_version =
|
|
28
|
-
Caterpillar.base_uri = 'https://api.caterpillar.io'
|
|
26
|
+
Caterpillar.api_key = 'YOUR_CATERPILLAR_API_KEY' # required
|
|
27
|
+
Caterpillar.api_version = 'YOUR_API_VERSION' # optional, default: 'v1'
|
|
28
|
+
Caterpillar.base_uri = 'YOUR_API_BASE_URI' # optional, default: 'https://api.caterpillar.io'
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
For a Rails app you can execute:
|
|
32
32
|
|
|
33
33
|
$ rails generate caterpillar:install
|
|
34
34
|
|
|
35
|
-
or create an initializer `config/initializers/caterpillar.rb
|
|
35
|
+
or create an initializer `config/initializers/caterpillar.rb`:
|
|
36
36
|
|
|
37
37
|
```
|
|
38
38
|
Caterpillar.configure do |config|
|
|
39
39
|
config.api_key = 'YOUR_CATERPILLAR_API_KEY'
|
|
40
|
-
config.api_version = 'v1'
|
|
41
|
-
config.base_uri = 'https://api.caterpillar.io'
|
|
42
40
|
end
|
|
43
41
|
```
|
|
44
42
|
|
|
@@ -58,16 +56,18 @@ The `create` call can also take a block, like so:
|
|
|
58
56
|
|
|
59
57
|
```
|
|
60
58
|
Caterpillar.create(source: content) do |file, response|
|
|
61
|
-
#file is a tempfile holding the response body
|
|
62
|
-
#
|
|
59
|
+
# file is a tempfile holding the response body
|
|
60
|
+
# response is the HTTParty response object
|
|
63
61
|
end
|
|
64
62
|
```
|
|
65
63
|
|
|
66
64
|
`create` will return an [HTTParty](https://github.com/jnunemaker/httparty) response object, which will be the new file (or errors, if the request was not valid).
|
|
67
65
|
|
|
68
|
-
The only required parameter is:
|
|
66
|
+
The only **required parameter** is:
|
|
69
67
|
* `:source` - a string containing the HTML or URL for creating the document
|
|
70
68
|
|
|
69
|
+
For a Rails app you can pass a view as source by converting it to an HTML string using [render_to_string](http://apidock.com/rails/ActionController/Base/render_to_string).
|
|
70
|
+
|
|
71
71
|
You might want to set other options in that hash:
|
|
72
72
|
|
|
73
73
|
| Option | Type | Description |
|
|
@@ -116,13 +116,13 @@ You might want to set other options in that hash:
|
|
|
116
116
|
`:password_protect` | `Hash` | Refer next section for more details
|
|
117
117
|
|
|
118
118
|
## Password Protect
|
|
119
|
-
You can
|
|
119
|
+
You can password protect PDF using AES 256, AES 128, RC4 (128 & 40) encryption algorithms supported by Adobe Reader.
|
|
120
120
|
|
|
121
121
|
To encrypt PDF you need to pass `:password_protect` hash in the `create` method call along with the following **required parameters**:
|
|
122
122
|
* `:password` - a string containing the secret password which will be further used to unlock the PDF
|
|
123
|
-
* `:key_length` - a number which defines the encryption
|
|
123
|
+
* `:key_length` - a number which defines the encryption algorithm to be used. Values can be **40, 128 and 256** only.
|
|
124
124
|
|
|
125
|
-
You might want to set other options for each encryption
|
|
125
|
+
You might want to set other options for each encryption algorithm inside `:restrictions` hash:
|
|
126
126
|
|
|
127
127
|
*Key Length:* **40**
|
|
128
128
|
|
|
@@ -157,7 +157,7 @@ You might want to set other options for each encryption alogrithm inside `:restr
|
|
|
157
157
|
Caterpillar.create(
|
|
158
158
|
source: content,
|
|
159
159
|
password_protect: {
|
|
160
|
-
|
|
160
|
+
password: 'YOUR_PASSWORD_HERE',
|
|
161
161
|
key_length: 128,
|
|
162
162
|
restrictions: {
|
|
163
163
|
print: 'low',
|
data/lib/caterpillar-ruby.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: caterpillar-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nitish Sharma
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
99
99
|
version: '0'
|
|
100
100
|
requirements: []
|
|
101
101
|
rubyforge_project:
|
|
102
|
-
rubygems_version: 2.
|
|
102
|
+
rubygems_version: 2.6.8
|
|
103
103
|
signing_key:
|
|
104
104
|
specification_version: 4
|
|
105
105
|
summary: A simple ruby client for the Caterpillar API
|