Skip to content

Commit

Permalink
Merge pull request #78 from asonas/faraday_v2
Browse files Browse the repository at this point in the history
Support faraday v2+ and drop support ruby < 2.6
  • Loading branch information
sue445 committed Jan 8, 2022
2 parents 5853186 + eb73d0f commit 3808995
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 42 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@ jobs:

matrix:
ruby:
- ruby:2.4
- ruby:2.5
- ruby:2.6
- ruby:2.7
- ruby:3.0
- ruby:3.1
- rubylang/ruby:master-nightly-bionic
gemfile:
- faraday_0
- faraday_1
- faraday_2
include:
- ruby: rubylang/ruby:master-nightly-bionic
allow_failures: "true"
Expand Down Expand Up @@ -75,9 +72,9 @@ jobs:
flag-name: run-${{ matrix.ruby }}-${{ matrix.gemfile }}
parallel: true

- run: bundle exec rubocop
continue-on-error: ${{ matrix.allow_failures == 'true' }}
if: matrix.ruby < 'ruby:3.0' # FIXME: remove this after upgrade rubocop
# TODO: Enable after rubocop is upgraded
# - run: bundle exec rubocop
# continue-on-error: ${{ matrix.allow_failures == 'true' }}

finish:
needs: test
Expand Down
8 changes: 5 additions & 3 deletions chatwork.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_dependency "faraday", ">= 0.9"
spec.add_dependency "faraday_middleware"
spec.add_dependency "hashie"
spec.required_ruby_version = ">= 2.6.0"

spec.add_dependency "faraday", ">= 2.0.0"
spec.add_dependency "faraday-mashify"
spec.add_dependency "faraday-multipart"

spec.add_development_dependency "activesupport"
spec.add_development_dependency "bundler", ">= 1.3"
Expand Down
18 changes: 0 additions & 18 deletions gemfiles/common.gemfile
Original file line number Diff line number Diff line change
@@ -1,18 +0,0 @@
if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.3.0")
group :test do
gem "backport_dig", group: :development
end
end

if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.2.2")
group :test do
gem "activesupport", "< 5.0.0", group: :development
end
end

if Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.5.0")
group :test do
# NOTE: unparser v0.3.0+ requires Ruby 2.5+
gem "unparser", "< 0.3.0"
end
end
8 changes: 0 additions & 8 deletions gemfiles/faraday_1.gemfile

This file was deleted.

2 changes: 1 addition & 1 deletion gemfiles/faraday_0.gemfile → gemfiles/faraday_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ gemspec path: "../"

eval_gemfile "#{__dir__}/common.gemfile"

gem "faraday", "~> 0.9"
gem "faraday", "~> 2.0"
4 changes: 3 additions & 1 deletion lib/chatwork.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "chatwork/version"
require "hashie"
require "faraday"
require "faraday/mashify"
require "faraday/multipart"

module ChatWork
autoload :BaseClient, "chatwork/base_client"
Expand Down Expand Up @@ -34,7 +36,7 @@ module ChatWork
@client_secret = nil

Faraday::Request.register_middleware(
chatwork_multipart: -> { ChatWork::Multipart },
chatwork_multipart: ChatWork::Multipart,
)

class << self
Expand Down
3 changes: 0 additions & 3 deletions lib/chatwork/base_client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require "faraday"
require "faraday_middleware"

module ChatWork
class BaseClient
include Converter
Expand Down
2 changes: 1 addition & 1 deletion lib/chatwork/multipart.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module ChatWork
class Multipart < ::Faraday::Request::Multipart
class Multipart < ::Faraday::Multipart::Middleware
self.mime_type = "multipart/form-data".freeze

def create_multipart(env, params)
Expand Down

0 comments on commit 3808995

Please sign in to comment.