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

Features/support ruby3.2 faraday2 #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions .github/workflows/unittest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ 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 }}

- name: Install apt dependencies
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev # needed by faraday-patron gem

- name: Install dependencies
run: bundle install

Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.2
3.2.2
10 changes: 9 additions & 1 deletion ipinfo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
28 changes: 15 additions & 13 deletions test/ipinfo_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def assert_ip6(resp)
assert_equal(resp.postal, '08054')
assert_equal(resp.timezone, 'America/New_York')
assert_equal(resp.country_flag_url, 'https://cdn.ipinfo.io/static/images/countries-flags/US.svg')
assert_equal(
resp.respond_to?(:asn) && assert_equal(
resp.asn,
{
"asn": 'AS7922',
Expand All @@ -43,15 +43,15 @@ def assert_ip6(resp)
"type": 'isp'
}
)
assert_equal(
resp.respond_to?(:company) && assert_equal(
resp.company,
{
"name": 'Comcast Cable Communications, LLC',
"domain": 'comcast.com',
"type": 'isp'
}
)
assert_equal(
resp.respond_to?(:privacy) && assert_equal(
resp.privacy,
{
"vpn": false,
Expand All @@ -62,7 +62,7 @@ def assert_ip6(resp)
"service": ''
}
)
assert_equal(
resp.respond_to?(:abuse) && assert_equal(
resp.abuse,
{
"address": 'US, NJ, Mount Laurel, ' \
Expand All @@ -74,7 +74,7 @@ def assert_ip6(resp)
"phone": '+1-888-565-4329'
}
)
assert_equal(
resp.respond_to?(:domains) && assert_equal(
resp.domains,
{
"total": 0,
Expand Down Expand Up @@ -115,7 +115,7 @@ def assert_ip4(resp)
assert_equal(resp.longitude, '-122.0775')
assert_equal(resp.postal, '94043')
assert_equal(resp.timezone, 'America/Los_Angeles')
assert_equal(
resp.respond_to?(:asn) && assert_equal(
resp.asn,
{
"asn": 'AS15169',
Expand All @@ -125,15 +125,15 @@ def assert_ip4(resp)
"type": 'hosting'
}
)
assert_equal(
resp.respond_to?(:company) && assert_equal(
resp.company,
{
"name": 'Google LLC',
"domain": 'google.com',
"type": 'hosting'
}
)
assert_equal(
resp.respond_to?(:privacy) && assert_equal(
resp.privacy,
{
"vpn": false,
Expand All @@ -144,21 +144,23 @@ def assert_ip4(resp)
"service": ''
}
)
assert_equal(
resp.respond_to?(:abuse) && assert_equal(
resp.abuse,
{
"address": 'US, CA, Mountain View, ' \
'1600 Amphitheatre Parkway, 94043',
'1600 Amphitheatre Parkway, 94043',
"country": 'US',
"email": '[email protected]',
"name": 'Abuse',
"network": '8.8.8.0/24',
"phone": '+1-650-253-0000'
}
)
assert_equal(resp.domains[:ip], TEST_IPV4)
refute_nil(resp.domains[:total])
refute_nil(resp.domains[:domains])
if resp.respond_to?(:domains)
assert_equal(resp.domains[:ip], TEST_IPV4)
refute_nil(resp.domains[:total])
refute_nil(resp.domains[:domains])
end
end

def test_lookup_ip4
Expand Down
15 changes: 13 additions & 2 deletions test/lib/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down