diff --git a/CHANGELOG.md b/CHANGELOG.md index 8adae85..e08a2e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### 0.3.1 (Next) * Your contribution here. +* [#33](https://github.com/dblock/open-weather-ruby-client/pull/33): Update faraday to 2.x - [@dgarwood](https://github.com/dgarwood). ### 0.3.0 (2023/03/25) diff --git a/Gemfile b/Gemfile index 0a417e0..f7200f1 100644 --- a/Gemfile +++ b/Gemfile @@ -3,15 +3,3 @@ source 'http://rubygems.org' gemspec - -group :development, :test do - gem 'danger-changelog', '~> 0.4.2' - gem 'danger-toc', '~> 0.1.3' - gem 'dotenv' - gem 'pry' - gem 'rake' - gem 'rspec' - gem 'rubocop', '~> 1.48.1' - gem 'vcr' - gem 'webmock' -end diff --git a/lib/open-weather-ruby-client.rb b/lib/open-weather-ruby-client.rb index a2cab32..41807fe 100644 --- a/lib/open-weather-ruby-client.rb +++ b/lib/open-weather-ruby-client.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true require 'faraday' -require 'faraday_middleware' +require 'faraday/multipart' + require 'json' require 'logger' require 'hashie' diff --git a/lib/open_weather/connection.rb b/lib/open_weather/connection.rb index cdfaa80..74965bc 100644 --- a/lib/open_weather/connection.rb +++ b/lib/open_weather/connection.rb @@ -26,13 +26,12 @@ def connection request_options[:open_timeout] = open_timeout if open_timeout options[:request] = request_options if request_options.any? - ::Faraday::Connection.new(endpoint, options) do |connection| - connection.use ::Faraday::Request::Multipart - connection.use ::Faraday::Request::UrlEncoded - connection.use ::OpenWeather::Response::RaiseError - connection.use ::FaradayMiddleware::ParseJson, content_type: /\bjson$/ - connection.response :logger, logger if logger - connection.adapter ::Faraday.default_adapter + Faraday.new(endpoint, options) do |f| + f.request :multipart + f.request :url_encoded + f.use ::OpenWeather::Response::RaiseError + f.response :json, content_type: /\bjson$/ + f.response :logger, logger if logger end end end diff --git a/lib/open_weather/raise_error.rb b/lib/open_weather/raise_error.rb index 14aa0e7..6677953 100644 --- a/lib/open_weather/raise_error.rb +++ b/lib/open_weather/raise_error.rb @@ -2,7 +2,7 @@ module OpenWeather module Response - class RaiseError < ::Faraday::Response::Middleware + class RaiseError < ::Faraday::Response::RaiseError def on_complete(env) case env[:status] when 404 diff --git a/open-weather-ruby-client.gemspec b/open-weather-ruby-client.gemspec index d12db4c..35cfc19 100644 --- a/open-weather-ruby-client.gemspec +++ b/open-weather-ruby-client.gemspec @@ -17,7 +17,17 @@ Gem::Specification.new do |s| s.licenses = ['MIT'] s.summary = 'OpenWeather API Ruby client.' s.add_dependency 'activesupport' - s.add_dependency 'faraday', '>= 1.0.0' - s.add_dependency 'faraday_middleware' + s.add_dependency 'faraday', '>= 2.0.1' + s.add_dependency 'faraday-multipart' s.add_dependency 'hashie' + + s.add_development_dependency 'danger-changelog', '~> 0.4.2' + s.add_development_dependency 'danger-toc', '~> 0.1.3' + s.add_development_dependency 'dotenv' + s.add_development_dependency 'pry' + s.add_development_dependency 'rake' + s.add_development_dependency 'rspec' + s.add_development_dependency 'rubocop', '~> 1.48.1' + s.add_development_dependency 'vcr' + s.add_development_dependency 'webmock' end