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

Prepare this adapter for Faraday 2.0 #7

Merged
merged 1 commit into from
Nov 1, 2021
Merged
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
5 changes: 0 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# frozen_string_literal: true

source "https://rubygems.org"

# TODO: remove this once v4 is released
options = (RUBY_VERSION.start_with?("3") ? {github: "grosser/net-http-persistent", branch: "grosser/spec"} : {})
gem "net-http-persistent", ">= 3.1", **options

gemspec
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,31 @@

This gem is a [Faraday][faraday] adapter for the [Net::HTTP::Persistent gem][net-http-persistent].

---

:warning: **This README is for the `main` branch that uses Faraday 2.0, which is not yet released.**

For 1.0-compatible documentation, refer to [v1.2.0 of the README](https://github.com/lostisland/faraday-net_http_persistent/blob/v1.2.0/README.md).

---

## Installation

Add these lines to your application's Gemfile:
Add this to your application's Gemfile:

```ruby
gem 'faraday-net_http_persistent'
gem 'net-http-persistent', '>= 3.1'
gem 'faraday-net_http_persistent',
git: 'https://github.com/lostisland/faraday-net_http_persistent',
branch: 'main'
```

And then execute:

$ bundle

Or install them yourself as:

$ gem install net_http_persistent -v '>= 3.1'
$ gem install faraday-net_http_persistent

## Usage

Configure your Faraday connection to use this adapter instead of the default one:
Configure your Faraday connection to use the `net_http_persistent` adapter:

```ruby
connection = Faraday.new(url, conn_options) do |conn|
Expand Down
6 changes: 3 additions & 3 deletions faraday-net_http_persistent.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Gem::Specification.new do |spec|
spec.files = Dir.glob("lib/**/*") + %w[README.md LICENSE.md]
spec.require_paths = ["lib"]

# TODO: make this a normal dependency when releasing v2.0
spec.add_development_dependency "net-http-persistent", ">= 3.1"
spec.add_dependency "faraday", ">= 2.0.0.alpha.pre.2"
spec.add_dependency "faraday-net_http"
spec.add_dependency "net-http-persistent", ">= 3.1"

spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "faraday", "~> 1.0"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "simplecov", "~> 0.19.0"
Expand Down
5 changes: 3 additions & 2 deletions lib/faraday/adapter/net_http_persistent.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# frozen_string_literal: true

require "faraday/net_http"
require "net/http/persistent"

module Faraday
class Adapter
# Net::HTTP::Persistent adapter.
class NetHttpPersistent < NetHttp
dependency "net/http/persistent"

private

def net_http_connection(env)
Expand Down