Skip to content

Commit

Permalink
Merge pull request #61 from Nuzair46/main
Browse files Browse the repository at this point in the history
Updated Faraday to 2.0.1
  • Loading branch information
afrase committed Apr 24, 2023
2 parents f2b0a39 + 7132552 commit cf886f6
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: [ '2.5', '2.6', '2.7', '3.0' ]
ruby-version: ['2.6', '2.7', '3.0' ]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require: rubocop-rspec

AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 2.6
NewCops: enable

Exclude:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.7.3
ruby-2.7.8
20 changes: 13 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
# 0.3.0

- Updated faraday to version 2.0.1
- Removed depricated faraday_middleware gem
- Updated minimum ruby version to 2.6

# 0.2.0

* Update faraday and faraday_middleware dependency requirements.
* Update rubocop dev dependencies and fixed failures.
* Updated minimum ruby version to 2.5.
- Update faraday and faraday_middleware dependency requirements.
- Update rubocop dev dependencies and fixed failures.
- Updated minimum ruby version to 2.5.

# 0.1.2

* Removed the double quote from the body check since it appears a space is added after the colon.
* Added changelog file.
- Removed the double quote from the body check since it appears a space is added after the colon.
- Added changelog file.

# 0.1.1

* Removed safe accessor usage to work with older versions of Ruby.
- Removed safe accessor usage to work with older versions of Ruby.

# 0.1.0

* Added support for V2 of Zerobounce API.
- Added support for V2 of Zerobounce API.
7 changes: 3 additions & 4 deletions lib/zerobounce/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# frozen_string_literal: true

require 'faraday'
require 'faraday_middleware'
require 'zerobounce/middleware/raise_error'
require 'zerobounce/middleware/raise_http_exception'

module Zerobounce
# Configuration object for Zerobounce.
Expand Down Expand Up @@ -39,15 +38,15 @@ class Configuration

def initialize
self.host = 'https://api.zerobounce.net'
self.apikey = ENV['ZEROBOUNCE_API_KEY']
self.apikey = ENV.fetch('ZEROBOUNCE_API_KEY', nil)
self.api_version = 'v2'
self.valid_statuses = %i[valid catch_all]
self.headers = { user_agent: "ZerobounceRubyGem/#{Zerobounce::VERSION}" }

self.middleware = proc do |builder|
builder.response(:json, content_type: /\bjson$/, parser_options: { symbolize_names: true })
builder.response(:logger) { |l| l.filter(/(api_?key=)(\w+)/, '\1[REMOVED]') } if ENV['ZEROBOUNCE_API_DEBUG']
builder.use(Zerobounce::Middleware::RaiseError)
builder.use(Zerobounce::Middleware::RaiseHttpException)
builder.adapter(Faraday.default_adapter)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Middleware
# Raises an error if the response wasn't successful.
#
# @author Aaron Frase
class RaiseError < Faraday::Response::Middleware
class RaiseHttpException < Faraday::Middleware
# Check for errors after the response has finished.
#
# @param [Hash] env
Expand Down
2 changes: 1 addition & 1 deletion lib/zerobounce/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

module Zerobounce
# The version of the gem.
VERSION = '0.2.2'
VERSION = '0.3.0'
end
4 changes: 2 additions & 2 deletions spec/zerobounce/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
expect(builder).to have_received(:response).with(:json, Hash)
end

it 'uses the RaiseError class' do
it 'uses the RaiseHttpException class' do
described_class.new.middleware.call(builder)
expect(builder).to have_received(:use).with(Zerobounce::Middleware::RaiseError)
expect(builder).to have_received(:use).with(Zerobounce::Middleware::RaiseHttpException)
end

it 'uses Faraday default adapter' do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe Zerobounce::Middleware::RaiseError do
RSpec.describe Zerobounce::Middleware::RaiseHttpException do
describe '#on_complete' do
context 'when response contains an error' do
let(:env) { { status: 500 } }
Expand Down
10 changes: 5 additions & 5 deletions zerobounce.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'zerobounce/version'

Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
Gem::Specification.new do |spec|
spec.name = 'zerobounce'
spec.version = Zerobounce::VERSION
spec.authors = ['Aaron Frase']
Expand All @@ -24,12 +24,11 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength

spec.metadata['yard.run'] = 'yri' # use "yard" to build full HTML docs.

spec.required_ruby_version = '>= 2.5'
spec.required_ruby_version = '>= 2.6'

spec.add_dependency 'faraday', '>= 0.14', '< 2.0'
spec.add_dependency 'faraday_middleware', '~> 1.0'
spec.add_dependency 'faraday', '>= 2.0.1'

spec.add_development_dependency 'bundler', '~> 2.2.17'
spec.add_development_dependency 'bundler', '>= 2.2.17'
spec.add_development_dependency 'pry', '~> 0.14.1'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.0'
Expand All @@ -40,4 +39,5 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
spec.add_development_dependency 'rubocop-rspec', '~> 2.3'
spec.add_development_dependency 'simplecov', '~> 0.21.2'
spec.add_development_dependency 'yard', '~> 0.9.26'
spec.metadata['rubygems_mfa_required'] = 'true'
end

0 comments on commit cf886f6

Please sign in to comment.