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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 8daba6def01e77256ca5532b78978f463776aa3fb169be97ad07e94abd35cff1
4
- data.tar.gz: a594083549ed0d7193d75dc3d377bcb72789cc67a108bbe08f35ea970cda84c1
2
+ SHA1:
3
+ metadata.gz: 6c2408b72d3639129d60e1fa1c2c66726af876ff
4
+ data.tar.gz: 5f4360b109b5d33671ce8733f8ac67918682c9cf
5
5
  SHA512:
6
- metadata.gz: 9cd012f9bfee425cd37bb1fdf881afc0a03f2a81d2b9fa2d2551f27051856a4b61a32800b978903e14de7a7cb850dc4b6ab346a65de83670d25f0a08cdd2f4b5
7
- data.tar.gz: 025aa3969b8dafdde558d38914dfdef95b3569a1339554123776c41da1c2919fe08e98d9de9490c3a24fc7460cbea7b1b401acd0771546ec84ac359c6d498de1
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.
@@ -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 'C:/test/general/%E3%83%96%E3%83%AD%E3%83%83%E3%82%B3%E3%83%AA%E3%83%BC.pdf', 'C:/test/out'
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')
@@ -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 = nil)
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
- file = File.open(input_file_path, 'rb')
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, file: file)
97
+ r = RestClient.post(@endpoint, params)
85
98
  rescue RestClient::ExceptionWithResponse => e
86
- raise('Error uploading file:\n' + e.message)
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' +
@@ -1,3 +1,3 @@
1
1
  class BuildVu
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
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: 1.0.0
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-07-31 00:00:00.000000000 Z
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.7.6
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