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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e87ee021afbce241b24e28e70245ec318a6c6ae799c1ff769cd6437a4065536f
4
- data.tar.gz: b385c3030e308d7dde8d711f3b2f30d48303f5af6bc5208437b09ae329b50519
3
+ metadata.gz: 5fcd9fe8ad08c01b6cd0ca4e52208444ff3da05a10ebdf20eac4d6d8f443c94f
4
+ data.tar.gz: 9a4842f2843643892704f9ebfd134f98519c0a689a18fbfed0d7587b3e30330a
5
5
  SHA512:
6
- metadata.gz: 0447ac667edc5df34913612ff81003dfbcdea39a345b1fc111ecfd28dd123651d0fa2218b4942258e4aecd32266438ae2768e593ceb5c0ff7573fbb4f389d26e
7
- data.tar.gz: 57a409748204a607373d4b1d2a6db8b8d7ad68a02f4da5a6aab1bf023358e6d727972f29113c606d940686c854b3a261f2e690921a3345785c394f321364a32c
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
  [![Gem](https://img.shields.io/gem/v/convert_api.svg)](https://rubygems.org/gems/convert_api)
5
- [![Build Status](https://github.com/ConvertAPI/convertapi-ruby/actions/workflows/main.yml/badge.svg)](https://github.com/ConvertAPI/convertapi-ruby/actions)
5
+ [![Build](https://github.com/ConvertAPI/convertapi-library-ruby/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/ConvertAPI/convertapi-library-ruby/actions/workflows/build.yml)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](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 secret at https://www.convertapi.com/a/auth
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.api_secret = 'your-api-secret'
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 remaining seconds programmatically by fetching [user information](https://www.convertapi.com/doc/user).
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/master/examples) folder.
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 `CONVERT_API_SECRET=your_secret rake spec` to run the tests.
138
-
139
- Or
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`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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
 
@@ -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), DEFAULT_HEADERS)
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), DEFAULT_HEADERS)
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
- raise(AuthenticationError, 'API secret or Token not configured') if authentication.nil?
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 authentication
127
- return { Secret: config.api_secret } unless config.api_secret.nil?
128
- return { Token: config.token } unless config.token.nil?
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
- nil
129
+ def api_credentials
130
+ config.api_credentials || raise(AuthenticationError, 'API credentials not configured')
131
131
  end
132
132
 
133
133
  def base_uri
@@ -1,7 +1,6 @@
1
1
  module ConvertApi
2
2
  class Configuration
3
- attr_accessor :api_secret
4
- attr_accessor :token
3
+ attr_accessor :api_credentials
5
4
  attr_accessor :base_uri
6
5
  attr_accessor :connect_timeout
7
6
  attr_accessor :read_timeout
@@ -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}#{converter_path}",
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
@@ -1,3 +1,3 @@
1
1
  module ConvertApi
2
- VERSION = '2.0.0'
2
+ VERSION = '3.0.1'
3
3
  end
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
- URI_REGEXP = URI::regexp(%w(http https))
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: 2.0.0
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: 2024-08-04 00:00:00.000000000 Z
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
- - ".github/workflows/main.yml"
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
- post_install_message:
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.5.11
106
- signing_key:
100
+ rubygems_version: 3.6.9
107
101
  specification_version: 4
108
102
  summary: ConvertAPI client library
109
103
  test_files: []
@@ -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
@@ -1,12 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
10
-
11
- # rspec failure tracking
12
- .rspec_status
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --require spec_helper
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.3.4
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in convert_api.gemspec
6
- gemspec
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
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