Skip to content

Commit

Permalink
#185829263 : Allow faraday from 1.x (#20)
Browse files Browse the repository at this point in the history
* allow faraday from 1x

* in faraday 1.0 retry and net_http_persistent is bundled in

* bump version to minor 2.1.0 since supporting faraday 1.0 is adding new feature

* remove uneeded if else

* remove unneeded space

* remove uneeded print

* clarify comment
  • Loading branch information
xinghengwang authored Aug 16, 2023
1 parent 9359b8d commit 449eedf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/test/tmp/
/test/version_tmp/
/tmp/
Gemfile.lock

# Used by dotenv library to load environment variables.
# .env
Expand Down
11 changes: 9 additions & 2 deletions lib/moesif_api/http/faraday_client.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
require 'faraday'
require 'faraday/net_http_persistent'
require 'faraday/retry'
require 'json'

faraday_version = Gem.loaded_specs['faraday'].version

# in faraday < 2.0 net_http_persistent and retry is build into faraday already
# in faraday >= 2.0 we must require these plugins
if faraday_version >= Gem::Version.new('2.0')
require 'faraday/net_http_persistent'
require 'faraday/retry'
end

module MoesifApi
class FaradayClient < HttpClient
def initialize
Expand Down
8 changes: 4 additions & 4 deletions moesif_api.gemspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Gem::Specification.new do |s|
s.name = 'moesif_api'
s.version = '2.0.2'
s.version = '2.1.0'
s.summary = 'moesif_api'
s.description = 'Collection/Data Ingestion API'
s.authors = ['Moesif, Inc', 'Derric Gilling']
s.email = 'derric@moesif.com'
s.homepage = 'https://moesif.com'
s.license = 'Apache-2.0'
s.add_development_dependency('test-unit', '~> 3.5', '>= 3.5.0')
s.add_dependency('faraday', '~> 2')
s.add_dependency('faraday-net_http_persistent', '~> 2')
s.add_dependency('faraday-retry', '~> 2')
s.add_dependency('faraday', '>= 1.0', '< 3.0')
s.add_dependency('faraday-net_http_persistent', '< 3.0')
s.add_dependency('faraday-retry', '< 3.0')
s.add_dependency('json_mapper', '~> 0')
s.add_dependency('net-http-persistent', '~> 4')
s.required_ruby_version = '>= 2.6'
Expand Down

0 comments on commit 449eedf

Please sign in to comment.