buildvu 2.0.0 → 3.1.4
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 +5 -5
- data/README.md +35 -9
- data/buildvu.gemspec +10 -7
- data/example_usage.rb +19 -8
- data/lib/buildvu.rb +75 -47
- data/lib/buildvu/version.rb +1 -1
- metadata +21 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0a050414fcce6b74e5c134a4fabc5c87cd319961b029f67813abedd4bad30dd8
|
|
4
|
+
data.tar.gz: 0572ce858a12304777d2823e1b9e982dea4a11b44eec1a3b20bd51874bbcb4cb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9177aa5d193e0388a3f1eab60796ba99e9e97a52748671beb0f1560a660797cc10a3069837f83bf744ed5b5eded748821717143abf4dec90fd457fb869574a6
|
|
7
|
+
data.tar.gz: ed96b17b340123e3ab4fc5695b864570f31da9a6df582064da68124c4b01bd0805f97e88834d153c255c55d21dc0a07de0e67a507395c6593d5ef9639947f78f
|
data/README.md
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
# THIS PACKAGE HAS BEEN DEPRECATED #
|
|
2
|
+
Future development has been directed to the [idrsolutuions client](https://github.com/idrsolutions/idrsolutions-ruby-client), which can be used for the same purpose. This package will receive no more updates.
|
|
3
|
+
|
|
1
4
|
# BuildVu Ruby Client #
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
Convert PDF to HTML5 or SVG with Ruby using the BuildVu Ruby Client to interact with IDRsolutions' [BuildVu Microservice Example](https://github.com/idrsolutions/buildvu-microservice-example).
|
|
7
|
+
|
|
8
|
+
The BuildVu Microservice Example is an open source project that allows you to convert PDF to HTML5 or SVG by running [BuildVu](https://www.idrsolutions.com/buildvu/) as a web service in the cloud or on-premise.
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
IDRsolutions offer a free trial service for running BuildVu with Ruby, more infomation on this can be found [here](https://www.idrsolutions.com/buildvu/convert-pdf-in-ruby/).
|
|
6
11
|
|
|
7
12
|
-----
|
|
8
13
|
|
|
@@ -43,17 +48,38 @@ You can then install it using:
|
|
|
43
48
|
Setup the converter details by creating a new `BuildVu` object:
|
|
44
49
|
```ruby
|
|
45
50
|
require 'buildvu'
|
|
46
|
-
buildvu = BuildVu.new('localhost:8080/microservice
|
|
51
|
+
buildvu = BuildVu.new('http://localhost:8080/buildvu-microservice')
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
If your BuildVu service requires authentication, you can provide credentials when you create the `BuildVu` object:
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
buildvu = BuildVu.new('http://localhost:8080/buildvu-microservice', auth: {login: 'username', pass: 'password'})
|
|
47
58
|
```
|
|
48
59
|
|
|
49
|
-
|
|
60
|
+
|
|
61
|
+
You can now convert files by calling the methods available. `convert()` will start the conversion process. For example to convert to html5:
|
|
62
|
+
```ruby
|
|
63
|
+
# Convert the file with the input method specified
|
|
64
|
+
results = buildvu.convert(input: BuildVu::UPLOAD, file: "path/to/file.pdf")
|
|
65
|
+
|
|
66
|
+
# Return a URL where you can download the converted output
|
|
67
|
+
puts results['downloadUrl']
|
|
68
|
+
```
|
|
69
|
+
Alternatively, you can specify a url as the input source.
|
|
50
70
|
```ruby
|
|
51
|
-
#
|
|
52
|
-
|
|
53
|
-
puts buildvu.convert('http://link.to/file.pdf', input_type: "download") # Send url pointing to file to server.
|
|
71
|
+
# Convert the file with the input method specified
|
|
72
|
+
results = buildvu.convert(input: BuildVu::UPLOAD, url: 'http://link.to/file.pdf')
|
|
54
73
|
|
|
55
|
-
#
|
|
56
|
-
|
|
74
|
+
# Return a URL where you can download the converted output
|
|
75
|
+
puts results['downloadUrl']
|
|
76
|
+
```
|
|
77
|
+
See additional parameters for `convert()` at our [API](https://github.com/idrsolutions/buildvu-microservice-example/blob/master/API.md).
|
|
78
|
+
|
|
79
|
+
Once you have converted the file you can also specify a directory to download the converted output to:
|
|
80
|
+
```ruby
|
|
81
|
+
# Optionally specify a directory to download the converted output to
|
|
82
|
+
buildvu.download_result(conversion_results, 'path/to/output/dir')
|
|
57
83
|
```
|
|
58
84
|
|
|
59
85
|
See `example_usage.rb` for examples.
|
data/buildvu.gemspec
CHANGED
|
@@ -5,18 +5,21 @@ require 'buildvu/version'
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'buildvu'
|
|
7
7
|
spec.version = BuildVu::VERSION
|
|
8
|
-
spec.authors = ['IDRsolutions']
|
|
8
|
+
spec.authors = ['Rob Foley', 'IDRsolutions']
|
|
9
9
|
spec.email = ['support@idrsolutions.zendesk.com']
|
|
10
10
|
spec.date = Time.now.strftime('%Y-%m-%d')
|
|
11
11
|
|
|
12
|
-
spec.summary = 'Ruby API for IDRSolutions BuildVu Microservice'
|
|
13
|
-
spec.description = "
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
spec.summary = '[DEPRECATED] Ruby API for IDRSolutions BuildVu Microservice'
|
|
13
|
+
spec.description = "Future development has been directed to idrsolutions-ruby-client, which can be used for the same purpose.
|
|
14
|
+
This package will receive no more updates.
|
|
15
|
+
Convert PDF to HTML5 or SVG with Ruby, using the BuildVu Ruby Client to interact with
|
|
16
|
+
IDRsolutions' BuildVu Microservice Example. The BuildVu Microservice Example is an open source
|
|
17
|
+
project that allows you to convert PDF to HTML5 or SVG by running BuildVu as a web service in
|
|
18
|
+
the cloud or on-premise. For documentation and usage examples, check out our GitHub page. "
|
|
16
19
|
spec.homepage = 'https://github.com/idrsolutions/buildvu-ruby-client'
|
|
17
20
|
spec.license = 'Apache-2.0'
|
|
18
21
|
|
|
19
|
-
spec.required_ruby_version = '>= 2.
|
|
22
|
+
spec.required_ruby_version = '>= 2.3.0'
|
|
20
23
|
|
|
21
24
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
22
25
|
f.match(%r{^(test|spec|features)/})
|
|
@@ -25,6 +28,6 @@ Gem::Specification.new do |spec|
|
|
|
25
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
26
29
|
spec.require_paths = ['lib']
|
|
27
30
|
|
|
28
|
-
spec.add_runtime_dependency '
|
|
31
|
+
spec.add_runtime_dependency 'faraday', '~> 0.17'
|
|
29
32
|
spec.add_runtime_dependency 'json', '~> 2.1', '>= 2.1'
|
|
30
33
|
end
|
data/example_usage.rb
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
require 'buildvu'
|
|
2
2
|
|
|
3
|
-
buildvu = BuildVu.new'localhost:8080/microservice
|
|
3
|
+
buildvu = BuildVu.new'localhost:8080/buildvu-microservice'
|
|
4
4
|
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
# Upload a local file to the BuildVu microservice
|
|
6
|
+
# convert() returns a hash collection with the conversion results.
|
|
7
|
+
conversion_results = buildvu.convert input: BuildVu::UPLOAD, file: 'path/to/file.pdf'
|
|
8
|
+
|
|
9
|
+
# You can specify other parameters for the API as named parameters, for example
|
|
10
|
+
# here is the use of the callbackUrl parameter which is a URL that you want to
|
|
11
|
+
# be updated when the conversion finishes.
|
|
12
|
+
# See https://github.com/idrsolutions/buildvu-microservice-example/blob/master/API.md
|
|
13
|
+
#conversion_results = buildvu.convert input: BuildVu::UPLOAD, callbackUrl: 'http://listener.url'
|
|
14
|
+
|
|
15
|
+
# Alternatively, you can specify a url from which the server will download the file to convert.
|
|
16
|
+
#conversion_results = buildvu.convert url: 'http://link.to/filename', input: BuildVu::DOWNLOAD
|
|
10
17
|
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
output_url = conversion_results['downloadUrl']
|
|
19
|
+
|
|
20
|
+
# After the conversion you can also specify a directory to download the output to:
|
|
21
|
+
#buildvu.download_result conversion_results, 'path/to/output/dir'
|
|
22
|
+
|
|
23
|
+
puts 'Converted: ' + output_url
|
data/lib/buildvu.rb
CHANGED
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
# License:: Apache 2.0
|
|
21
21
|
|
|
22
22
|
require 'json'
|
|
23
|
-
require '
|
|
23
|
+
require 'Faraday'
|
|
24
|
+
|
|
24
25
|
|
|
25
26
|
# Used to interact with IDRsolutions' BuildVu web service
|
|
26
27
|
# For detailed usage instructions, see GitHub[https://github.com/idrsolutions/buildvu-ruby-client]
|
|
@@ -32,26 +33,30 @@ class BuildVu
|
|
|
32
33
|
@base_endpoint = nil
|
|
33
34
|
@endpoint = nil
|
|
34
35
|
@convert_timeout = nil
|
|
36
|
+
@auth = nil
|
|
35
37
|
|
|
36
38
|
# Constructor, setup the converter details
|
|
37
39
|
# Params:
|
|
38
40
|
# +url+:: string, the URL of the BuildVu web service.
|
|
39
41
|
# +conversion_timeout+:: int, (optional) the time to wait (in seconds) before timing out. Set to 30 by default.
|
|
40
|
-
|
|
42
|
+
# +auth+:: array, (optional) the username and password to use for HTTP Authentication. Set to nil by default
|
|
43
|
+
def initialize(url, conversion_timeout: 30, auth: nil)
|
|
41
44
|
@base_endpoint = url
|
|
42
45
|
@endpoint = @base_endpoint + '/buildvu'
|
|
43
46
|
@convert_timeout = conversion_timeout
|
|
47
|
+
@auth = auth
|
|
44
48
|
end
|
|
45
49
|
|
|
46
|
-
# Converts the given file and returns
|
|
47
|
-
#
|
|
50
|
+
# Converts the given file and returns a hash collection with the conversion results. Requires the 'input' and either 'url' or
|
|
51
|
+
# 'file' parameters to run. You can then use the values from the hash, or use methods like download_result().
|
|
48
52
|
# Params:
|
|
49
|
-
# +
|
|
50
|
-
# +
|
|
53
|
+
# +input+:: string, the method of inputting a file. Examples are BuildVu::UPLOAD or BuildVu::DOWNLOAD
|
|
54
|
+
# +file+:: string, (optional) Location of the PDF to convert, i.e 'path/to/input.pdf'
|
|
55
|
+
# +url+:: string, (optional) the url for the server to download a PDF from
|
|
51
56
|
#
|
|
52
|
-
# Returns: string,
|
|
53
|
-
def convert(
|
|
54
|
-
uuid = upload
|
|
57
|
+
# Returns: hash [string: string], The results of the conversion
|
|
58
|
+
def convert(**params)
|
|
59
|
+
uuid = upload params
|
|
55
60
|
|
|
56
61
|
response = nil
|
|
57
62
|
# check conversion status once every second until complete or error / timeout
|
|
@@ -61,75 +66,98 @@ class BuildVu
|
|
|
61
66
|
|
|
62
67
|
break if response['state'] == 'processed'
|
|
63
68
|
|
|
69
|
+
break unless params[:callbackUrl].nil?
|
|
70
|
+
|
|
64
71
|
raise('Server error getting conversion status, see server logs for details') if response['state'] == 'error'
|
|
65
72
|
|
|
66
73
|
raise('Failed: File took longer than ' + @convert_timeout.to_s + ' seconds to convert') if i == @convert_timeout
|
|
67
74
|
end
|
|
68
75
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
response
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Downloads the zip file produced by the microservice. Provide '.' as the output_file_path if you wish to use the
|
|
80
|
+
# current directory. Will use the filename of the zip on the server if none is specified.
|
|
81
|
+
# Params:
|
|
82
|
+
# +output_file_path+:: string, the output location to save the zip file
|
|
83
|
+
# +file_name+:: string, (optional) the custom name for the zip file. This should not include .zip
|
|
84
|
+
def download_result(results, output_file_path, file_name=nil)
|
|
85
|
+
download_url = results['downloadUrl']
|
|
86
|
+
|
|
87
|
+
raise('Error: downloadUrl parameter is empty') if download_url.nil?
|
|
88
|
+
|
|
89
|
+
if file_name.nil?
|
|
90
|
+
output_file_path += '/' + download_url.split('/').last
|
|
91
|
+
else
|
|
92
|
+
output_file_path += '/' + file_name + '.zip'
|
|
75
93
|
end
|
|
76
94
|
|
|
77
|
-
|
|
95
|
+
download download_url, output_file_path
|
|
78
96
|
end
|
|
79
97
|
|
|
80
98
|
private
|
|
81
99
|
|
|
82
100
|
# Upload file at given path to converter, return UUID if successful
|
|
83
|
-
def upload(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
when DOWNLOAD
|
|
91
|
-
params[:url] = input_file_path
|
|
92
|
-
else
|
|
93
|
-
raise('Unknown input type\n')
|
|
94
|
-
end
|
|
101
|
+
def upload(params)
|
|
102
|
+
|
|
103
|
+
file_path = params.delete(:file)
|
|
104
|
+
params[:file] = Faraday::UploadIO.new(file_path, 'application/pdf') if !file_path.nil?
|
|
105
|
+
|
|
106
|
+
uri = URI(@endpoint)
|
|
107
|
+
host = uri.scheme + "://" + uri.host + ':' + uri.port.to_s;
|
|
95
108
|
|
|
96
109
|
begin
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
110
|
+
conn = Faraday.new(host) do |f|
|
|
111
|
+
f.request :multipart
|
|
112
|
+
f.request :url_encoded
|
|
113
|
+
f.adapter Faraday.default_adapter
|
|
114
|
+
f.basic_auth @auth[:login], @auth[:pass] unless @auth.nil?
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
r = conn.post(uri.path, params)
|
|
118
|
+
|
|
119
|
+
rescue StandardError => e
|
|
120
|
+
raise("Error sending url:\n" + e.to_s)
|
|
100
121
|
end
|
|
101
122
|
|
|
102
|
-
|
|
103
|
-
|
|
123
|
+
raise "Error uploading file:\n Server returned 401 - Unauthorized" if r.status == 401
|
|
124
|
+
r.status == 200 ? uuid = JSON.parse(r.body)['uuid'] : raise("Error uploading file:\n Server returned response\n" + r.status.to_s + " - " + JSON.parse(r.body)['error'])
|
|
104
125
|
|
|
105
|
-
uuid.nil? ? raise(
|
|
126
|
+
uuid.nil? ? raise("Error uploading file:\nServer returned null UUID") : uuid
|
|
106
127
|
end
|
|
107
128
|
|
|
108
129
|
# Check conversion status
|
|
109
130
|
def poll_status(uuid)
|
|
131
|
+
uri = URI(@endpoint)
|
|
132
|
+
host = uri.scheme + "://" + uri.host + ':' + uri.port.to_s;
|
|
133
|
+
|
|
110
134
|
begin
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
135
|
+
conn = Faraday.new(host) do |req|
|
|
136
|
+
req.params['uuid'] = uuid
|
|
137
|
+
req.request :url_encoded
|
|
138
|
+
req.adapter Faraday.default_adapter
|
|
139
|
+
req.basic_auth @auth[:login], @auth[:pass] unless @auth.nil?
|
|
140
|
+
end
|
|
141
|
+
r = conn.get(uri.path)
|
|
142
|
+
rescue StandardError => e
|
|
143
|
+
raise("Error checking conversion status:\n" + e.to_s)
|
|
114
144
|
end
|
|
115
145
|
|
|
116
|
-
r.
|
|
117
|
-
'response\n' + r.code)
|
|
146
|
+
r.status == 200 ? response = JSON.parse(r.body) : raise("Error checking conversion status:\n Server returned response\n" + r.status.to_s + " - " + JSON.parse(r.body)['error'])
|
|
118
147
|
|
|
119
148
|
response
|
|
120
149
|
end
|
|
121
150
|
|
|
122
151
|
# Download converted output to the given location
|
|
123
152
|
def download(download_url, output_file_path)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
output_file.write data
|
|
128
|
-
end
|
|
129
|
-
}
|
|
130
|
-
RestClient::Request.new(method: :get, url: download_url, block_response: block).execute
|
|
153
|
+
conn = Faraday.new download_url do |req|
|
|
154
|
+
req.adapter Faraday.default_adapter
|
|
155
|
+
req.basic_auth @auth[:login], @auth[:pass] unless @auth.nil?
|
|
131
156
|
end
|
|
132
|
-
|
|
157
|
+
response = conn.get(download_url)
|
|
158
|
+
File.open(output_file_path, 'wb') { |fp| fp.write(response.body) }
|
|
159
|
+
|
|
160
|
+
rescue StandardError => e
|
|
133
161
|
raise('Error downloading conversion output: ' + e.to_s)
|
|
134
162
|
end
|
|
135
163
|
end
|
data/lib/buildvu/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,59 +1,58 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: buildvu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
+
- Rob Foley
|
|
7
8
|
- IDRsolutions
|
|
8
9
|
autorequire:
|
|
9
10
|
bindir: exe
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
+
date: 2020-08-03 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
15
|
+
name: faraday
|
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
|
16
17
|
requirements:
|
|
17
18
|
- - "~>"
|
|
18
19
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
20
|
-
- - ">="
|
|
21
|
-
- !ruby/object:Gem::Version
|
|
22
|
-
version: 2.0.2
|
|
20
|
+
version: '0.17'
|
|
23
21
|
type: :runtime
|
|
24
22
|
prerelease: false
|
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
24
|
requirements:
|
|
27
25
|
- - "~>"
|
|
28
26
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '
|
|
30
|
-
- - ">="
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: 2.0.2
|
|
27
|
+
version: '0.17'
|
|
33
28
|
- !ruby/object:Gem::Dependency
|
|
34
29
|
name: json
|
|
35
30
|
requirement: !ruby/object:Gem::Requirement
|
|
36
31
|
requirements:
|
|
37
|
-
- - "
|
|
32
|
+
- - ">="
|
|
38
33
|
- !ruby/object:Gem::Version
|
|
39
34
|
version: '2.1'
|
|
40
|
-
- - "
|
|
35
|
+
- - "~>"
|
|
41
36
|
- !ruby/object:Gem::Version
|
|
42
37
|
version: '2.1'
|
|
43
38
|
type: :runtime
|
|
44
39
|
prerelease: false
|
|
45
40
|
version_requirements: !ruby/object:Gem::Requirement
|
|
46
41
|
requirements:
|
|
47
|
-
- - "
|
|
42
|
+
- - ">="
|
|
48
43
|
- !ruby/object:Gem::Version
|
|
49
44
|
version: '2.1'
|
|
50
|
-
- - "
|
|
45
|
+
- - "~>"
|
|
51
46
|
- !ruby/object:Gem::Version
|
|
52
47
|
version: '2.1'
|
|
53
|
-
description:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
description: "Future development has been directed to idrsolutions-ruby-client, which
|
|
49
|
+
can be used for the same purpose. \n This package will receive
|
|
50
|
+
no more updates. \n Convert PDF to HTML5 or SVG with Ruby,
|
|
51
|
+
using the BuildVu Ruby Client to interact with\n IDRsolutions'
|
|
52
|
+
BuildVu Microservice Example. The BuildVu Microservice Example is an open source\n
|
|
53
|
+
\ project that allows you to convert PDF to HTML5 or SVG by
|
|
54
|
+
running BuildVu as a web service in\n the cloud or on-premise.
|
|
55
|
+
For documentation and usage examples, check out our GitHub page. "
|
|
57
56
|
email:
|
|
58
57
|
- support@idrsolutions.zendesk.com
|
|
59
58
|
executables: []
|
|
@@ -84,16 +83,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
84
83
|
requirements:
|
|
85
84
|
- - ">="
|
|
86
85
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: 2.
|
|
86
|
+
version: 2.3.0
|
|
88
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
88
|
requirements:
|
|
90
89
|
- - ">="
|
|
91
90
|
- !ruby/object:Gem::Version
|
|
92
91
|
version: '0'
|
|
93
92
|
requirements: []
|
|
94
|
-
|
|
95
|
-
rubygems_version: 2.6.14.1
|
|
93
|
+
rubygems_version: 3.0.3
|
|
96
94
|
signing_key:
|
|
97
95
|
specification_version: 4
|
|
98
|
-
summary: Ruby API for IDRSolutions BuildVu Microservice
|
|
96
|
+
summary: "[DEPRECATED] Ruby API for IDRSolutions BuildVu Microservice"
|
|
99
97
|
test_files: []
|