convert_api 2.0.0 → 3.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 +4 -4
- data/CHANGELOG.md +40 -0
- data/README.md +11 -21
- data/lib/convert_api/client.rb +13 -13
- data/lib/convert_api/configuration.rb +1 -2
- data/lib/convert_api/task.rb +1 -11
- data/lib/convert_api/version.rb +1 -1
- data/lib/convert_api.rb +2 -1
- metadata +10 -16
- data/.github/workflows/main.yml +0 -28
- data/.github/workflows/publish.yml +0 -21
- data/.gitignore +0 -12
- data/.rspec +0 -2
- data/.ruby-version +0 -1
- data/Gemfile +0 -6
- data/Rakefile +0 -6
- data/convert_api.gemspec +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5fcd9fe8ad08c01b6cd0ca4e52208444ff3da05a10ebdf20eac4d6d8f443c94f
|
|
4
|
+
data.tar.gz: 9a4842f2843643892704f9ebfd134f98519c0a689a18fbfed0d7587b3e30330a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc25cd4c5fa5cd60d147d3831b7a9c24d012634681a6f1e6f5d1bb5b4095a91e56f49f30cfc890d940b5358a1e16cbd7712f05d8ccd8964eca5c5f15dd1c502b
|
|
7
|
+
data.tar.gz: afe7726d6c1e03bcc5e155c9abd593114a35857af0bc31de64dba8c0127f52449ed5368f494732202e9b77cf1d539ed1ade1c9fdcc25e98fc1578d4b5a9a71a2
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
|
|
6
|
+
|
|
7
|
+
## [3.0.1] — 2026-10-20
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- No more warnings on load on current Rubies: `URI.regexp is obsolete` (Ruby 3.4+) and "CGI library is
|
|
11
|
+
removed from Ruby 4.0" (Ruby 4.0). The library now uses the RFC 2396 URI parser directly and requires
|
|
12
|
+
only `cgi/escape`. Behaviour is unchanged.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- Tested on Ruby 3.2, 3.3, 3.4 and 4.0 (was 2.0–3.3 and JRuby). No Ruby version constraint was added: the
|
|
16
|
+
gem still installs on older Rubies, which are no longer tested.
|
|
17
|
+
- The gem contains only `lib/`, `README.md`, `LICENSE.txt` and `CHANGELOG.md` (it used to ship the
|
|
18
|
+
repository's dotfiles, `Gemfile`, `Rakefile` and workflow). Its RubyGems page links to the source,
|
|
19
|
+
changelog and issues.
|
|
20
|
+
- The specs that call ConvertAPI are tagged `live` and run only when `CONVERT_API_SECRET` is set.
|
|
21
|
+
- Releases are now cut from a GitHub Release `v{version}` and pushed with RubyGems Trusted Publishing. See
|
|
22
|
+
[RELEASING.md](RELEASING.md).
|
|
23
|
+
|
|
24
|
+
## [3.0.0] — 2024-09-14
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- Credentials are sent in the `Authorization` header and configured with `config.api_credentials` (an API
|
|
28
|
+
secret or token), which replaces `api_secret` and `token`.
|
|
29
|
+
|
|
30
|
+
### Removed
|
|
31
|
+
- Alternative converter support.
|
|
32
|
+
|
|
33
|
+
## [2.0.0] — 2024-08-04
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
- Token authentication.
|
|
37
|
+
|
|
38
|
+
[3.0.1]: https://github.com/ConvertAPI/convertapi-library-ruby/compare/v3.0.0...v3.0.1
|
|
39
|
+
[3.0.0]: https://github.com/ConvertAPI/convertapi-library-ruby/compare/v2.0.0...v3.0.0
|
|
40
|
+
[2.0.0]: https://github.com/ConvertAPI/convertapi-library-ruby/compare/v1.4.0...v2.0.0
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
[](https://rubygems.org/gems/convert_api)
|
|
5
|
-
[](https://github.com/ConvertAPI/convertapi-library-ruby/actions/workflows/build.yml)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
8
|
|
|
@@ -23,20 +23,11 @@ gem 'convert_api'
|
|
|
23
23
|
|
|
24
24
|
### Configuration
|
|
25
25
|
|
|
26
|
-
You can get your
|
|
26
|
+
You can get your credentials at [https://www.convertapi.com/a/authentication](https://www.convertapi.com/a/authentication)
|
|
27
27
|
|
|
28
28
|
```ruby
|
|
29
29
|
ConvertApi.configure do |config|
|
|
30
|
-
config.
|
|
31
|
-
end
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Or
|
|
35
|
-
|
|
36
|
-
You can get your token at https://www.convertapi.com/a/access-tokens
|
|
37
|
-
```ruby
|
|
38
|
-
ConvertApi.configure do |config|
|
|
39
|
-
config.token = 'your-token'
|
|
30
|
+
config.api_credentials = 'api-token'
|
|
40
31
|
end
|
|
41
32
|
```
|
|
42
33
|
|
|
@@ -108,7 +99,7 @@ puts result.files[0].size
|
|
|
108
99
|
|
|
109
100
|
### User information
|
|
110
101
|
|
|
111
|
-
You can always check your
|
|
102
|
+
You can always check your usage by fetching [user information](https://www.convertapi.com/doc/user).
|
|
112
103
|
|
|
113
104
|
```ruby
|
|
114
105
|
user_info = ConvertApi.user
|
|
@@ -129,22 +120,21 @@ end
|
|
|
129
120
|
|
|
130
121
|
### More examples
|
|
131
122
|
|
|
132
|
-
Find more advanced examples in the [examples/](https://github.com/ConvertAPI/convertapi-ruby/tree/
|
|
123
|
+
Find more advanced examples in the [examples/](https://github.com/ConvertAPI/convertapi-library-ruby/tree/main/examples) folder.
|
|
133
124
|
|
|
134
125
|
|
|
135
126
|
## Development
|
|
136
127
|
|
|
137
|
-
Run `
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
Run `CONVERT_API_TOKEN=your_token rake spec` to run the tests.
|
|
128
|
+
Run `bundle exec rake spec` to run the specs. Without an API token only the offline specs run; with
|
|
129
|
+
`CONVERT_API_SECRET=your_api_token bundle exec rake spec` the specs that call ConvertAPI run too
|
|
130
|
+
(set `CONVERT_API_BASE_URI` to test against another deployment).
|
|
142
131
|
|
|
143
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
132
|
+
To install this gem onto your local machine, run `bundle exec rake install`. Releases are published from
|
|
133
|
+
GitHub Releases only; see [RELEASING.md](RELEASING.md) and [CHANGELOG.md](CHANGELOG.md).
|
|
144
134
|
|
|
145
135
|
## Contributing
|
|
146
136
|
|
|
147
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/ConvertAPI/convertapi-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
137
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ConvertAPI/convertapi-library-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
148
138
|
|
|
149
139
|
## License
|
|
150
140
|
|
data/lib/convert_api/client.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'net/https'
|
|
2
2
|
require 'uri'
|
|
3
|
-
require 'cgi'
|
|
3
|
+
require 'cgi/escape'
|
|
4
4
|
require 'json'
|
|
5
5
|
|
|
6
6
|
module ConvertApi
|
|
@@ -30,7 +30,7 @@ module ConvertApi
|
|
|
30
30
|
|
|
31
31
|
def get(path, params = {}, options = {})
|
|
32
32
|
handle_response do
|
|
33
|
-
request = Net::HTTP::Get.new(request_uri(path, params),
|
|
33
|
+
request = Net::HTTP::Get.new(request_uri(path, params), headers_with_auth)
|
|
34
34
|
|
|
35
35
|
http(options).request(request)
|
|
36
36
|
end
|
|
@@ -38,7 +38,7 @@ module ConvertApi
|
|
|
38
38
|
|
|
39
39
|
def post(path, params, options = {})
|
|
40
40
|
handle_response do
|
|
41
|
-
request = Net::HTTP::Post.new(request_uri(path),
|
|
41
|
+
request = Net::HTTP::Post.new(request_uri(path), headers_with_auth)
|
|
42
42
|
request.form_data = build_form_data(params)
|
|
43
43
|
|
|
44
44
|
http(options).request(request)
|
|
@@ -101,12 +101,7 @@ module ConvertApi
|
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
def request_uri(path, params = {})
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
params_with_authentication = params.merge(authentication)
|
|
107
|
-
query = URI.encode_www_form(params_with_authentication)
|
|
108
|
-
|
|
109
|
-
base_uri.path + path + '?' + query
|
|
104
|
+
base_uri.path + path + '?' + URI.encode_www_form(params)
|
|
110
105
|
end
|
|
111
106
|
|
|
112
107
|
def build_form_data(params)
|
|
@@ -123,11 +118,16 @@ module ConvertApi
|
|
|
123
118
|
data
|
|
124
119
|
end
|
|
125
120
|
|
|
126
|
-
def
|
|
127
|
-
|
|
128
|
-
|
|
121
|
+
def headers_with_auth
|
|
122
|
+
DEFAULT_HEADERS.merge(auth_headers)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def auth_headers
|
|
126
|
+
{ 'Authorization' => "Bearer #{api_credentials}" }
|
|
127
|
+
end
|
|
129
128
|
|
|
130
|
-
|
|
129
|
+
def api_credentials
|
|
130
|
+
config.api_credentials || raise(AuthenticationError, 'API credentials not configured')
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
def base_uri
|
data/lib/convert_api/task.rb
CHANGED
|
@@ -15,11 +15,9 @@ 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 = detect_converter(params)
|
|
19
|
-
converter_path = converter ? "/converter/#{converter}" : ''
|
|
20
18
|
|
|
21
19
|
response = ConvertApi.client.post(
|
|
22
|
-
"convert/#{from_format}/to/#{@to_format}
|
|
20
|
+
"convert/#{from_format}/to/#{@to_format}",
|
|
23
21
|
params,
|
|
24
22
|
read_timeout: read_timeout,
|
|
25
23
|
)
|
|
@@ -70,14 +68,6 @@ module ConvertApi
|
|
|
70
68
|
FormatDetector.new(resource, @to_format).run
|
|
71
69
|
end
|
|
72
70
|
|
|
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
|
-
|
|
81
71
|
def config
|
|
82
72
|
ConvertApi.config
|
|
83
73
|
end
|
data/lib/convert_api/version.rb
CHANGED
data/lib/convert_api.rb
CHANGED
|
@@ -10,7 +10,8 @@ require 'convert_api/file_param'
|
|
|
10
10
|
require 'convert_api/format_detector'
|
|
11
11
|
|
|
12
12
|
module ConvertApi
|
|
13
|
-
|
|
13
|
+
# URI.regexp is obsolete since Ruby 3.4 and warns; the RFC 2396 parser is what it always used.
|
|
14
|
+
URI_REGEXP = (defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::DEFAULT_PARSER).make_regexp(%w(http https))
|
|
14
15
|
DEFAULT_URL_FORMAT = 'url'
|
|
15
16
|
|
|
16
17
|
module_function
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: convert_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tomas Rutkauskas
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: bundler
|
|
@@ -62,16 +61,9 @@ executables: []
|
|
|
62
61
|
extensions: []
|
|
63
62
|
extra_rdoc_files: []
|
|
64
63
|
files:
|
|
65
|
-
-
|
|
66
|
-
- ".github/workflows/publish.yml"
|
|
67
|
-
- ".gitignore"
|
|
68
|
-
- ".rspec"
|
|
69
|
-
- ".ruby-version"
|
|
70
|
-
- Gemfile
|
|
64
|
+
- CHANGELOG.md
|
|
71
65
|
- LICENSE.txt
|
|
72
66
|
- README.md
|
|
73
|
-
- Rakefile
|
|
74
|
-
- convert_api.gemspec
|
|
75
67
|
- lib/convert_api.rb
|
|
76
68
|
- lib/convert_api/client.rb
|
|
77
69
|
- lib/convert_api/configuration.rb
|
|
@@ -83,11 +75,14 @@ files:
|
|
|
83
75
|
- lib/convert_api/task.rb
|
|
84
76
|
- lib/convert_api/upload_io.rb
|
|
85
77
|
- lib/convert_api/version.rb
|
|
86
|
-
homepage: https://github.com/ConvertAPI/convertapi-ruby
|
|
78
|
+
homepage: https://github.com/ConvertAPI/convertapi-library-ruby
|
|
87
79
|
licenses:
|
|
88
80
|
- MIT
|
|
89
|
-
metadata:
|
|
90
|
-
|
|
81
|
+
metadata:
|
|
82
|
+
source_code_uri: https://github.com/ConvertAPI/convertapi-library-ruby
|
|
83
|
+
changelog_uri: https://github.com/ConvertAPI/convertapi-library-ruby/blob/main/CHANGELOG.md
|
|
84
|
+
bug_tracker_uri: https://github.com/ConvertAPI/convertapi-library-ruby/issues
|
|
85
|
+
documentation_uri: https://www.convertapi.com/doc
|
|
91
86
|
rdoc_options: []
|
|
92
87
|
require_paths:
|
|
93
88
|
- lib
|
|
@@ -102,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
102
97
|
- !ruby/object:Gem::Version
|
|
103
98
|
version: '0'
|
|
104
99
|
requirements: []
|
|
105
|
-
rubygems_version: 3.
|
|
106
|
-
signing_key:
|
|
100
|
+
rubygems_version: 3.6.9
|
|
107
101
|
specification_version: 4
|
|
108
102
|
summary: ConvertAPI client library
|
|
109
103
|
test_files: []
|
data/.github/workflows/main.yml
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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.1
|
|
13
|
-
- 3.2
|
|
14
|
-
- 3.3
|
|
15
|
-
- jruby-9.1
|
|
16
|
-
- jruby-head
|
|
17
|
-
name: Ruby ${{ matrix.ruby-version }} sample
|
|
18
|
-
steps:
|
|
19
|
-
- uses: actions/checkout@v3
|
|
20
|
-
- uses: ruby/setup-ruby@v1
|
|
21
|
-
with:
|
|
22
|
-
ruby-version: ${{ matrix.ruby-version }}
|
|
23
|
-
# bundler-cache: true
|
|
24
|
-
- run: bundle install
|
|
25
|
-
- env:
|
|
26
|
-
CONVERT_API_SECRET: ${{ secrets.CONVERTAPI_SECRET }}
|
|
27
|
-
CONVERT_API_TOKEN: ${{ secrets.CONVERTAPI_TOKEN }}
|
|
28
|
-
run: bundle exec rake spec
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
name: Publish gem to rubygems
|
|
2
|
-
on:
|
|
3
|
-
release:
|
|
4
|
-
types: [published]
|
|
5
|
-
jobs:
|
|
6
|
-
build:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
steps:
|
|
9
|
-
- uses: actions/checkout@v4
|
|
10
|
-
- uses: ruby/setup-ruby@v1
|
|
11
|
-
|
|
12
|
-
# setup .gem/credentials
|
|
13
|
-
- run: mkdir -p ~/.gem
|
|
14
|
-
- env:
|
|
15
|
-
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
|
16
|
-
run: >-
|
|
17
|
-
echo -e "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}" > ~/.gem/credentials
|
|
18
|
-
- run: chmod 0600 ~/.gem/credentials
|
|
19
|
-
|
|
20
|
-
- run: gem build convert_api.gemspec --output=release.gem
|
|
21
|
-
- run: gem push release.gem
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.3.4
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/convert_api.gemspec
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
-
require 'convert_api/version'
|
|
4
|
-
|
|
5
|
-
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name = 'convert_api'
|
|
7
|
-
spec.version = ConvertApi::VERSION
|
|
8
|
-
spec.authors = ['Tomas Rutkauskas']
|
|
9
|
-
spec.email = ['support@convertapi.com']
|
|
10
|
-
|
|
11
|
-
spec.summary = %q{ConvertAPI client library}
|
|
12
|
-
spec.description = %q{Convert various files like MS Word, Excel, PowerPoint, Images to PDF and Images. Create PDF and Images from url and raw HTML. Extract and create PowerPoint presentation from PDF. Merge, Encrypt, Split, Repair and Decrypt PDF files. All supported files conversions and manipulations can be found at https://www.convertapi.com/doc/supported-formats}
|
|
13
|
-
spec.homepage = 'https://github.com/ConvertAPI/convertapi-ruby'
|
|
14
|
-
spec.license = 'MIT'
|
|
15
|
-
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
17
|
-
f.match(%r{^(test|spec|features|examples)/})
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
spec.bindir = 'exe'
|
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
|
-
spec.require_paths = ['lib']
|
|
23
|
-
|
|
24
|
-
spec.add_development_dependency 'bundler'
|
|
25
|
-
spec.add_development_dependency 'rake', '>= 12.3.3'
|
|
26
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
27
|
-
end
|