convert_api 1.2.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +26 -0
- data/.ruby-version +1 -1
- data/README.md +18 -5
- data/convert_api.gemspec +2 -2
- data/lib/convert_api/client.rb +3 -3
- data/lib/convert_api/configuration.rb +2 -3
- data/lib/convert_api/format_detector.rb +11 -4
- data/lib/convert_api/result_file.rb +1 -1
- data/lib/convert_api/task.rb +4 -4
- data/lib/convert_api/version.rb +2 -2
- metadata +12 -13
- data/.travis.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a32b7ed931b291534f117094b1e4ae376bd85435bdd4da624f491db402a873c8
|
4
|
+
data.tar.gz: 3da43e3aefecb611eece8f304dcba9a2392bfa290654244d057d0454258b1dff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb00e76bf1cb9ff0635b25be1d105048d300a15846b2c2672e523e6fcf3ce8b3d97cac3e6ef184ef044b26d51176b35e42618fec788c9f3bcb479efe18e0faff
|
7
|
+
data.tar.gz: 1893489362ed8dad54b8e9909f4435e687878e9fb03ecb84aebc46f9e728f1eac06a1dbc999332a95e3b6173c21f4e45bfa58517294060c1162be29edc317738
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Build
|
2
|
+
on: [push,pull_request]
|
3
|
+
jobs:
|
4
|
+
build:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
strategy:
|
7
|
+
matrix:
|
8
|
+
ruby-version:
|
9
|
+
- 2.0
|
10
|
+
- 2.6
|
11
|
+
- 2.7
|
12
|
+
- 3.0
|
13
|
+
- ruby-head
|
14
|
+
- jruby-9.1
|
15
|
+
- jruby-head
|
16
|
+
name: Ruby ${{ matrix.ruby-version }} sample
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v3
|
19
|
+
- uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby-version }}
|
22
|
+
# bundler-cache: true
|
23
|
+
- run: bundle install
|
24
|
+
- env:
|
25
|
+
CONVERT_API_SECRET: ${{ secrets.CONVERTAPI_SECRET }}
|
26
|
+
run: bundle exec rake spec
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3
|
1
|
+
2.6.3
|
data/README.md
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
[![Gem](https://img.shields.io/gem/v/convert_api.svg)](https://rubygems.org/gems/convert_api)
|
5
|
-
[![Build Status](https://
|
5
|
+
[![Build Status](https://github.com/ConvertAPI/convertapi-ruby/actions/workflows/main.yml/badge.svg)](https://github.com/ConvertAPI/convertapi-ruby/actions)
|
6
|
+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
|
7
|
+
|
6
8
|
|
7
9
|
## Convert your files with our online file conversion API
|
8
10
|
|
9
|
-
|
11
|
+
ConvertAPI helps in converting various file formats. Creating PDF and Images from various sources like Word, Excel, Powerpoint, images, web pages or raw HTML codes. Merge, Encrypt, Split, Repair and Decrypt PDF files and many other file manipulations. You can integrate it into your application in just a few minutes and use it easily.
|
10
12
|
|
11
13
|
|
12
14
|
## Installation
|
@@ -32,7 +34,7 @@ end
|
|
32
34
|
### File conversion
|
33
35
|
|
34
36
|
Example to convert file to PDF. All supported formats and options can be found
|
35
|
-
[here](https://www.convertapi.com).
|
37
|
+
[here](https://www.convertapi.com/doc/supported-formats).
|
36
38
|
|
37
39
|
```ruby
|
38
40
|
result = ConvertApi.convert('pdf', File: '/path/to/my_file.docx')
|
@@ -84,9 +86,20 @@ result = ConvertApi.convert(
|
|
84
86
|
)
|
85
87
|
```
|
86
88
|
|
89
|
+
#### Accessing result file properties
|
90
|
+
|
91
|
+
You can access result file collection like this:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
result = ConvertApi.convert('pdf', File: 'https://website/my_file.docx')
|
95
|
+
|
96
|
+
puts result.files[0].url
|
97
|
+
puts result.files[0].size
|
98
|
+
```
|
99
|
+
|
87
100
|
### User information
|
88
101
|
|
89
|
-
You can always check remaining seconds
|
102
|
+
You can always check your remaining seconds programmatically by fetching [user information](https://www.convertapi.com/doc/user).
|
90
103
|
|
91
104
|
```ruby
|
92
105
|
user_info = ConvertApi.user
|
@@ -96,7 +109,7 @@ puts user_info['SecondsLeft']
|
|
96
109
|
|
97
110
|
### More examples
|
98
111
|
|
99
|
-
|
112
|
+
Find more advanced examples in the [examples/](https://github.com/ConvertAPI/convertapi-ruby/tree/master/examples) folder.
|
100
113
|
|
101
114
|
|
102
115
|
## Development
|
data/convert_api.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.add_development_dependency 'bundler'
|
25
|
-
spec.add_development_dependency 'rake', '
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
26
26
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
27
|
end
|
data/lib/convert_api/client.rb
CHANGED
@@ -48,7 +48,7 @@ module ConvertApi
|
|
48
48
|
def upload(io, filename)
|
49
49
|
handle_response do
|
50
50
|
request_uri = base_uri.path + 'upload'
|
51
|
-
encoded_filename =
|
51
|
+
encoded_filename = CGI.escape(filename)
|
52
52
|
|
53
53
|
headers = DEFAULT_HEADERS.merge(
|
54
54
|
'Content-Type' => 'application/octet-stream',
|
@@ -91,10 +91,10 @@ module ConvertApi
|
|
91
91
|
raise(TimeoutError, e)
|
92
92
|
end
|
93
93
|
|
94
|
-
def http(
|
94
|
+
def http(options = {})
|
95
95
|
http = Net::HTTP.new(base_uri.host, base_uri.port)
|
96
96
|
http.open_timeout = config.connect_timeout
|
97
|
-
http.read_timeout = read_timeout
|
97
|
+
http.read_timeout = options.fetch(:read_timeout, config.read_timeout)
|
98
98
|
http.use_ssl = base_uri.scheme == 'https'
|
99
99
|
# http.set_debug_output $stderr
|
100
100
|
http
|
@@ -13,10 +13,9 @@ module ConvertApi
|
|
13
13
|
@base_uri = URI('https://v2.convertapi.com/')
|
14
14
|
@connect_timeout = 5
|
15
15
|
@read_timeout = 60
|
16
|
-
@conversion_timeout = 180
|
17
16
|
@conversion_timeout_delta = 10
|
18
|
-
@upload_timeout =
|
19
|
-
@download_timeout =
|
17
|
+
@upload_timeout = 1800
|
18
|
+
@download_timeout = 1800
|
20
19
|
end
|
21
20
|
end
|
22
21
|
end
|
@@ -1,21 +1,28 @@
|
|
1
1
|
module ConvertApi
|
2
2
|
class FormatDetector
|
3
|
-
|
3
|
+
ANY_FORMAT = 'any'
|
4
|
+
|
5
|
+
def initialize(resource, to_format)
|
4
6
|
@resource = resource
|
7
|
+
@to_format = to_format
|
5
8
|
end
|
6
9
|
|
7
10
|
def run
|
11
|
+
return ANY_FORMAT if archive?
|
8
12
|
return @resource.file_ext.downcase if @resource.is_a?(UploadIO)
|
9
13
|
|
10
|
-
format_from_path
|
14
|
+
format_from_path || raise(FormatError, 'Unable to detect format')
|
11
15
|
end
|
12
16
|
|
13
17
|
private
|
14
18
|
|
19
|
+
def archive?
|
20
|
+
@to_format.to_s.downcase == 'zip'
|
21
|
+
end
|
22
|
+
|
15
23
|
def format_from_path
|
16
24
|
extension = File.extname(path).downcase
|
17
|
-
|
18
|
-
format || raise(FormatError, 'Unable to detect format')
|
25
|
+
extension[1..-1]
|
19
26
|
end
|
20
27
|
|
21
28
|
def path
|
data/lib/convert_api/task.rb
CHANGED
@@ -14,13 +14,13 @@ module ConvertApi
|
|
14
14
|
)
|
15
15
|
|
16
16
|
from_format = @from_format || detect_format(params)
|
17
|
-
read_timeout = @conversion_timeout + config.conversion_timeout_delta
|
17
|
+
read_timeout = @conversion_timeout + config.conversion_timeout_delta if @conversion_timeout
|
18
18
|
converter = params[:converter] ? "/converter/#{params[:converter]}" : ''
|
19
19
|
|
20
20
|
response = ConvertApi.client.post(
|
21
21
|
"convert/#{from_format}/to/#{@to_format}#{converter}",
|
22
22
|
params,
|
23
|
-
read_timeout: read_timeout
|
23
|
+
read_timeout: read_timeout,
|
24
24
|
)
|
25
25
|
|
26
26
|
Result.new(response)
|
@@ -66,11 +66,11 @@ module ConvertApi
|
|
66
66
|
|
67
67
|
resource = params[:File] || Array(params[:Files]).first
|
68
68
|
|
69
|
-
FormatDetector.new(resource).run
|
69
|
+
FormatDetector.new(resource, @to_format).run
|
70
70
|
end
|
71
71
|
|
72
72
|
def config
|
73
73
|
ConvertApi.config
|
74
74
|
end
|
75
75
|
end
|
76
|
-
end
|
76
|
+
end
|
data/lib/convert_api/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module ConvertApi
|
2
|
-
VERSION = '1.
|
3
|
-
end
|
2
|
+
VERSION = '1.3.1'
|
3
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convert_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Rutkauskas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 12.3.3
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 12.3.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,10 +62,10 @@ executables: []
|
|
62
62
|
extensions: []
|
63
63
|
extra_rdoc_files: []
|
64
64
|
files:
|
65
|
+
- ".github/workflows/main.yml"
|
65
66
|
- ".gitignore"
|
66
67
|
- ".rspec"
|
67
68
|
- ".ruby-version"
|
68
|
-
- ".travis.yml"
|
69
69
|
- Gemfile
|
70
70
|
- LICENSE.txt
|
71
71
|
- README.md
|
@@ -101,8 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
|
105
|
-
rubygems_version: 2.7.7
|
104
|
+
rubygems_version: 3.0.3
|
106
105
|
signing_key:
|
107
106
|
specification_version: 4
|
108
107
|
summary: ConvertAPI client library
|
data/.travis.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.1.0
|
5
|
-
- 2.2.0
|
6
|
-
- 2.3.0
|
7
|
-
- 2.4.1
|
8
|
-
- 2.5.1
|
9
|
-
- ruby-head
|
10
|
-
- ruby-head-clang
|
11
|
-
- jruby-head
|
12
|
-
bundler_args: --jobs=3 --retry=3 --binstubs
|
13
|
-
env:
|
14
|
-
global:
|
15
|
-
secure: Pri+nCT6ayGYkjGO/WfMGkqk4DBKseJjQuWHWdft9YH2G+5dc7UKypDqmlfZvqwLPw2kybepKfh/utRGYsL5nfbET+3Ml8+2Bgaf0IT4Ej/3B5KIdFbivHmRp/NP/Dgh64M+5u1wKEEnw1NIMHwcanQDzPUDtaxqsw1xwowUL5Axr+UnJtWL2bP/RCED2JEgwhBQBFSMBXXwpSK2yFT7X1pInPWX2S0hELxj1UDefLDjp6kEnkrU/u+FjC9RhmYhusx2muXC4pHiqdNL0fDZStgginAQAd92FsMHQyzwewefCGRAg0g25ZmSGx5cHL4BZORdUnxaG9+AS9Wt17tZI2WS9eUBc9yyRU+R76aSo79uJj4RKi1Ljd3+4fyI/9BDz9a2koEgeDbYUHHf0dYaFSLXcOpnLBBPtr0qD02SUP1EcYTOe1/sNMweDLfN67E70YV69+ZqQeb+xgCbAeeoTOGJ9uKR2c91wSZwDjpTXXSLrNeNw98FPRyWxpfRRFQV29ZDPx/cfHt9gAVQVnd+ZBCAFwr353nqE8Ux1wtrxkexPkT8G+TXIgTvvYDfu2WmaO7qrZR2D6427jc4sgndwWfSPgiLw4eW1u3hCyaCnPBsviugtj1sTs2NfnLPdgtSUcKBd4xNbbVQoqZM1qTL139HvpZFB+jD8uoVtgWigUA=
|