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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0c19d784a48c22fedfcb2f00b4d150cc638b99b4688bae2d6f5bb13e28af08d
4
- data.tar.gz: 775a9a90934f9447acde26c05a004f9106541603b6a2fb3fcb458dbb426cca98
3
+ metadata.gz: 9000b9daea1645e115548fbbb17edcdbcb52cdd179fda838ea40f17df85f4adc
4
+ data.tar.gz: 8d43ea9df0273824b2f90489e0c3f6a74403045f627161dfdc11958dbea14800
5
5
  SHA512:
6
- metadata.gz: c15b8d712d8ce29cb11ad915d11676b1ff13f064c3df3655611f085f958c8ca9502352300b940bffea2ce2ccfc5f64bfc177f6b7a70262e5c43236b3f02a3b10
7
- data.tar.gz: 24ad1374796432ed6a3e332676b3421e183a9224b70bea09fe2bd1c2dfa0eea86fc6c9f1ca496a0ec2a134fcb5b6fed9ead4a2edf10b1b5aee2e1342c19110ee
6
+ metadata.gz: cff4a0ba9aa76cfaf50c03403b8c8376665d4bcb3c5490ab0fbf5fbbac9f88523241d383e834b9e01246be5e0a05b4cf473b8c6bcbd2196e5afdd5fd4780625c
7
+ data.tar.gz: 0430d681bd169f0765166b4009697488c5ba585023f64c6f83ec8bfc84177519b52319230aba6f13a8cfe52ac954cfd9ac2e17c1105a88a5009f19f355b11ece
@@ -9,8 +9,8 @@ jobs:
9
9
  - 2.0
10
10
  - 2.6
11
11
  - 2.7
12
- - 3.0
13
- - ruby-head
12
+ - 3.1
13
+ - 3.2
14
14
  - jruby-9.1
15
15
  - jruby-head
16
16
  name: Ruby ${{ matrix.ruby-version }} sample
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
- { File: /path/to/my_file' },
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.
@@ -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[:converter] ? "/converter/#{params[:converter]}" : ''
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}#{converter}",
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 key
36
- when :File
37
- result[:File] = FileParam.build(value)
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
@@ -1,3 +1,3 @@
1
1
  module ConvertApi
2
- VERSION = '1.3.2'
2
+ VERSION = '1.4.0'
3
3
  end
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.3.2
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: 2022-09-18 00:00:00.000000000 Z
11
+ date: 2023-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler