Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for faraday 2.x #412

Merged
merged 8 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,11 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [2.3, 2.4, 2.5, 2.6, 2.7]
rails: ["4.1", "4.2", "5.0", "5.2.3", "6.0"]
exclude:
- ruby: "2.4"
rails: "4.1"
- ruby: "2.4"
rails: "4.2"
- ruby: "2.4"
rails: "6.0"
- ruby: "2.5"
rails: "4.1"
- ruby: "2.5"
rails: "4.2"
- ruby: "2.6"
rails: "4.1"
- ruby: "2.6"
rails: "4.2"
- ruby: "2.7"
rails: "4.1"
- ruby: "2.7"
rails: "4.2"
ruby:
- "3.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be quoted, otherwise 3.0 becomes 3, which gets interpreted as 3.x, resolving to 3.3

- "3.1"
- "3.2"
- "3.3"
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
Expand All @@ -51,4 +35,6 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake
run: |
bundle exec appraisal install
bundle exec appraisal rake test
27 changes: 16 additions & 11 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
appraise '3.2' do
gem 'activesupport', '~> 3.2.22'
gem 'minitest', '~> 5'
appraise 'activesupport-6.0' do
gem 'activesupport', '~> 6.0.0'
end

appraise '4.0' do
gem 'activesupport', '~> 4.0.13'
appraise 'activesupport-6.1' do
gem 'activesupport', '~> 6.1.0'
end

appraise '4.1' do
gem 'activesupport', '~> 4.1.14'
appraise 'activesupport-7.0' do
gem 'activesupport', '~> 7.0.0'
end

appraise '4.2' do
gem 'activesupport', '~> 4.2.5.1'
appraise 'activesupport-7.1' do
gem 'activesupport', '~> 7.1.0'
end

appraise '5.0' do
gem 'activesupport', '~> 5.0.0'
appraise 'faraday-1.x' do
gem 'faraday', '~> 1.10'
gem 'faraday-gzip', '~> 1.0'
end

appraise 'faraday-2.x' do
gem 'faraday', '~> 2.0'
gem 'faraday-gzip', '~> 2.0'
end
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## Unreleased


- [#412](https://github.com/JsonApiClient/json_api_client/pull/412)
- Add support for faraday 2.x
- Drop support for Ruby < 3.0 (EOL)
- Drop support for activesupport < 6.0 (EOL)
- Remove deprecated faraday_middleware and add faraday-gzip (from [#402](https://github.com/JsonApiClient/json_api_client/pull/402))
- [#400](https://github.com/JsonApiClient/json_api_client/pull/400) - Fix for multi-word custom endpoint and route format

## 1.22.0
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ source "https://rubygems.org"
gemspec

gem 'rake'
gem 'appraisal'

gem "activesupport"
gem "activesupport", ">= 4.0.13"
gem 'addressable', '~> 2.2'

gem "codeclimate-test-reporter", group: :test, require: nil
Expand Down
16 changes: 0 additions & 16 deletions gemfiles/3.2.gemfile

This file was deleted.

15 changes: 0 additions & 15 deletions gemfiles/4.0.gemfile

This file was deleted.

15 changes: 0 additions & 15 deletions gemfiles/4.1.gemfile

This file was deleted.

15 changes: 0 additions & 15 deletions gemfiles/4.2.gemfile

This file was deleted.

15 changes: 0 additions & 15 deletions gemfiles/5.0.gemfile

This file was deleted.

15 changes: 0 additions & 15 deletions gemfiles/5.2.3.gemfile

This file was deleted.

7 changes: 3 additions & 4 deletions gemfiles/6.0.gemfile → gemfiles/activesupport_6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
source "https://rubygems.org"

gem "rake"
gem "appraisal"
gem "activesupport", "~> 6.0.0"
gem "addressable", "~> 2.2"
gem "codeclimate-test-reporter", :group => :test, :require => nil
gem "codeclimate-test-reporter", group: :test, require: nil

group :development, :test do
gem "byebug", :platforms => [:mri_25]
gem "byebug", "~> 10.0", platforms: [:mri_20, :mri_21, :mri_22]
end

gemspec :path => "../"
gemspec path: "../"
14 changes: 14 additions & 0 deletions gemfiles/activesupport_6.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rake"
gem "activesupport", "~> 6.1.0"
gem "addressable", "~> 2.2"
gem "codeclimate-test-reporter", group: :test, require: nil

group :development, :test do
gem "byebug", "~> 10.0", platforms: [:mri_20, :mri_21, :mri_22]
end

gemspec path: "../"
14 changes: 14 additions & 0 deletions gemfiles/activesupport_7.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rake"
gem "activesupport", "~> 7.0.0"
gem "addressable", "~> 2.2"
gem "codeclimate-test-reporter", group: :test, require: nil

group :development, :test do
gem "byebug", "~> 10.0", platforms: [:mri_20, :mri_21, :mri_22]
end

gemspec path: "../"
14 changes: 14 additions & 0 deletions gemfiles/activesupport_7.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rake"
gem "activesupport", "~> 7.1.0"
gem "addressable", "~> 2.2"
gem "codeclimate-test-reporter", group: :test, require: nil

group :development, :test do
gem "byebug", "~> 10.0", platforms: [:mri_20, :mri_21, :mri_22]
end

gemspec path: "../"
16 changes: 16 additions & 0 deletions gemfiles/faraday_1.x.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rake"
gem "activesupport", ">= 4.0.13"
gem "addressable", "~> 2.2"
gem "codeclimate-test-reporter", group: :test, require: nil
gem "faraday", "~> 1.10"
gem "faraday-gzip", "~> 1.0"

group :development, :test do
gem "byebug", "~> 10.0", platforms: [:mri_20, :mri_21, :mri_22]
end

gemspec path: "../"
16 changes: 16 additions & 0 deletions gemfiles/faraday_2.x.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rake"
gem "activesupport", ">= 4.0.13"
gem "addressable", "~> 2.2"
gem "codeclimate-test-reporter", group: :test, require: nil
gem "faraday", "~> 2.0"
gem "faraday-gzip", "~> 2.0"

group :development, :test do
gem "byebug", "~> 10.0", platforms: [:mri_20, :mri_21, :mri_22]
end

gemspec path: "../"
9 changes: 5 additions & 4 deletions json_api_client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ Gem::Specification.new do |s|
s.description = 'Build client libraries compliant with specification defined by jsonapi.org'
s.summary = 'Build client libraries compliant with specification defined by jsonapi.org'

s.add_dependency "activesupport", '>= 3.2.0'
s.add_dependency "faraday", '>= 0.15.2', '< 2.0'
s.add_dependency "faraday_middleware", '>= 0.9.0', '< 2.0'
s.add_dependency "activesupport", '>= 6.0.0'
s.add_dependency "faraday", '>= 1.10', '< 3.0'
s.add_dependency "faraday-gzip", '>= 1.0', '< 3.0'
s.add_dependency "addressable", '~> 2.2'
s.add_dependency "activemodel", '>= 3.2.0'
s.add_dependency "activemodel", '>= 6.0.0'
s.add_dependency "rack", '>= 0.2'

s.add_development_dependency "webmock", '~> 3.5.1'
s.add_development_dependency "mocha"
s.add_development_dependency "appraisal"

s.license = "MIT"

Expand Down
2 changes: 1 addition & 1 deletion lib/json_api_client.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'faraday'
require 'faraday_middleware'
require 'faraday/gzip'
require 'json'
require 'addressable/uri'
require 'json_api_client/formatter'
Expand Down
6 changes: 3 additions & 3 deletions lib/json_api_client/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def initialize(options = {})
builder.request :json
builder.use Middleware::JsonRequest
builder.use Middleware::Status, status_middleware_options
builder.use Middleware::ParseJson
builder.use ::FaradayMiddleware::Gzip
builder.response :json
builder.use ::Faraday::Gzip::Middleware
builder.adapter(*adapter_options)
end
yield(self) if block_given?
Expand All @@ -24,7 +24,7 @@ def initialize(options = {})
# inserted middleware will run after json parsed
def use(middleware, *args, &block)
return if faraday.builder.locked?
faraday.builder.insert_before(Middleware::ParseJson, middleware, *args, &block)
faraday.builder.insert_before(::Faraday::Response::Json, middleware, *args, &block)
end

def delete(middleware)
Expand Down
3 changes: 1 addition & 2 deletions lib/json_api_client/middleware.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module JsonApiClient
module Middleware
autoload :JsonRequest, 'json_api_client/middleware/json_request'
autoload :ParseJson, 'json_api_client/middleware/parse_json'
autoload :Status, 'json_api_client/middleware/status'
end
end
end
31 changes: 0 additions & 31 deletions lib/json_api_client/middleware/parse_json.rb

This file was deleted.