buildvu 2.0.0 → 2.0.1
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 +6 -4
- data/buildvu.gemspec +5 -4
- data/example_usage.rb +20 -4
- data/lib/buildvu.rb +24 -1
- data/lib/buildvu/version.rb +1 -1
- metadata +10 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 93af82490df9eec79cfc20306dd7be171545665e9fb8b777d20183b93e564b96
|
|
4
|
+
data.tar.gz: e511e7e1a378acd243922f00409d7a287c942672b0c14990b5e589f8e53cd026
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 25d71aa6847ad20760bbe840e4ed468ef97f96f71b4b472ebf28e96414f38501912f94695714fe571fd70bacbb084b91ea102728ce005163daff06ac4f3751a3
|
|
7
|
+
data.tar.gz: 417811aba070b68d06d10846cedf552ef6aedcf31f008e1971f5d3861480f281e73d635caffbcdddae76a7c06caedce18b263ec99e5ad52ec1ef1d1425f917c6
|
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# BuildVu Ruby Client #
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
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).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
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.
|
|
6
6
|
|
|
7
7
|
-----
|
|
8
8
|
|
|
@@ -49,11 +49,13 @@ buildvu = BuildVu.new('localhost:8080/microservice-example')
|
|
|
49
49
|
You can now convert files by calling `convert`:
|
|
50
50
|
```ruby
|
|
51
51
|
# returns a URL where you can view the converted output in your web browser
|
|
52
|
-
puts buildvu.convert('/path/to/input/file')
|
|
53
|
-
puts buildvu.convert('http://link.to/file.pdf', input_type: "download") # Send url pointing to file to server.
|
|
52
|
+
puts buildvu.convert('/path/to/input/file')
|
|
54
53
|
|
|
55
54
|
# you can optionally specify a directory to download the converted output to
|
|
56
55
|
buildvu.convert('/path/to/input/file', output_file_path: '/path/to/output/dir')
|
|
56
|
+
|
|
57
|
+
# alternatively, you can specify a URL as input instead of uploading a file
|
|
58
|
+
puts buildvu.convert('http://link.to/file.pdf', input_type: BuildVu::DOWNLOAD)
|
|
57
59
|
```
|
|
58
60
|
|
|
59
61
|
See `example_usage.rb` for examples.
|
data/buildvu.gemspec
CHANGED
|
@@ -5,14 +5,15 @@ 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
12
|
spec.summary = 'Ruby API for IDRSolutions BuildVu Microservice'
|
|
13
|
-
spec.description = "
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
spec.description = "Convert PDF to HTML5 or SVG with Ruby, using the BuildVu Ruby Client to interact with
|
|
14
|
+
IDRsolutions' BuildVu Microservice Example. The BuildVu Microservice Example is an open source
|
|
15
|
+
project that allows you to convert PDF to HTML5 or SVG by running BuildVu as a web service in
|
|
16
|
+
the cloud or on-premise. For documentation and usage examples, check out our GitHub page. "
|
|
16
17
|
spec.homepage = 'https://github.com/idrsolutions/buildvu-ruby-client'
|
|
17
18
|
spec.license = 'Apache-2.0'
|
|
18
19
|
|
data/example_usage.rb
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
require 'buildvu'
|
|
2
2
|
|
|
3
3
|
buildvu = BuildVu.new'localhost:8080/microservice-example'
|
|
4
|
+
# buildvu = BuildVu.new'https://requestinspector.com/inspect/rf41test'
|
|
4
5
|
|
|
5
6
|
# convert returns a URL (string) where you can view the converted output.
|
|
6
|
-
output_url = buildvu.convert '
|
|
7
|
-
|
|
8
|
-
#
|
|
9
|
-
|
|
7
|
+
# output_url = buildvu.convert 'C:/test/general/ブロッコリ_броколи_ä_é.pdf', output_file_path: 'C:/test/out'
|
|
8
|
+
output_url = buildvu.convert 'C:/test/general/wpgames.pdf', output_file_path: 'C:/test/out'
|
|
9
|
+
# puts 'Converted: ' + output_url
|
|
10
|
+
|
|
11
|
+
require 'CGI'
|
|
12
|
+
|
|
13
|
+
# Encode URI as per RFC-3986
|
|
14
|
+
def encode_uri(uri)
|
|
15
|
+
CGI::escape uri
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Decode URI as per RFC-3986
|
|
19
|
+
def decode_uri(uri)
|
|
20
|
+
CGI::unescape uri
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# filename = encode_uri File.basename('C:/test/general/ブロッコリ.pdf')
|
|
24
|
+
# puts 'RAW: ' + File.basename('C:/test/general/ブロッコリ.pdf')
|
|
25
|
+
# puts 'ENCODED: ' + filename
|
|
10
26
|
|
|
11
27
|
# You can also specify a directory to download the converted output to:
|
|
12
28
|
# buildvu.convert('path/to/input.pdf', output_file_path: 'path/to/output/dir')
|
data/lib/buildvu.rb
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
# Copyright:: IDRsolutions
|
|
20
20
|
# License:: Apache 2.0
|
|
21
21
|
|
|
22
|
+
require 'CGI'
|
|
22
23
|
require 'json'
|
|
23
24
|
require 'rest-client'
|
|
24
25
|
|
|
@@ -54,6 +55,7 @@ class BuildVu
|
|
|
54
55
|
uuid = upload input_file_path, input_type
|
|
55
56
|
|
|
56
57
|
response = nil
|
|
58
|
+
|
|
57
59
|
# check conversion status once every second until complete or error / timeout
|
|
58
60
|
(0..@convert_timeout).each do |i|
|
|
59
61
|
sleep 1
|
|
@@ -63,7 +65,7 @@ class BuildVu
|
|
|
63
65
|
|
|
64
66
|
raise('Server error getting conversion status, see server logs for details') if response['state'] == 'error'
|
|
65
67
|
|
|
66
|
-
raise('Failed: File took longer than
|
|
68
|
+
raise('Failed: File took longer than' + @convert_timeout.to_s + ' seconds to convert') if i == @convert_timeout
|
|
67
69
|
end
|
|
68
70
|
|
|
69
71
|
# download output
|
|
@@ -93,7 +95,18 @@ class BuildVu
|
|
|
93
95
|
raise('Unknown input type\n')
|
|
94
96
|
end
|
|
95
97
|
|
|
98
|
+
# Percent-encode filename
|
|
99
|
+
filename = encode_uri File.basename(input_file_path)
|
|
100
|
+
|
|
101
|
+
# Debug
|
|
102
|
+
puts 'INPUT:' + input_file_path
|
|
103
|
+
puts 'BASENAME: ' + File.basename(input_file_path)
|
|
104
|
+
puts 'ENCODED: ' + filename
|
|
105
|
+
# puts 'HEADER: ' + 'Content-Disposition: form-data; name="file"; filename="' + filename + '"'
|
|
106
|
+
|
|
96
107
|
begin
|
|
108
|
+
# r = RestClient.post(@endpoint, {file: file}, {Content_Disposition: 'form-data; name="file"; filename:"' + filename + '"'}) # THIS WORKS?
|
|
109
|
+
# r = RestClient::Request.execute(method: :post, url: @endpoint, payload: { file: file }, headers: { Content_Disposition: 'form-data; filename:"' + filename + '"', Content_Type: 'application/pdf' })
|
|
97
110
|
r = RestClient.post(@endpoint, params)
|
|
98
111
|
rescue RestClient::ExceptionWithResponse => e
|
|
99
112
|
raise('Error sending url:\n' + e.to_s)
|
|
@@ -133,3 +146,13 @@ class BuildVu
|
|
|
133
146
|
raise('Error downloading conversion output: ' + e.to_s)
|
|
134
147
|
end
|
|
135
148
|
end
|
|
149
|
+
|
|
150
|
+
# Encode URI as per RFC-3986
|
|
151
|
+
def encode_uri(uri)
|
|
152
|
+
CGI::escape uri
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# Decode URI as per RFC-3986
|
|
156
|
+
def decode_uri(uri)
|
|
157
|
+
CGI::unescape uri
|
|
158
|
+
end
|
data/lib/buildvu/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: buildvu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.1
|
|
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: 2018-
|
|
12
|
+
date: 2018-10-08 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
15
|
name: rest-client
|
|
@@ -50,10 +51,12 @@ dependencies:
|
|
|
50
51
|
- - ">="
|
|
51
52
|
- !ruby/object:Gem::Version
|
|
52
53
|
version: '2.1'
|
|
53
|
-
description:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
description: "Convert PDF to HTML5 or SVG with Ruby, using the BuildVu Ruby Client
|
|
55
|
+
to interact with\n IDRsolutions' BuildVu Microservice Example.
|
|
56
|
+
The BuildVu Microservice Example is an open source\n project
|
|
57
|
+
that allows you to convert PDF to HTML5 or SVG by running BuildVu as a web service
|
|
58
|
+
in\n the cloud or on-premise. For documentation and usage
|
|
59
|
+
examples, check out our GitHub page. "
|
|
57
60
|
email:
|
|
58
61
|
- support@idrsolutions.zendesk.com
|
|
59
62
|
executables: []
|
|
@@ -92,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
92
95
|
version: '0'
|
|
93
96
|
requirements: []
|
|
94
97
|
rubyforge_project:
|
|
95
|
-
rubygems_version: 2.6
|
|
98
|
+
rubygems_version: 2.7.6
|
|
96
99
|
signing_key:
|
|
97
100
|
specification_version: 4
|
|
98
101
|
summary: Ruby API for IDRSolutions BuildVu Microservice
|