idr_cloud_client 1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f230aca7d50227ba16e30b2e1f4c6b7bdc066c91eaec6a9c5c4dbcc0d45daf8d
4
+ data.tar.gz: f4eebdaafdda240052c3030765f5f05560e533a19d8b2d72227de83f26aa0e07
5
+ SHA512:
6
+ metadata.gz: b750c5e47035580ba78b7b135032a719e3203c6772637fb5f879f8afc594d4abe298d839d96a9033a9e8bdcd1c74aaae5905aeba3ad8d0c79582c51918dd883a
7
+ data.tar.gz: 68aed215de5869e3a6377db5200f6e47d1f09f8c2135d2a6cb0d07b3bbf163250fe7702c0fc97a0dbddd72c56fe68b6afa0dc037a017cdc7fbb9e49f0879be98
@@ -0,0 +1,9 @@
1
+ # Automatically detect & normalise text files that aren't already specified below
2
+ * text=auto
3
+
4
+ # Normalise line endings on checkin (set "text" attribute)
5
+ *.in text
6
+ *.cfg text
7
+ *.rst text
8
+ *.md text
9
+ *.rb text
@@ -0,0 +1,56 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team [here](https://idrsolutions.zendesk.com/hc/en-us/requests/new). All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,82 @@
1
+ # IDRSolutions Ruby Client for BuildVu #
2
+
3
+ Convert PDF to HTML5 or SVG with Ruby, using the IDRSolutions Ruby Client to
4
+ interact with IDRsolutions' [BuildVu Microservice Example](https://github.com/idrsolutions/buildvu-microservice-example).
5
+
6
+ The BuildVu Microservice Example is an open source project that allows you to
7
+ convert PDF to HTML5 or SVG by running [BuildVu](https://www.idrsolutions.com/buildvu/) as an online service.
8
+
9
+ IDR Solutions offer a free trial service for running BuildVu with Ruby,
10
+ more infomation on this can be found [here.](https://www.idrsolutions.com/buildvu/convert-pdf-in-ruby/)
11
+
12
+ -----
13
+
14
+ # Usage #
15
+
16
+ ## Basic: (Upload) #
17
+
18
+ ```ruby
19
+ require idr_cloud_client
20
+ client = IDRCloudClient.new('http://localhost:80/' + IDRCloudClient::BUILDVU)
21
+
22
+ # Convert the file with the input method specified
23
+ results = client.convert(input: IDRCloudClient::UPLOAD, file: 'path/to/file.pdf')
24
+
25
+ # Return a URL where you can view the converted output.
26
+ puts results['downloadUrl']
27
+
28
+ # Download the converted output to a specified directory:
29
+ client.download_result(results, 'path/to/output/dir')
30
+ ```
31
+
32
+ ## Basic: (Download) #
33
+ ```ruby
34
+ require idr_cloud_client
35
+ client = IDRCloudClient.new('http://localhost:80/' + IDRCloudClient::BUILDVU)
36
+
37
+ # Convert the file with the input method specified
38
+ results = client.convert(input: IDRCloudClient::DOWNLOAD, url: 'http://link.to/filename')
39
+
40
+ # Return a URL where you can view the converted output.
41
+ puts results['downloadUrl']
42
+
43
+ # Download the converted output to a specified directory:
44
+ client.download_result(results, 'path/to/output/dir')
45
+ ```
46
+
47
+ The parameters object should contain the parameters that are sent to the API
48
+ See the [API](https://github.com/idrsolutions/buildvu-microservice-example/blob/master/API.md) for more details.
49
+
50
+ See `exampleBuildVuUsage.rb` for examples.
51
+
52
+ -----
53
+
54
+ # Who do I talk to? #
55
+
56
+ Found a bug, or have a suggestion / improvement? Let us know through the Issues page.
57
+
58
+ Got questions? You can contact us [here](https://idrsolutions.zendesk.com/hc/en-us/requests/new).
59
+
60
+ -----
61
+
62
+ # Code of Conduct #
63
+
64
+ Short version: Don't be an awful person.
65
+
66
+ Longer version: Everyone interacting in the BuildVu Ruby Client project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
67
+
68
+ -----
69
+
70
+ Copyright 2020 IDRsolutions
71
+
72
+ Licensed under the Apache License, Version 2.0 (the "License");
73
+ you may not use this file except in compliance with the License.
74
+ You may obtain a copy of the License at
75
+
76
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
77
+
78
+ Unless required by applicable law or agreed to in writing, software
79
+ distributed under the License is distributed on an "AS IS" BASIS,
80
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
81
+ See the License for the specific language governing permissions and
82
+ limitations under the License.
@@ -0,0 +1,82 @@
1
+ # IDRSolutions Ruby Client for JPedal #
2
+
3
+ Convert PDF to Images with Ruby, using the IDRSolutions Ruby Client to
4
+ interact with IDRsolutions' [JPedal Microservice Example](https://github.com/idrsolutions/jpedal-microservice-example).
5
+
6
+ The JPedal Microservice Example is an open source project that allows you to
7
+ convert PDF to Images by running [JPedal](https://www.idrsolutions.com/jpedal/) as an online service.
8
+
9
+ IDR Solutions offer a free trial service for running JPedal with Ruby,
10
+ more information on this can be found [here.](https://www.idrsolutions.com/jpedal/convert-pdf-in-ruby)
11
+
12
+ -----
13
+
14
+ # Usage #
15
+
16
+ ## Basic: (Upload) #
17
+
18
+ ```Ruby
19
+ require idr_cloud_client
20
+ client = IDRCloudClient.new('http://localhost:80/' + IDRCloudClient::JPEDAL)
21
+
22
+ # Convert the file with the input method specified
23
+ results = client.convert(input: IDRCloudClient::UPLOAD, file: 'path/to/file.pdf')
24
+
25
+ # Return a URL where you can view the converted output.
26
+ puts results['downloadUrl']
27
+
28
+ # Download the converted output to a specified directory:
29
+ client.download_result(results, 'path/to/output/dir')
30
+ ```
31
+
32
+ ## Basic: (Download) #
33
+ ```Ruby
34
+ require idr_cloud_client
35
+ client = IDRCloudClient.new('http://localhost:80/' + IDRCloudClient::JPEDAL)
36
+
37
+ # Convert the file with the input method specified
38
+ results = client.convert(input: IDRCloudClient::DOWNLOAD, url: 'http://link.to/filename')
39
+
40
+ # Return a URL where you can view the converted output.
41
+ puts results['downloadUrl']
42
+
43
+ # Download the converted output to a specified directory:
44
+ client.download_result(results, 'path/to/output/dir')
45
+ ```
46
+
47
+ The parameters object should contain the parameters that are sent to the API
48
+ See the [API](https://github.com/idrsolutions/jpedal-microservice-example/blob/master/API.md) for more details.
49
+
50
+ See `example_jpedal_usage.rb` for examples.
51
+
52
+ -----
53
+
54
+ # Who do I talk to? #
55
+
56
+ Found a bug, or have a suggestion / improvement? Let us know through the Issues page.
57
+
58
+ Got questions? You can contact us [here](https://idrsolutions.zendesk.com/hc/en-us/requests/new).
59
+
60
+ -----
61
+
62
+ # Code of Conduct #
63
+
64
+ Short version: Don't be an awful person.
65
+
66
+ Longer version: Everyone interacting in the JPedal Ruby Client project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
67
+
68
+ -----
69
+
70
+ Copyright 2020 IDRsolutions
71
+
72
+ Licensed under the Apache License, Version 2.0 (the "License");
73
+ you may not use this file except in compliance with the License.
74
+ You may obtain a copy of the License at
75
+
76
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
77
+
78
+ Unless required by applicable law or agreed to in writing, software
79
+ distributed under the License is distributed on an "AS IS" BASIS,
80
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
81
+ See the License for the specific language governing permissions and
82
+ limitations under the License.
@@ -0,0 +1,80 @@
1
+ # IDRSolutions Ruby Client #
2
+
3
+ Interact with any [IDRsolutions' Microservice Examples](https://github.com/idrsolutions/) using the IDRSolutions Ruby Client.
4
+
5
+ The BuildVu Microservice Example is an open source project that allows you to convert PDFs using various softwares from [IDRSolutions](https://www.idrsolutions.com) as an online service.
6
+
7
+ IDRsolutions offer a free trial service for running these libraries with Ruby. You can find information at the following links for [JPedal](https://www.idrsolutions.com/jpedal/) and [BuildVU](https://www.idrsolutions.com/buildvu/).
8
+
9
+ -----
10
+
11
+ # Installation #
12
+
13
+ ## Using RubyGems: ##
14
+
15
+ Run the following command to install
16
+
17
+ $ gem install idr_cloud_client
18
+
19
+ Alternatively, add this line to your application's Gemfile...
20
+
21
+ ```ruby
22
+ gem 'idr_cloud_client'
23
+ ```
24
+
25
+ ...and then execute:
26
+
27
+ $ bundle install
28
+
29
+ ## Building the gem manually: ##
30
+
31
+ Run the following command to build the gem locally:
32
+
33
+ $ gem build idr_cloud_client.gemspec
34
+
35
+ You can then install it using:
36
+
37
+ $ gem install idr_cloud_client
38
+
39
+ -----
40
+
41
+ # Usage #
42
+
43
+ ## BuildVu: ##
44
+
45
+ Full usage for connecting to BuildVu can be found [here](README-BUILDVU.md).
46
+
47
+ ## JPedal: ##
48
+
49
+ Full usage for connecting to JPedal can be found [here](README-JPEDAL.md).
50
+
51
+ -----
52
+
53
+ # Who do I talk to? #
54
+
55
+ Found a bug, or have a suggestion / improvement? Let us know through the Issues page.
56
+
57
+ Got questions? You can contact us [here](https://idrsolutions.zendesk.com/hc/en-us/requests/new).
58
+
59
+ -----
60
+
61
+ # Code of Conduct #
62
+
63
+ Short version: Don't be an awful person.
64
+
65
+ Longer version: Everyone interacting in the BuildVu Ruby Client project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
66
+
67
+ -----
68
+ Copyright 2020 IDRsolutions
69
+
70
+ Licensed under the Apache License, Version 2.0 (the "License");
71
+ you may not use this file except in compliance with the License.
72
+ You may obtain a copy of the License at
73
+
74
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
75
+
76
+ Unless required by applicable law or agreed to in writing, software
77
+ distributed under the License is distributed on an "AS IS" BASIS,
78
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
79
+ See the License for the specific language governing permissions and
80
+ limitations under the License.
@@ -0,0 +1,23 @@
1
+ require 'idr_cloud_client'
2
+
3
+ client = IDRCloudClient.new('http://localhost:80/' + IDRCloudClient::BUILDVU)
4
+
5
+ # Upload a local file to the BuildVu microservice
6
+ # convert() returns a hash collection with the conversion results.
7
+ conversion_results = client.convert(input: IDRCloudClient::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 = client.convert input: IDRCloudClient::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 = client.convert url: 'http://link.to/filename', input: IDRCloudClient::DOWNLOAD
17
+
18
+ output_url = conversion_results['downloadUrl']
19
+
20
+ # After the conversion you can also specify a directory to download the output to:
21
+ #client.download_result conversion_results, 'path/to/output/dir'
22
+
23
+ puts 'Converted: ' + output_url
@@ -0,0 +1,23 @@
1
+ require 'idr_cloud_client'
2
+
3
+ client = IDRCloudClient.new('http://localhost:80/' + IDRCloudClient::JPEDAL)
4
+
5
+ # Upload a local file to the JPedal microservice
6
+ # convert() returns a hash collection with the conversion results.
7
+ conversion_results = client.convert(input: IDRCloudClient::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/jpedal-microservice-example/blob/master/API.md
13
+ #conversion_results = client.convert input: IDRCloudClient::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 = client.convert url: 'http://link.to/filename', input: IDRCloudClient::DOWNLOAD
17
+
18
+ output_url = conversion_results['downloadUrl']
19
+
20
+ # After the conversion you can also specify a directory to download the output to:
21
+ #client.download_result conversion_results, 'path/to/output/dir'
22
+
23
+ puts 'Converted: ' + output_url
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'idr_cloud_client/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'idr_cloud_client'
7
+ spec.version = IDRCloudClient::VERSION
8
+ spec.authors = ['IDRsolutions']
9
+ spec.email = ['support@idrsolutions.zendesk.com']
10
+ spec.date = Time.now.strftime('%Y-%m-%d')
11
+
12
+ spec.summary = 'Ruby API for IDRSolutions Microservices'
13
+ spec.description = "Convert PDF to HTML5, SVG, or image with Ruby, using the IDR Cloud Client to interact with
14
+ IDRsolutions' BuildVu Microservice Example. The Microservice Example is an open source
15
+ project that allows you to convert PDF to HTML5, SVG, or image by running BuildVu or JPedal as a web service in the cloud or on-premise. For documentation and usage examples, check out our GitHub page. "
16
+ spec.homepage = 'https://github.com/idrsolutions/idrsolutions-ruby-client'
17
+ spec.license = 'Apache-2.0'
18
+
19
+ spec.required_ruby_version = '>= 2.3.0'
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.add_runtime_dependency 'faraday', '~> 0.17'
29
+ spec.add_runtime_dependency 'json', '~> 2.1', '>= 2.1'
30
+ end
@@ -0,0 +1,171 @@
1
+ #--
2
+ # Copyright 2018 IDRsolutions
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ #
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+ #
18
+ # Author:: IDRsolutions (mailto:support@idrsolutions.zendesk.com)
19
+ # Copyright:: IDRsolutions
20
+ # License:: Apache 2.0
21
+
22
+ require 'json'
23
+ require 'Faraday'
24
+
25
+
26
+ # Used to interact with IDRsolutions' web services
27
+ # For detailed usage instructions, see GitHub[https://github.com/idrsolutions/IDRSolutions-Ruby-Client]
28
+ class IDRCloudClient
29
+
30
+ DOWNLOAD = 'download'
31
+ UPLOAD = 'upload'
32
+ JPEDAL = 'jpedal'
33
+ BUILDVU = 'buildvu'
34
+
35
+ @base_endpoint = nil
36
+ @endpoint = nil
37
+ @convert_timeout = nil
38
+ @auth = nil
39
+
40
+ # Constructor, setup the converter details
41
+ # Params:
42
+ # +url+:: string, the URL of the web service.
43
+ # +conversion_timeout+:: int, (optional) the time to wait (in seconds) before timing out. Set to 30 by default.
44
+ # +auth+:: array, (optional) the username and password to use for HTTP Authentication. Set to nil by default
45
+ def initialize(url, conversion_timeout: 30, auth: nil)
46
+ @base_endpoint = url
47
+ @endpoint = @base_endpoint
48
+ @convert_timeout = conversion_timeout
49
+ @auth = auth
50
+ end
51
+
52
+ # Converts the given file and returns a hash collection with the conversion results. Requires the 'input' and either 'url' or
53
+ # 'file' parameters to run. You can then use the values from the hash, or use methods like download_result().
54
+ # Params:
55
+ # +input+:: string, the method of inputting a file. Examples are IDRCloudClient::UPLOAD or IDRCloudClient::DOWNLOAD
56
+ # +file+:: string, (optional) Location of the PDF to convert, i.e 'path/to/input.pdf'
57
+ # +url+:: string, (optional) the url for the server to download a PDF from
58
+ #
59
+ # Returns: hash [string: string], The results of the conversion
60
+ def convert(**params)
61
+ uuid = upload params
62
+
63
+ response = nil
64
+ # check conversion status once every second until complete or error / timeout
65
+ (0..@convert_timeout).each do |i|
66
+ sleep 1
67
+ response = poll_status uuid
68
+
69
+ break if response['state'] == 'processed'
70
+
71
+ break unless params[:callbackUrl].nil?
72
+
73
+ if response['state'] == 'error'
74
+ exMessage = "Failed: Error with conversion\n"
75
+ response.each do | key, val |
76
+ exMessage = exMessage + "#{key}: $#{val}\n" if key != 'state'
77
+ end
78
+ raise(exMessage)
79
+ end
80
+
81
+ raise('Failed: File took longer than ' + @convert_timeout.to_s + ' seconds to convert') if i == @convert_timeout
82
+ end
83
+
84
+ response
85
+ end
86
+
87
+ # Downloads the zip file produced by the microservice. Provide '.' as the output_file_path if you wish to use the
88
+ # current directory. Will use the filename of the zip on the server if none is specified.
89
+ # Params:
90
+ # +output_file_path+:: string, the output location to save the zip file
91
+ # +file_name+:: string, (optional) the custom name for the zip file. This should not include .zip
92
+ def download_result(results, output_file_path, file_name=nil)
93
+ download_url = results['downloadUrl']
94
+
95
+ raise('Error: downloadUrl parameter is empty') if download_url.nil?
96
+
97
+ if file_name.nil?
98
+ output_file_path += '/' + download_url.split('/').last
99
+ else
100
+ output_file_path += '/' + file_name + '.zip'
101
+ end
102
+
103
+ download download_url, output_file_path
104
+ end
105
+
106
+ private
107
+
108
+ # Upload file at given path to converter, return UUID if successful
109
+ def upload(params)
110
+
111
+ file_path = params.delete(:file)
112
+ params[:file] = Faraday::UploadIO.new(file_path, 'application/pdf') if !file_path.nil?
113
+
114
+ uri = URI(@endpoint)
115
+ host = uri.scheme + "://" + uri.host + ':' + uri.port.to_s;
116
+
117
+ begin
118
+ conn = Faraday.new(host) do |f|
119
+ f.request :multipart
120
+ f.request :url_encoded
121
+ f.adapter Faraday.default_adapter
122
+ f.basic_auth @auth[:login], @auth[:pass] unless @auth.nil?
123
+ end
124
+
125
+ r = conn.post(uri.path, params)
126
+
127
+ rescue StandardError => e
128
+ raise("Error sending url:\n" + e.to_s)
129
+ end
130
+
131
+ raise "Error uploading file:\n Server returned 401 - Unauthorized" if r.status == 401
132
+ 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'])
133
+
134
+ uuid.nil? ? raise("Error uploading file:\nServer returned null UUID") : uuid
135
+ end
136
+
137
+ # Check conversion status
138
+ def poll_status(uuid)
139
+ uri = URI(@endpoint)
140
+ host = uri.scheme + "://" + uri.host + ':' + uri.port.to_s;
141
+
142
+ begin
143
+ conn = Faraday.new(host) do |req|
144
+ req.params['uuid'] = uuid
145
+ req.request :url_encoded
146
+ req.adapter Faraday.default_adapter
147
+ req.basic_auth @auth[:login], @auth[:pass] unless @auth.nil?
148
+ end
149
+ r = conn.get(uri.path)
150
+ rescue StandardError => e
151
+ raise("Error checking conversion status:\n" + e.to_s)
152
+ end
153
+
154
+ 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'])
155
+
156
+ response
157
+ end
158
+
159
+ # Download converted output to the given location
160
+ def download(download_url, output_file_path)
161
+ conn = Faraday.new download_url do |req|
162
+ req.adapter Faraday.default_adapter
163
+ req.basic_auth @auth[:login], @auth[:pass] unless @auth.nil?
164
+ end
165
+ response = conn.get(download_url)
166
+ File.open(output_file_path, 'wb') { |fp| fp.write(response.body) }
167
+
168
+ rescue StandardError => e
169
+ raise('Error downloading conversion output: ' + e.to_s)
170
+ end
171
+ end
@@ -0,0 +1,3 @@
1
+ class IDRCloudClient
2
+ VERSION = "1.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: idr_cloud_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - IDRsolutions
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-07-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.17'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.1'
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '2.1'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '2.1'
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.1'
47
+ description: "Convert PDF to HTML5, SVG, or image with Ruby, using the IDR Cloud Client
48
+ to interact with\n IDRsolutions' BuildVu Microservice Example.
49
+ The Microservice Example is an open source\n project that
50
+ allows you to convert PDF to HTML5, SVG, or image by running BuildVu or JPedal as
51
+ a web service in the cloud or on-premise. For documentation and usage examples,
52
+ check out our GitHub page. "
53
+ email:
54
+ - support@idrsolutions.zendesk.com
55
+ executables: []
56
+ extensions: []
57
+ extra_rdoc_files: []
58
+ files:
59
+ - ".gitattributes"
60
+ - ".gitignore"
61
+ - CODE_OF_CONDUCT.md
62
+ - Gemfile
63
+ - LICENSE.txt
64
+ - README-BUILDVU.md
65
+ - README-JPEDAL.md
66
+ - README.md
67
+ - example_buildvu_usage.rb
68
+ - example_jpedal_usage.rb
69
+ - idr_cloud_client.gemspec
70
+ - lib/idr_cloud_client.rb
71
+ - lib/idr_cloud_client/version.rb
72
+ homepage: https://github.com/idrsolutions/idrsolutions-ruby-client
73
+ licenses:
74
+ - Apache-2.0
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 2.3.0
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 3.0.3
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Ruby API for IDRSolutions Microservices
95
+ test_files: []