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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6c2408b72d3639129d60e1fa1c2c66726af876ff
4
- data.tar.gz: 5f4360b109b5d33671ce8733f8ac67918682c9cf
2
+ SHA256:
3
+ metadata.gz: 93af82490df9eec79cfc20306dd7be171545665e9fb8b777d20183b93e564b96
4
+ data.tar.gz: e511e7e1a378acd243922f00409d7a287c942672b0c14990b5e589f8e53cd026
5
5
  SHA512:
6
- metadata.gz: 784e32ea71de0a62e67ddfd5d117c3291bffe7ffb500adec67045251b6f2ba19a35bface289e5324d81509fd5801d790490c81e97583b9c885a6d30725d06313
7
- data.tar.gz: 60059fb5ba71ba1f094e6fd3e8509671e6edd07e291609ce6f37fef539145bc899891259269a6874e606eb1a6d1a9dfa9d88e833c66f60f4a3d68239a5b1093a
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
- BuildVu Ruby Client is the Ruby API for IDRSolution's [BuildVu Microservice Example](https://github.com/idrsolutions/buildvu-microservice-example).
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
- It functions as an easy to use, plug and play library that lets you use [BuildVu](https://www.idrsolutions.com/buildvu/) from Ruby.
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') # File upload
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.
@@ -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 = "The BuildVu Ruby Client is the Ruby API for IDRsolutions' BuildVu Microservice Example, an open
14
- source project that allows you to convert PDF to HTML5 by running BuildVu as an online service.
15
- For documentation and usage examples, check out our GitHub page."
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
 
@@ -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 '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
9
- puts 'Converted: ' + output_url
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')
@@ -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 ' + @convert_timeout.to_s + ' seconds to convert') if i == @convert_timeout
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
@@ -1,3 +1,3 @@
1
1
  class BuildVu
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
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.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-09-17 00:00:00.000000000 Z
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
- The BuildVu Ruby Client is the Ruby API for IDRsolutions' BuildVu Microservice Example, an open
55
- source project that allows you to convert PDF to HTML5 by running BuildVu as an online service.
56
- For documentation and usage examples, check out our GitHub page.
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.14.1
98
+ rubygems_version: 2.7.6
96
99
  signing_key:
97
100
  specification_version: 4
98
101
  summary: Ruby API for IDRSolutions BuildVu Microservice