From 5bf8fba290f85ba63f3ddd0a1ce7da021aa039f5 Mon Sep 17 00:00:00 2001 From: Nicola Pagiaro Date: Tue, 30 May 2023 18:20:00 +0200 Subject: [PATCH 1/3] bumped ruby version to 3 bumped faraday to latest version and included adapters for testing remove byebug and small fixes added ruby 3.2 to circleci file install libcurl during CI --- .github/workflows/unittest.yaml | 6 ++++-- .ruby-version | 2 +- ipinfo.gemspec | 10 +++++++++- test/ipinfo_test.rb | 2 +- test/lib/adapter_test.rb | 15 +++++++++++++-- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.github/workflows/unittest.yaml b/.github/workflows/unittest.yaml index 6208acc..e028e70 100644 --- a/.github/workflows/unittest.yaml +++ b/.github/workflows/unittest.yaml @@ -12,13 +12,15 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['3.1', '3.0', '2.7', '2.6'] + ruby-version: ['3.2', '3.1', '3.0', '2.7', '2.6'] steps: - uses: actions/checkout@v3 + - name: Install apt dependencies + run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev # needed by faraday-patron gem - name: Set up Ruby ${{ matrix.ruby-version }} - uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} diff --git a/.ruby-version b/.ruby-version index 37c2961..be94e6f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.2 +3.2.2 diff --git a/ipinfo.gemspec b/ipinfo.gemspec index 5d92d88..d38fc3c 100644 --- a/ipinfo.gemspec +++ b/ipinfo.gemspec @@ -16,7 +16,15 @@ Gem::Specification.new do |spec| spec.description = ' This is a ruby wrapper for http://ipinfo.io. ' spec.homepage = 'https://ipinfo.io' - spec.add_runtime_dependency 'faraday', '~> 1.0' + spec.add_runtime_dependency 'faraday', '~> 2.0' + # add development dependency to test against faraday adapters that are been moved out the gem + spec.add_development_dependency 'async-http-faraday' + spec.add_development_dependency 'faraday-net_http_persistent', '~> 2.0' + spec.add_development_dependency 'faraday-typhoeus', '~> 1.0' + spec.add_development_dependency 'faraday-patron', '~> 2.0' + spec.add_development_dependency 'faraday-httpclient', '~> 2.0' + spec.add_development_dependency 'faraday-excon', '~> 2.1' + spec.add_runtime_dependency 'json', '~> 2.1' spec.add_runtime_dependency 'lru_redux', '~> 1.1' diff --git a/test/ipinfo_test.rb b/test/ipinfo_test.rb index 58a40a8..4a68570 100644 --- a/test/ipinfo_test.rb +++ b/test/ipinfo_test.rb @@ -148,7 +148,7 @@ def assert_ip4(resp) resp.abuse, { "address": 'US, CA, Mountain View, ' \ - '1600 Amphitheatre Parkway, 94043', + '1600 Amphitheatre Parkway, 94043', "country": 'US', "email": 'network-abuse@google.com', "name": 'Abuse', diff --git a/test/lib/adapter_test.rb b/test/lib/adapter_test.rb index c36e026..3793212 100644 --- a/test/lib/adapter_test.rb +++ b/test/lib/adapter_test.rb @@ -3,6 +3,17 @@ require 'test_helper' require_relative '../../lib/ipinfo/adapter' +require 'faraday/net_http_persistent' +require 'faraday/typhoeus' +require 'faraday/patron' +require 'faraday/httpclient' +require 'faraday/excon' + +# No updates since 2021, the method `dependecy` from the class Faraday::Adapter has been removed +# https://github.com/lostisland/faraday/blob/main/UPGRADING.md#the-dependency-method-in-middlewares-has-been-removed +# require 'faraday/em_http' +# require 'faraday/em_synchrony' + class IPinfo::AdapterTest < Minitest::Test def test_default adapter = IPinfo::Adapter.new @@ -17,8 +28,8 @@ def test_default net_http_persistent: Faraday::Adapter::NetHttpPersistent, typhoeus: Faraday::Adapter::Typhoeus, patron: Faraday::Adapter::Patron, - em_synchrony: Faraday::Adapter::EMSynchrony, - em_http: Faraday::Adapter::EMHttp, + # em_synchrony: Faraday::Adapter::EMSynchrony, + # em_http: Faraday::Adapter::EMHttp, excon: Faraday::Adapter::Excon, httpclient: Faraday::Adapter::HTTPClient }.freeze From da9fc0e0303c80390cf0fbcc6e6188a1307bc9ab Mon Sep 17 00:00:00 2001 From: Uman Shahzad Date: Tue, 21 Nov 2023 13:13:03 +0500 Subject: [PATCH 2/3] Apply suggestions from code review --- test/lib/adapter_test.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/lib/adapter_test.rb b/test/lib/adapter_test.rb index 3793212..6e3ea5f 100644 --- a/test/lib/adapter_test.rb +++ b/test/lib/adapter_test.rb @@ -9,11 +9,6 @@ require 'faraday/httpclient' require 'faraday/excon' -# No updates since 2021, the method `dependecy` from the class Faraday::Adapter has been removed -# https://github.com/lostisland/faraday/blob/main/UPGRADING.md#the-dependency-method-in-middlewares-has-been-removed -# require 'faraday/em_http' -# require 'faraday/em_synchrony' - class IPinfo::AdapterTest < Minitest::Test def test_default adapter = IPinfo::Adapter.new @@ -28,8 +23,6 @@ def test_default net_http_persistent: Faraday::Adapter::NetHttpPersistent, typhoeus: Faraday::Adapter::Typhoeus, patron: Faraday::Adapter::Patron, - # em_synchrony: Faraday::Adapter::EMSynchrony, - # em_http: Faraday::Adapter::EMHttp, excon: Faraday::Adapter::Excon, httpclient: Faraday::Adapter::HTTPClient }.freeze From b133a77cab98ca6328b94f6ba774fc4a0737bb3c Mon Sep 17 00:00:00 2001 From: SaadHassan-dev Date: Tue, 21 Nov 2023 15:46:30 +0500 Subject: [PATCH 3/3] bumped version to 2.1.0 --- lib/ipinfo/adapter.rb | 2 +- lib/ipinfo/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ipinfo/adapter.rb b/lib/ipinfo/adapter.rb index 5046ae0..2580bf7 100644 --- a/lib/ipinfo/adapter.rb +++ b/lib/ipinfo/adapter.rb @@ -42,7 +42,7 @@ def connection(adapter) def default_headers headers = { - 'User-Agent' => 'IPinfoClient/Ruby/2.0.0', + 'User-Agent' => 'IPinfoClient/Ruby/2.1.0', 'Accept' => 'application/json' } headers['Authorization'] = "Bearer #{CGI.escape(token)}" if token diff --git a/lib/ipinfo/version.rb b/lib/ipinfo/version.rb index e2ca3e0..1d7cd02 100644 --- a/lib/ipinfo/version.rb +++ b/lib/ipinfo/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module IPinfo - VERSION = '2.0.0' + VERSION = '2.1.0' end