convert_api 1.3.2 → 1.4.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 +4 -4
- data/.github/workflows/main.yml +2 -2
- data/README.md +18 -7
- data/lib/convert_api/task.rb +15 -6
- data/lib/convert_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9000b9daea1645e115548fbbb17edcdbcb52cdd179fda838ea40f17df85f4adc
|
4
|
+
data.tar.gz: 8d43ea9df0273824b2f90489e0c3f6a74403045f627161dfdc11958dbea14800
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cff4a0ba9aa76cfaf50c03403b8c8376665d4bcb3c5490ab0fbf5fbbac9f88523241d383e834b9e01246be5e0a05b4cf473b8c6bcbd2196e5afdd5fd4780625c
|
7
|
+
data.tar.gz: 0430d681bd169f0765166b4009697488c5ba585023f64c6f83ec8bfc84177519b52319230aba6f13a8cfe52ac954cfd9ac2e17c1105a88a5009f19f355b11ece
|
data/.github/workflows/main.yml
CHANGED
data/README.md
CHANGED
@@ -37,7 +37,7 @@ Example to convert file to PDF. All supported formats and options can be found
|
|
37
37
|
[here](https://www.convertapi.com/doc/supported-formats).
|
38
38
|
|
39
39
|
```ruby
|
40
|
-
result = ConvertApi.convert('pdf', File: '/path/to/my_file.docx')
|
40
|
+
result = ConvertApi.convert('pdf', { File: '/path/to/my_file.docx' })
|
41
41
|
|
42
42
|
# save to file
|
43
43
|
result.file.save('/path/to/save/file.pdf')
|
@@ -59,7 +59,7 @@ conversion_cost = result.conversion_cost
|
|
59
59
|
#### Convert file url
|
60
60
|
|
61
61
|
```ruby
|
62
|
-
result = ConvertApi.convert('pdf', File: 'https://website/my_file.docx')
|
62
|
+
result = ConvertApi.convert('pdf', { File: 'https://website/my_file.docx' })
|
63
63
|
```
|
64
64
|
|
65
65
|
#### Specifying from format
|
@@ -67,7 +67,7 @@ result = ConvertApi.convert('pdf', File: 'https://website/my_file.docx')
|
|
67
67
|
```ruby
|
68
68
|
result = ConvertApi.convert(
|
69
69
|
'pdf',
|
70
|
-
{
|
70
|
+
{File: /path/to/my_file'},
|
71
71
|
from_format: 'docx'
|
72
72
|
)
|
73
73
|
```
|
@@ -75,14 +75,14 @@ result = ConvertApi.convert(
|
|
75
75
|
#### Additional conversion parameters
|
76
76
|
|
77
77
|
ConvertAPI accepts extra conversion parameters depending on converted formats. All conversion
|
78
|
-
parameters and explanations can be found [here](https://www.convertapi.com).
|
78
|
+
parameters and explanations can be found [here](https://www.convertapi.com/doc/supported-formats).
|
79
79
|
|
80
80
|
```ruby
|
81
81
|
result = ConvertApi.convert(
|
82
82
|
'pdf',
|
83
|
-
File: /path/to/my_file.docx',
|
83
|
+
{File: /path/to/my_file.docx',
|
84
84
|
PageRange: '1-10',
|
85
|
-
PdfResolution: '150'
|
85
|
+
PdfResolution: '150'}
|
86
86
|
)
|
87
87
|
```
|
88
88
|
|
@@ -91,7 +91,7 @@ result = ConvertApi.convert(
|
|
91
91
|
You can access result file collection like this:
|
92
92
|
|
93
93
|
```ruby
|
94
|
-
result = ConvertApi.convert('pdf', File: 'https://website/my_file.docx')
|
94
|
+
result = ConvertApi.convert('pdf', { File: 'https://website/my_file.docx' })
|
95
95
|
|
96
96
|
puts result.files[0].url
|
97
97
|
puts result.files[0].size
|
@@ -107,6 +107,17 @@ user_info = ConvertApi.user
|
|
107
107
|
puts user_info['SecondsLeft']
|
108
108
|
```
|
109
109
|
|
110
|
+
### Alternative domain
|
111
|
+
|
112
|
+
Set config `base_uri` attribute to use other service domains. Dedicated to the region [domain list](https://www.convertapi.com/doc/servers-location).
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
ConvertApi.configure do |config|
|
116
|
+
config.base_uri = URI('https://eu-v2.convertapi.com/')
|
117
|
+
end
|
118
|
+
```
|
119
|
+
|
120
|
+
|
110
121
|
### More examples
|
111
122
|
|
112
123
|
Find more advanced examples in the [examples/](https://github.com/ConvertAPI/convertapi-ruby/tree/master/examples) folder.
|
data/lib/convert_api/task.rb
CHANGED
@@ -15,10 +15,11 @@ module ConvertApi
|
|
15
15
|
|
16
16
|
from_format = @from_format || detect_format(params)
|
17
17
|
read_timeout = @conversion_timeout + config.conversion_timeout_delta if @conversion_timeout
|
18
|
-
converter = params
|
18
|
+
converter = detect_converter(params)
|
19
|
+
converter_path = converter ? "/converter/#{converter}" : ''
|
19
20
|
|
20
21
|
response = ConvertApi.client.post(
|
21
|
-
"convert/#{from_format}/to/#{@to_format}#{
|
22
|
+
"convert/#{from_format}/to/#{@to_format}#{converter_path}",
|
22
23
|
params,
|
23
24
|
read_timeout: read_timeout,
|
24
25
|
)
|
@@ -32,10 +33,10 @@ module ConvertApi
|
|
32
33
|
result = {}
|
33
34
|
|
34
35
|
symbolize_keys(params).each do |key, value|
|
35
|
-
case
|
36
|
-
when :File
|
37
|
-
result[
|
38
|
-
when :Files
|
36
|
+
case
|
37
|
+
when key != :StoreFile && key.to_s.end_with?('File')
|
38
|
+
result[key] = FileParam.build(value)
|
39
|
+
when key == :Files
|
39
40
|
result[:Files] = files_batch(value)
|
40
41
|
else
|
41
42
|
result[key] = value
|
@@ -69,6 +70,14 @@ module ConvertApi
|
|
69
70
|
FormatDetector.new(resource, @to_format).run
|
70
71
|
end
|
71
72
|
|
73
|
+
def detect_converter(params)
|
74
|
+
params.each do |key, value|
|
75
|
+
return value if key.to_s.downcase == 'converter'
|
76
|
+
end
|
77
|
+
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
|
72
81
|
def config
|
73
82
|
ConvertApi.config
|
74
83
|
end
|
data/lib/convert_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convert_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
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: 2023-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|