docraptor 1.4.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.swagger-codegen/VERSION +1 -1
- data/.swagger-revision +1 -1
- data/.travis.yml +9 -0
- data/CHANGELOG.md +4 -0
- data/README.md +6 -13
- data/docraptor.gemspec +3 -2
- data/examples/hosted_async.rb +1 -1
- data/examples/hosted_sync.rb +1 -1
- data/lib/docraptor.rb +1 -1
- data/lib/docraptor/api/doc_api.rb +1 -1
- data/lib/docraptor/api_client.rb +4 -4
- data/lib/docraptor/api_error.rb +1 -1
- data/lib/docraptor/configuration.rb +3 -3
- data/lib/docraptor/models/async_doc.rb +1 -1
- data/lib/docraptor/models/doc.rb +1 -1
- data/lib/docraptor/models/doc_status.rb +1 -1
- data/lib/docraptor/models/prince_options.rb +1 -1
- data/lib/docraptor/version.rb +2 -2
- data/script/fix_gemspec.rb +13 -5
- data/script/setup +25 -0
- data/script/test +38 -7
- data/swagger-config.json +1 -1
- data/test/expire_hosted.rb +3 -8
- data/test/hosted_async.rb +1 -6
- data/test/hosted_sync.rb +2 -7
- metadata +36 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfd3d5b8d3364bd02c04b712136686d4a714f6cd3ab3fced0c7efae7e9709ee0
|
4
|
+
data.tar.gz: 89d4fb74883b56c49a71eef45487534474a8f9fa0ae8fc065a592e6a1ae7340c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 964a77fd28bb343dd5410b01e5b6981f631fd5c0ed047225b2dc048b8070249d9d704bb7a4bd289d154b406e8b794a2ac71e7d031af047bb8c47a0500c86b29d
|
7
|
+
data.tar.gz: 90787b9656e2455038833d260caf62b7aa48ce833d3de5e1483c1a9893feed6e0deb5d4cb995ee565510c0c3bfabe7e851decdf5cae00fd0389dc07d8319ff90
|
data/.swagger-codegen/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.4.
|
1
|
+
2.4.19
|
data/.swagger-revision
CHANGED
@@ -1 +1 @@
|
|
1
|
-
v2.4.
|
1
|
+
v2.4.19
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -18,9 +18,7 @@ bundle install
|
|
18
18
|
```
|
19
19
|
|
20
20
|
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
See [examples](examples/) for runnable examples with file output, error handling, etc.
|
21
|
+
## Basic Usage
|
24
22
|
|
25
23
|
```ruby
|
26
24
|
DocRaptor.configure do |config|
|
@@ -44,20 +42,15 @@ response = $docraptor.create_doc(
|
|
44
42
|
)
|
45
43
|
```
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
We have guides for doing some of the common things:
|
50
|
-
|
51
|
-
* [Headers and Footers](https://docraptor.com/documentation/style#pdf-headers-footers) including page skipping
|
52
|
-
* [CSS Media Selector](https://docraptor.com/documentation/api#api_basic_pdf) to make the page look exactly as it does in your browser
|
53
|
-
* Protect content with [HTTP authentication](https://docraptor.com/documentation/api#api_http_user) or [proxies](https://docraptor.com/documentation/api#api_http_proxy) so only DocRaptor can access them
|
45
|
+
## Next Steps
|
54
46
|
|
47
|
+
- Optionally store and get a URL for your converted document with [document hosting](https://docraptor.com/document-hosting)
|
48
|
+
- View more [code examples](examples) with error handling, asynchronous creation, file saving, and document hosting.
|
49
|
+
- Perfect your document styling with our [style and formatting reference](https://docraptor.com/documentation/style), and [API reference](https://docraptor.com/documentation/api). Easily add headers and footers, page breaks, page numbers, table of contents, and much more!
|
55
50
|
|
56
51
|
## More Help
|
57
52
|
|
58
|
-
|
59
|
-
|
60
|
-
Stuck? We're experts at using DocRaptor so please [email us](mailto:support@docraptor.com) if you run into trouble.
|
53
|
+
Stuck? We're experts at turning HTML into PDFs so please [email us](mailto:support@docraptor.com) if you run into trouble.
|
61
54
|
|
62
55
|
|
63
56
|
## Development
|
data/docraptor.gemspec
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
OpenAPI spec version: 1.4.0
|
9
9
|
|
10
10
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
11
|
-
Swagger Codegen version: 2.4.
|
11
|
+
Swagger Codegen version: 2.4.19
|
12
12
|
|
13
13
|
=end
|
14
14
|
|
@@ -25,10 +25,11 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.summary = "A wrapper for the DocRaptor HTML to PDF/XLS service."
|
26
26
|
s.description = "A native client library for the DocRaptor HTML to PDF/XLS service."
|
27
27
|
s.license = 'MIT'
|
28
|
-
s.required_ruby_version = ">=
|
28
|
+
s.required_ruby_version = ">= 2.3"
|
29
29
|
|
30
30
|
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
31
31
|
s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
|
32
|
+
s.add_runtime_dependency 'addressable', '~> 2.3', '>= 2.3.0'
|
32
33
|
|
33
34
|
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
34
35
|
s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
|
data/examples/hosted_async.rb
CHANGED
data/examples/hosted_sync.rb
CHANGED
data/lib/docraptor.rb
CHANGED
data/lib/docraptor/api_client.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
OpenAPI spec version: 1.4.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.
|
9
|
+
Swagger Codegen version: 2.4.19
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -15,7 +15,7 @@ require 'json'
|
|
15
15
|
require 'logger'
|
16
16
|
require 'tempfile'
|
17
17
|
require 'typhoeus'
|
18
|
-
require 'uri'
|
18
|
+
require 'addressable/uri'
|
19
19
|
|
20
20
|
module DocRaptor
|
21
21
|
class ApiClient
|
@@ -63,7 +63,7 @@ module DocRaptor
|
|
63
63
|
:message => response.return_message)
|
64
64
|
else
|
65
65
|
fail ApiError.new(:code => response.code,
|
66
|
-
:response_headers => response.headers,
|
66
|
+
:response_headers => response.headers.to_h,
|
67
67
|
:response_body => response.body),
|
68
68
|
response.status_message
|
69
69
|
end
|
@@ -266,7 +266,7 @@ module DocRaptor
|
|
266
266
|
def build_request_url(path)
|
267
267
|
# Add leading and trailing slashes to path
|
268
268
|
path = "/#{path}".gsub(/\/+/, '/')
|
269
|
-
URI.encode(@config.base_url + path)
|
269
|
+
Addressable::URI.encode(@config.base_url + path)
|
270
270
|
end
|
271
271
|
|
272
272
|
# Builds the HTTP request body
|
data/lib/docraptor/api_error.rb
CHANGED
@@ -6,11 +6,11 @@
|
|
6
6
|
OpenAPI spec version: 1.4.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.4.
|
9
|
+
Swagger Codegen version: 2.4.19
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
|
-
require 'uri'
|
13
|
+
require 'addressable/uri'
|
14
14
|
|
15
15
|
module DocRaptor
|
16
16
|
class Configuration
|
@@ -175,7 +175,7 @@ module DocRaptor
|
|
175
175
|
|
176
176
|
def base_url
|
177
177
|
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
178
|
-
URI.encode(url)
|
178
|
+
Addressable::URI.encode(url)
|
179
179
|
end
|
180
180
|
|
181
181
|
# Gets API key (with prefix if set).
|
data/lib/docraptor/models/doc.rb
CHANGED
data/lib/docraptor/version.rb
CHANGED
data/script/fix_gemspec.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
bad_files
|
3
|
-
|
4
|
-
|
5
|
-
good_test_files
|
2
|
+
bad_files = %q{s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }}
|
3
|
+
good_files = %q{s.files = `git ls-files`.split("\n").uniq.sort.select { |f| !f.empty? }}
|
4
|
+
bad_test_files = %q{s.test_files = `find spec/*`.split("\n")}
|
5
|
+
good_test_files = %q{s.test_files = `git ls-files spec test`.split("\n")}
|
6
|
+
bad_ruby_version = %q{s.required_ruby_version = ">= 1.9"}
|
7
|
+
good_ruby_version = %q{s.required_ruby_version = ">= 2.3"}
|
6
8
|
|
7
9
|
development_dependency_marker = %q{ s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'}
|
8
10
|
development_dependency_marker_plus_injection =
|
@@ -16,7 +18,12 @@ development_dependency_marker_plus_injection =
|
|
16
18
|
|
17
19
|
filename = "docraptor.gemspec"
|
18
20
|
content = File.read(filename)
|
19
|
-
[
|
21
|
+
[
|
22
|
+
bad_files,
|
23
|
+
bad_test_files,
|
24
|
+
bad_ruby_version,
|
25
|
+
development_dependency_marker
|
26
|
+
].each do |bad_content_to_check|
|
20
27
|
unless content.include?(bad_content_to_check)
|
21
28
|
raise "Couldn't find content in docraptor.gemspec. Check matchers in there for: “#{bad_content_to_check}”"
|
22
29
|
end
|
@@ -24,6 +31,7 @@ end
|
|
24
31
|
updated_content = content.dup
|
25
32
|
updated_content.sub!(bad_files, good_files)
|
26
33
|
updated_content.sub!(bad_test_files, good_test_files)
|
34
|
+
updated_content.sub!(bad_ruby_version, good_ruby_version)
|
27
35
|
updated_content.sub!(development_dependency_marker,
|
28
36
|
development_dependency_marker_plus_injection)
|
29
37
|
|
data/script/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
cd "$(dirname "$0")/.."
|
4
|
+
|
5
|
+
rbenv which ruby || (brew upgrade ruby-build || true; rbenv install)
|
6
|
+
|
7
|
+
# Setup rbenv so we can switch rubies below
|
8
|
+
eval "$(rbenv init - --no-rehash)"
|
9
|
+
|
10
|
+
for ruby_version in `ruby -ryaml -e 'puts YAML.load(File.read(".travis.yml"))["rvm"].join(" ")'`; do
|
11
|
+
rbenv versions --bare | grep "^${ruby_version}$" || rbenv install $ruby_version
|
12
|
+
rbenv shell $ruby_version
|
13
|
+
gem list -i bundler --version 2.2.15 >/dev/null || gem install bundler:2.2.15
|
14
|
+
|
15
|
+
bundle install
|
16
|
+
done
|
17
|
+
|
18
|
+
tput bold # bold text
|
19
|
+
tput setaf 2 # green text
|
20
|
+
echo "****************************************************************"
|
21
|
+
echo "* *"
|
22
|
+
echo "* Good to go! *"
|
23
|
+
echo "* *"
|
24
|
+
echo "****************************************************************"
|
25
|
+
tput sgr0 # reset to default text
|
data/script/test
CHANGED
@@ -8,17 +8,48 @@ bundler -v > /dev/null || (echo "bundler must be installed"; exit 1)
|
|
8
8
|
|
9
9
|
bundle install
|
10
10
|
|
11
|
-
cd test
|
12
|
-
|
13
11
|
# runs a test file with PASS/FAIL message
|
14
12
|
run_test() {
|
15
13
|
ruby $1 && echo "PASS $1" || (echo "FAIL $1"; exit 1)
|
16
14
|
}
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
run_tests() {
|
17
|
+
if [ "$1" == "" ]; then
|
18
|
+
for test in $(ls *.rb); do
|
19
|
+
run_test $test
|
20
|
+
done
|
21
|
+
else
|
22
|
+
run_test $1.rb
|
23
|
+
fi
|
24
|
+
}
|
25
|
+
|
26
|
+
success="true"
|
27
|
+
|
28
|
+
# Setup rbenv so we can switch rubies below
|
29
|
+
eval "$(rbenv init - --no-rehash)"
|
30
|
+
|
31
|
+
for ruby_version in `ruby -ryaml -e 'puts YAML.load(File.read(".travis.yml"))["rvm"].join(" ")'`; do
|
32
|
+
{
|
33
|
+
echo "testing ruby version $ruby_version" &&
|
34
|
+
rbenv shell $ruby_version &&
|
35
|
+
( cd test && run_tests )
|
36
|
+
} || success="false"
|
37
|
+
done
|
38
|
+
|
39
|
+
if [ $success == "true" ]; then
|
40
|
+
tput bold # bold text
|
41
|
+
tput setaf 2 # green text
|
42
|
+
echo "======================================"
|
43
|
+
echo "= Passed ="
|
44
|
+
echo "======================================"
|
45
|
+
tput sgr0 # reset to default text
|
46
|
+
exit 0
|
22
47
|
else
|
23
|
-
|
48
|
+
tput bold # bold text
|
49
|
+
tput setaf 1 # red text
|
50
|
+
echo "======================================"
|
51
|
+
echo "= FAILED ="
|
52
|
+
echo "======================================"
|
53
|
+
tput sgr0 # reset to default text
|
54
|
+
exit 1
|
24
55
|
fi
|
data/swagger-config.json
CHANGED
data/test/expire_hosted.rb
CHANGED
@@ -2,13 +2,8 @@ require "bundler/setup"
|
|
2
2
|
Bundler.require
|
3
3
|
require 'open-uri'
|
4
4
|
|
5
|
-
api_key = File.read("#{__dir__}/../.docraptor_key").strip
|
6
|
-
unless api_key
|
7
|
-
raise "Please put a valid (paid plan) api key in the .docraptor_key file when testing this feature."
|
8
|
-
end
|
9
|
-
|
10
5
|
DocRaptor.configure do |dr|
|
11
|
-
dr.username =
|
6
|
+
dr.username = "YOUR_API_KEY_HERE"
|
12
7
|
# dr.debugging = true
|
13
8
|
end
|
14
9
|
|
@@ -31,7 +26,7 @@ status_response = nil
|
|
31
26
|
sleep 1
|
32
27
|
end
|
33
28
|
|
34
|
-
actual_document =
|
29
|
+
actual_document = URI.parse(status_response.download_url).open
|
35
30
|
IO.copy_stream(actual_document, output_file)
|
36
31
|
|
37
32
|
output_type = `file -b #{output_file}`
|
@@ -42,7 +37,7 @@ raise "Output was not a PDF" unless output_type.start_with?("PDF")
|
|
42
37
|
$docraptor.expire(status_response.download_id)
|
43
38
|
|
44
39
|
begin
|
45
|
-
actual_document =
|
40
|
+
actual_document = URI.parse(status_response.download_url).open
|
46
41
|
rescue OpenURI::HTTPError => http_error
|
47
42
|
exit 0
|
48
43
|
end
|
data/test/hosted_async.rb
CHANGED
@@ -2,13 +2,8 @@ require "bundler/setup"
|
|
2
2
|
Bundler.require
|
3
3
|
require "open-uri"
|
4
4
|
|
5
|
-
api_key = File.read("#{__dir__}/../.docraptor_key").strip
|
6
|
-
unless api_key
|
7
|
-
raise "Please put a valid (paid plan) api key in the .docraptor_key file when testing this feature."
|
8
|
-
end
|
9
|
-
|
10
5
|
DocRaptor.configure do |dr|
|
11
|
-
dr.username =
|
6
|
+
dr.username = "YOUR_API_KEY_HERE"
|
12
7
|
# dr.debugging = true
|
13
8
|
end
|
14
9
|
|
data/test/hosted_sync.rb
CHANGED
@@ -2,13 +2,8 @@ require "bundler/setup"
|
|
2
2
|
Bundler.require
|
3
3
|
require "open-uri"
|
4
4
|
|
5
|
-
api_key = File.read("#{__dir__}/../.docraptor_key").strip
|
6
|
-
unless api_key
|
7
|
-
raise "Please put a valid (paid plan) api key in the .docraptor_key file when testing this feature."
|
8
|
-
end
|
9
|
-
|
10
5
|
DocRaptor.configure do |dr|
|
11
|
-
dr.username =
|
6
|
+
dr.username = "YOUR_API_KEY_HERE"
|
12
7
|
# dr.debugging = true
|
13
8
|
end
|
14
9
|
|
@@ -24,7 +19,7 @@ output_payload = $docraptor.create_hosted_doc(
|
|
24
19
|
hosted_expires_at: (Time.now + 86400).strftime('%FT%T%:z'), # 1 day from now
|
25
20
|
)
|
26
21
|
|
27
|
-
actual_document =
|
22
|
+
actual_document = URI.parse(output_payload.download_url).open
|
28
23
|
IO.copy_stream(actual_document, output_file)
|
29
24
|
|
30
25
|
output_type = `file -b #{output_file}`
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docraptor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Expected Behavior
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -34,42 +34,62 @@ dependencies:
|
|
34
34
|
name: json
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 2.1.0
|
40
37
|
- - "~>"
|
41
38
|
- !ruby/object:Gem::Version
|
42
39
|
version: '2.1'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 2.1.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.1'
|
47
50
|
- - ">="
|
48
51
|
- !ruby/object:Gem::Version
|
49
52
|
version: 2.1.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: addressable
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
50
57
|
- - "~>"
|
51
58
|
- !ruby/object:Gem::Version
|
52
|
-
version: '2.
|
59
|
+
version: '2.3'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.3.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.3'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.3.0
|
53
73
|
- !ruby/object:Gem::Dependency
|
54
74
|
name: rspec
|
55
75
|
requirement: !ruby/object:Gem::Requirement
|
56
76
|
requirements:
|
57
|
-
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: 3.6.0
|
60
77
|
- - "~>"
|
61
78
|
- !ruby/object:Gem::Version
|
62
79
|
version: '3.6'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.6.0
|
63
83
|
type: :development
|
64
84
|
prerelease: false
|
65
85
|
version_requirements: !ruby/object:Gem::Requirement
|
66
86
|
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 3.6.0
|
70
87
|
- - "~>"
|
71
88
|
- !ruby/object:Gem::Version
|
72
89
|
version: '3.6'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 3.6.0
|
73
93
|
- !ruby/object:Gem::Dependency
|
74
94
|
name: vcr
|
75
95
|
requirement: !ruby/object:Gem::Requirement
|
@@ -242,6 +262,7 @@ files:
|
|
242
262
|
- ".swagger-codegen-ignore"
|
243
263
|
- ".swagger-codegen/VERSION"
|
244
264
|
- ".swagger-revision"
|
265
|
+
- ".travis.yml"
|
245
266
|
- CHANGELOG.md
|
246
267
|
- Gemfile
|
247
268
|
- LICENSE
|
@@ -267,6 +288,7 @@ files:
|
|
267
288
|
- script/fix_gemspec.rb
|
268
289
|
- script/generate_language
|
269
290
|
- script/post_generate_language
|
291
|
+
- script/setup
|
270
292
|
- script/swagger
|
271
293
|
- script/test
|
272
294
|
- script/update_from_upstream
|
@@ -294,14 +316,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
294
316
|
requirements:
|
295
317
|
- - ">="
|
296
318
|
- !ruby/object:Gem::Version
|
297
|
-
version: '
|
319
|
+
version: '2.3'
|
298
320
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
299
321
|
requirements:
|
300
322
|
- - ">="
|
301
323
|
- !ruby/object:Gem::Version
|
302
324
|
version: '0'
|
303
325
|
requirements: []
|
304
|
-
rubygems_version: 3.
|
326
|
+
rubygems_version: 3.2.15
|
305
327
|
signing_key:
|
306
328
|
specification_version: 4
|
307
329
|
summary: A wrapper for the DocRaptor HTML to PDF/XLS service.
|