hypdf 1.0.14 → 1.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/hypdf.gemspec +1 -2
- data/lib/hypdf.rb +30 -5
- data/lib/hypdf/composite_io.rb +57 -0
- data/lib/hypdf/exceptions.rb +2 -0
- data/lib/hypdf/version.rb +1 -1
- data/spec/hypdf_spec.rb +0 -0
- data/spec/spec_helper.rb +0 -0
- metadata +13 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 24b51670db389835fe3db9cc30ffea3d6e7f20ffff16608d9f4799f699beda77
|
4
|
+
data.tar.gz: b1b7915760e6a07d3ff77ed9cbb1519b54fcd258f66f60159ee29e8a07029989
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 882c2f3d4d9bcb0fd80f67ebee9ab03e4142bab8add8dce3d6eaaea92f614a59f204c5e0776d86d728c38a39c66917ed61bddd94d4b7e5a70df96c3b23caa89a
|
7
|
+
data.tar.gz: fa23247b8a45da28fcd6055ce6c1db8329e0c84d8117c31533cfbc2b13a2c2bead0f0db57c01d6bbcf52dc19225b80786ea5a60e48bcc78dbd04214bbdb25fb4
|
data/.gitignore
CHANGED
File without changes
|
data/.rspec
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/hypdf.gemspec
CHANGED
@@ -17,7 +17,6 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
|
-
gem.add_dependency "httparty", "
|
21
|
-
gem.add_dependency "httmultiparty", "~> 0.3"
|
20
|
+
gem.add_dependency "httparty", "> 0.16.0", "< 1.0"
|
22
21
|
gem.add_development_dependency "rspec"
|
23
22
|
end
|
data/lib/hypdf.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require '
|
1
|
+
require 'json'
|
2
|
+
require 'hypdf/exceptions'
|
3
|
+
require 'hypdf/composite_io'
|
4
|
+
require 'httparty'
|
4
5
|
|
5
6
|
class HyPDF
|
6
7
|
|
@@ -31,7 +32,7 @@ class HyPDF
|
|
31
32
|
options[:user] ||= ENV["HYPDF_USER"]
|
32
33
|
options[:password] ||= ENV["HYPDF_PASSWORD"]
|
33
34
|
|
34
|
-
response =
|
35
|
+
response = HTTParty.get(
|
35
36
|
"#{HyPDF::HOST}/jobstatus",
|
36
37
|
query: options
|
37
38
|
)
|
@@ -42,6 +43,7 @@ class HyPDF
|
|
42
43
|
when 402 then raise HyPDF::PaymentRequired
|
43
44
|
when 403 then raise HyPDF::S3AccessDenied
|
44
45
|
when 404 then raise HyPDF::NoSuchBucket
|
46
|
+
when 408 then raise HyPDF::RequestTimeout
|
45
47
|
when 500 then raise HyPDF::InternalServerError
|
46
48
|
end
|
47
49
|
end
|
@@ -108,6 +110,28 @@ class HyPDF
|
|
108
110
|
end
|
109
111
|
end
|
110
112
|
|
113
|
+
def encryptpdf(file, options = {})
|
114
|
+
options.merge!(file: File.new(file))
|
115
|
+
response = request('encryptpdf', options).body
|
116
|
+
|
117
|
+
if options[:bucket].nil?
|
118
|
+
{pdf: response}
|
119
|
+
else
|
120
|
+
JSON.parse(response, symbolize_names: true)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def decryptpdf(file, options = {})
|
125
|
+
options.merge!(file: File.new(file))
|
126
|
+
response = request('decryptpdf', options).body
|
127
|
+
|
128
|
+
if options[:bucket].nil?
|
129
|
+
{pdf: response}
|
130
|
+
else
|
131
|
+
JSON.parse(response, symbolize_names: true)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
111
135
|
private
|
112
136
|
|
113
137
|
def file_for(param, index)
|
@@ -130,7 +154,7 @@ class HyPDF
|
|
130
154
|
body[:user] ||= ENV["HYPDF_USER"]
|
131
155
|
body[:password] ||= ENV["HYPDF_PASSWORD"]
|
132
156
|
|
133
|
-
response =
|
157
|
+
response = HTTParty.post("#{HyPDF::HOST}/#{method}", body: body)
|
134
158
|
case response.code
|
135
159
|
when 200 then response
|
136
160
|
when 400 then raise HyPDF::ContentRequired
|
@@ -138,6 +162,7 @@ class HyPDF
|
|
138
162
|
when 402 then raise HyPDF::PaymentRequired
|
139
163
|
when 403 then raise HyPDF::S3AccessDenied
|
140
164
|
when 404 then raise HyPDF::NoSuchBucket
|
165
|
+
when 408 then raise HyPDF::RequestTimeout
|
141
166
|
when 500 then raise HyPDF::InternalServerError
|
142
167
|
end
|
143
168
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#--
|
2
|
+
# Origin: https://raw.githubusercontent.com/nicksieger/multipart-post/master/lib/composite_io.rb
|
3
|
+
# Copyright (c) 2007-2012 Nick Sieger.
|
4
|
+
#++
|
5
|
+
|
6
|
+
# Convenience methods for dealing with files and IO that are to be uploaded.
|
7
|
+
class UploadIO
|
8
|
+
# Create an upload IO suitable for including in the params hash of a
|
9
|
+
# Net::HTTP::Post::Multipart.
|
10
|
+
#
|
11
|
+
# Can take two forms. The first accepts a filename and content type, and
|
12
|
+
# opens the file for reading (to be closed by finalizer).
|
13
|
+
#
|
14
|
+
# The second accepts an already-open IO, but also requires a third argument,
|
15
|
+
# the filename from which it was opened (particularly useful/recommended if
|
16
|
+
# uploading directly from a form in a framework, which often save the file to
|
17
|
+
# an arbitrarily named RackMultipart file in /tmp).
|
18
|
+
#
|
19
|
+
# Usage:
|
20
|
+
#
|
21
|
+
# UploadIO.new("file.txt", "text/plain")
|
22
|
+
# UploadIO.new(file_io, "text/plain", "file.txt")
|
23
|
+
#
|
24
|
+
attr_reader :content_type, :original_filename, :local_path, :io, :opts, :path
|
25
|
+
|
26
|
+
def initialize(filename_or_io, content_type, filename = nil, opts = {})
|
27
|
+
io = filename_or_io
|
28
|
+
local_path = ""
|
29
|
+
if io.respond_to? :read
|
30
|
+
# in Ruby 1.9.2, StringIOs no longer respond to path
|
31
|
+
# (since they respond to :length, so we don't need their local path, see parts.rb:41)
|
32
|
+
local_path = filename_or_io.respond_to?(:path) ? filename_or_io.path : filename
|
33
|
+
else
|
34
|
+
io = File.open(filename_or_io)
|
35
|
+
local_path = filename_or_io
|
36
|
+
end
|
37
|
+
filename ||= local_path
|
38
|
+
|
39
|
+
@content_type = content_type
|
40
|
+
@original_filename = File.basename(filename)
|
41
|
+
@local_path = @path = local_path
|
42
|
+
@io = io
|
43
|
+
@opts = opts
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.convert!(io, content_type, original_filename, local_path)
|
47
|
+
raise ArgumentError, "convert! has been removed. You must now wrap IOs using:\nUploadIO.new(filename_or_io, content_type, filename=nil)\nPlease update your code."
|
48
|
+
end
|
49
|
+
|
50
|
+
def method_missing(*args)
|
51
|
+
@io.send(*args)
|
52
|
+
end
|
53
|
+
|
54
|
+
def respond_to?(meth, include_all = false)
|
55
|
+
@io.respond_to?(meth, include_all) || super(meth, include_all)
|
56
|
+
end
|
57
|
+
end
|
data/lib/hypdf/exceptions.rb
CHANGED
data/lib/hypdf/version.rb
CHANGED
data/spec/hypdf_spec.rb
CHANGED
File without changes
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,43 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hypdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- redfield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
19
|
+
version: 0.16.0
|
20
|
+
- - "<"
|
25
21
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: httmultiparty
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.3'
|
22
|
+
version: '1.0'
|
34
23
|
type: :runtime
|
35
24
|
prerelease: false
|
36
25
|
version_requirements: !ruby/object:Gem::Requirement
|
37
26
|
requirements:
|
38
|
-
- - "
|
27
|
+
- - ">"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.16.0
|
30
|
+
- - "<"
|
39
31
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
32
|
+
version: '1.0'
|
41
33
|
- !ruby/object:Gem::Dependency
|
42
34
|
name: rspec
|
43
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,6 +59,7 @@ files:
|
|
67
59
|
- Rakefile
|
68
60
|
- hypdf.gemspec
|
69
61
|
- lib/hypdf.rb
|
62
|
+
- lib/hypdf/composite_io.rb
|
70
63
|
- lib/hypdf/exceptions.rb
|
71
64
|
- lib/hypdf/version.rb
|
72
65
|
- spec/hypdf_spec.rb
|
@@ -90,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
83
|
- !ruby/object:Gem::Version
|
91
84
|
version: '0'
|
92
85
|
requirements: []
|
93
|
-
|
94
|
-
rubygems_version: 2.5.1
|
86
|
+
rubygems_version: 3.0.3
|
95
87
|
signing_key:
|
96
88
|
specification_version: 4
|
97
89
|
summary: Ruby wrapper around the HyPDF API
|