buildvu 1.0.0 → 2.0.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.
- checksums.yaml +5 -5
- data/README.md +7 -6
- data/example_usage.rb +4 -2
- data/lib/buildvu.rb +20 -7
- data/lib/buildvu/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 6c2408b72d3639129d60e1fa1c2c66726af876ff
|
|
4
|
+
data.tar.gz: 5f4360b109b5d33671ce8733f8ac67918682c9cf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 784e32ea71de0a62e67ddfd5d117c3291bffe7ffb500adec67045251b6f2ba19a35bface289e5324d81509fd5801d790490c81e97583b9c885a6d30725d06313
|
|
7
|
+
data.tar.gz: 60059fb5ba71ba1f094e6fd3e8509671e6edd07e291609ce6f37fef539145bc899891259269a6874e606eb1a6d1a9dfa9d88e833c66f60f4a3d68239a5b1093a
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
BuildVu Ruby Client is the Ruby API for IDRSolution's [BuildVu Microservice Example](https://github.com/idrsolutions/buildvu-microservice-example).
|
|
4
4
|
|
|
5
|
-
It functions as an easy to use, plug and play library that lets you use [BuildVu](https://www.idrsolutions.com/buildvu/) from Ruby.
|
|
5
|
+
It functions as an easy to use, plug and play library that lets you use [BuildVu](https://www.idrsolutions.com/buildvu/) from Ruby.
|
|
6
6
|
|
|
7
7
|
-----
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ It functions as an easy to use, plug and play library that lets you use [BuildVu
|
|
|
10
10
|
|
|
11
11
|
## Using RubyGems: ##
|
|
12
12
|
|
|
13
|
-
Run the following command to install
|
|
13
|
+
Run the following command to install
|
|
14
14
|
|
|
15
15
|
$ gem install buildvu
|
|
16
16
|
|
|
@@ -23,7 +23,7 @@ gem 'buildvu'
|
|
|
23
23
|
...and then execute:
|
|
24
24
|
|
|
25
25
|
$ bundle install
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
## Building the gem manually: ##
|
|
28
28
|
|
|
29
29
|
Run the following command to build the gem locally:
|
|
@@ -49,10 +49,11 @@ 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')
|
|
52
|
+
puts buildvu.convert('/path/to/input/file') # File upload
|
|
53
|
+
puts buildvu.convert('http://link.to/file.pdf', input_type: "download") # Send url pointing to file to server.
|
|
53
54
|
|
|
54
55
|
# you can optionally specify a directory to download the converted output to
|
|
55
|
-
buildvu.convert('/path/to/input/file', '/path/to/output/dir')
|
|
56
|
+
buildvu.convert('/path/to/input/file', output_file_path: '/path/to/output/dir')
|
|
56
57
|
```
|
|
57
58
|
|
|
58
59
|
See `example_usage.rb` for examples.
|
|
@@ -86,4 +87,4 @@ Unless required by applicable law or agreed to in writing, software
|
|
|
86
87
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
87
88
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
88
89
|
See the License for the specific language governing permissions and
|
|
89
|
-
limitations under the License.
|
|
90
|
+
limitations under the License.
|
data/example_usage.rb
CHANGED
|
@@ -3,8 +3,10 @@ require 'buildvu'
|
|
|
3
3
|
buildvu = BuildVu.new'localhost:8080/microservice-example'
|
|
4
4
|
|
|
5
5
|
# convert returns a URL (string) where you can view the converted output.
|
|
6
|
-
output_url = buildvu.convert '
|
|
6
|
+
output_url = buildvu.convert 'path/to/file.pdf'
|
|
7
|
+
# Or alternatively: to upload a url pointing to a pdf file with:
|
|
8
|
+
# output_url = buildvu.convert 'path/to/file.pdf', input_type: BuildVu::DOWNLOAD
|
|
7
9
|
puts 'Converted: ' + output_url
|
|
8
10
|
|
|
9
11
|
# You can also specify a directory to download the converted output to:
|
|
10
|
-
# buildvu.convert('path/to/input.pdf', 'path/to/output/dir')
|
|
12
|
+
# buildvu.convert('path/to/input.pdf', output_file_path: 'path/to/output/dir')
|
data/lib/buildvu.rb
CHANGED
|
@@ -25,6 +25,10 @@ require 'rest-client'
|
|
|
25
25
|
# Used to interact with IDRsolutions' BuildVu web service
|
|
26
26
|
# For detailed usage instructions, see GitHub[https://github.com/idrsolutions/buildvu-ruby-client]
|
|
27
27
|
class BuildVu
|
|
28
|
+
|
|
29
|
+
DOWNLOAD = 'download'
|
|
30
|
+
UPLOAD = 'upload'
|
|
31
|
+
|
|
28
32
|
@base_endpoint = nil
|
|
29
33
|
@endpoint = nil
|
|
30
34
|
@convert_timeout = nil
|
|
@@ -46,11 +50,10 @@ class BuildVu
|
|
|
46
50
|
# +output_file_path+:: string, (optional) the directory the output will be saved in, i.e 'path/to/output/dir'
|
|
47
51
|
#
|
|
48
52
|
# Returns: string, the URL where the HTML output can be previewed online
|
|
49
|
-
def convert(input_file_path, output_file_path
|
|
50
|
-
uuid = upload input_file_path
|
|
53
|
+
def convert(input_file_path, output_file_path: nil, input_type: UPLOAD)
|
|
54
|
+
uuid = upload input_file_path, input_type
|
|
51
55
|
|
|
52
56
|
response = nil
|
|
53
|
-
|
|
54
57
|
# check conversion status once every second until complete or error / timeout
|
|
55
58
|
(0..@convert_timeout).each do |i|
|
|
56
59
|
sleep 1
|
|
@@ -77,13 +80,23 @@ class BuildVu
|
|
|
77
80
|
private
|
|
78
81
|
|
|
79
82
|
# Upload file at given path to converter, return UUID if successful
|
|
80
|
-
def upload(input_file_path)
|
|
81
|
-
|
|
83
|
+
def upload(input_file_path, input_type)
|
|
84
|
+
params = {:input => input_type}
|
|
85
|
+
|
|
86
|
+
case input_type
|
|
87
|
+
when UPLOAD
|
|
88
|
+
file = File.open(input_file_path, 'rb')
|
|
89
|
+
params[:file] = file
|
|
90
|
+
when DOWNLOAD
|
|
91
|
+
params[:url] = input_file_path
|
|
92
|
+
else
|
|
93
|
+
raise('Unknown input type\n')
|
|
94
|
+
end
|
|
82
95
|
|
|
83
96
|
begin
|
|
84
|
-
r = RestClient.post(@endpoint,
|
|
97
|
+
r = RestClient.post(@endpoint, params)
|
|
85
98
|
rescue RestClient::ExceptionWithResponse => e
|
|
86
|
-
raise('Error
|
|
99
|
+
raise('Error sending url:\n' + e.to_s)
|
|
87
100
|
end
|
|
88
101
|
|
|
89
102
|
r.code == 200 ? uuid = JSON.parse(r.body)['uuid'] : raise('Error uploading file:\n Server returned response\n' +
|
data/lib/buildvu/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: buildvu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- IDRsolutions
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-09-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rest-client
|
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
92
92
|
version: '0'
|
|
93
93
|
requirements: []
|
|
94
94
|
rubyforge_project:
|
|
95
|
-
rubygems_version: 2.
|
|
95
|
+
rubygems_version: 2.6.14.1
|
|
96
96
|
signing_key:
|
|
97
97
|
specification_version: 4
|
|
98
98
|
summary: Ruby API for IDRSolutions BuildVu Microservice
|