doc_raptor 0.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.
- data/MIT-LICENSE +20 -0
- data/README.md +36 -0
- data/lib/doc_raptor.rb +42 -0
- metadata +84 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 [Expected Behavior, LLC]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
DocRaptor
|
2
|
+
==========
|
3
|
+
|
4
|
+
This is a Ruby gem providing a simple wrapper around the DocRaptor API.
|
5
|
+
|
6
|
+
|
7
|
+
## Usage ######################################################################
|
8
|
+
|
9
|
+
The gem will look for your api key in the ENV variable "DOCRAPTOR_API_KEY". If it is
|
10
|
+
not there, you can set it directly by calling:
|
11
|
+
|
12
|
+
DocRaptor.api_key "My API Key Here"
|
13
|
+
|
14
|
+
Once an API key is set, you can create documents by calling
|
15
|
+
|
16
|
+
DocRaptor.create(:document_content => content, :document_type => "pdf", :test => false)
|
17
|
+
|
18
|
+
This will return an HTTParty respsonse object, the body of which will be the new file
|
19
|
+
(or errors, if the request was not valid). You can pass in "pdf" or "xls" as the
|
20
|
+
:document_type - default is pdf. This determines the type of file that DocRaptor will create.
|
21
|
+
You can pass in true or false for :test - default is false - and this turns on or off
|
22
|
+
test mode for DocRaptor. The only required parameter is :document_content, which should be a
|
23
|
+
string of html - this will be what DocRaptor turns into your document.
|
24
|
+
|
25
|
+
The create call can also take a block, like so:
|
26
|
+
|
27
|
+
DocRaptor.create(:document_content => content) do |file, response|
|
28
|
+
#file is a tempfile holding the response body
|
29
|
+
#reponse is the HTTParty response object
|
30
|
+
end
|
31
|
+
|
32
|
+
## Meta #######################################################################
|
33
|
+
|
34
|
+
Maintained by Expected Behavior
|
35
|
+
|
36
|
+
Released under the MIT license. http://github.com/expected-behavior/docraptor-gem
|
data/lib/doc_raptor.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require "tempfile"
|
3
|
+
|
4
|
+
class DocRaptor
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
def self.api_key(key = nil)
|
8
|
+
return default_options[:api_key] unless key
|
9
|
+
default_options[:api_key] = key
|
10
|
+
end
|
11
|
+
|
12
|
+
# when given a block, hands the block a TempFile of the resulting document
|
13
|
+
# otherwise, just returns the response
|
14
|
+
def self.create(options = { })
|
15
|
+
raise "must supply :document_content" if options[:document_content].blank?
|
16
|
+
|
17
|
+
default_options = {
|
18
|
+
:name => "default",
|
19
|
+
:document_type => "pdf",
|
20
|
+
:test => false,
|
21
|
+
}
|
22
|
+
options = default_options.merge(options)
|
23
|
+
|
24
|
+
response = post("/docs", :body => {:doc => options}, :basic_auth => { :username => api_key })
|
25
|
+
|
26
|
+
if block_given?
|
27
|
+
Tempfile.open("docraptor") do |f|
|
28
|
+
f.sync = true
|
29
|
+
f.write(response.body)
|
30
|
+
f.rewind
|
31
|
+
|
32
|
+
yield f, response
|
33
|
+
end
|
34
|
+
else
|
35
|
+
response
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
base_uri ENV["DOCRAPTOR_URL"] || "https://docraptor.com/"
|
40
|
+
api_key ENV["DOCRAPTOR_API_KEY"]
|
41
|
+
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: doc_raptor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Michael Kuehl
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-20 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: httparty
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 5
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 6
|
33
|
+
- 1
|
34
|
+
version: 0.6.1
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Provides a simple ruby wrapper around the DocRaptor API
|
38
|
+
email: michael@expectedbehavior.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- README.md
|
47
|
+
- MIT-LICENSE
|
48
|
+
- lib/doc_raptor.rb
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://docraptor.com
|
51
|
+
licenses: []
|
52
|
+
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.3.7
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: wrap up the api for DocRaptor nicely
|
83
|
+
test_files: []
|
84
|
+
|