Skip to content

Commit

Permalink
Move to Faraday 2.x
Browse files Browse the repository at this point in the history
It does not attempt to support Faraday 1.x as well because dependency
wise it would be impossible to pull in the correct middleware. That is
why a hard switch was made.

This moves the minimum Ruby version to 2.6 since that's what Faraday 2
has as the minimum version.

It also pulls in faraday-follow_redirects, which was previously part of
Faraday itself.

The registration is now done without a lamba since it's allowed to pass
in a constant.

CI is also modified to test on all actual Ruby version that currently
match the required_ruby_version in the gemspec. That is, 2.6 - 3.1.
  • Loading branch information
ekohl committed Jun 9, 2022
1 parent 66df7fe commit 06102bc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ruby-rspec.yml
Expand Up @@ -14,7 +14,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: [2.7, 2.6, 2.5]
ruby:
- '3.1'
- '3.0'
- '2.7'
- '2.6'

steps:
- uses: actions/checkout@v1
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet_forge/connection.rb
@@ -1,7 +1,7 @@
require 'puppet_forge/connection/connection_failure'

require 'faraday'
require 'faraday_middleware'
require 'faraday/follow_redirects'

module PuppetForge
# Provide a common mixin for adding a HTTP connection to classes.
Expand Down Expand Up @@ -115,7 +115,7 @@ def make_connection(url, adapter_args = nil, opts = {})
end

Faraday.new(url, options) do |builder|
builder.use FaradayMiddleware::FollowRedirects
builder.use Faraday::FollowRedirects::Middleware
builder.response(:json, :content_type => /\bjson$/, :parser_options => { :symbolize_names => true })
builder.response(:raise_error)
builder.use(:connection_failure)
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet_forge/connection/connection_failure.rb
Expand Up @@ -22,4 +22,4 @@ def call(env)
end
end

Faraday::Middleware.register_middleware(:connection_failure => lambda { PuppetForge::Connection::ConnectionFailure })
Faraday::Middleware.register_middleware(:connection_failure => PuppetForge::Connection::ConnectionFailure)
6 changes: 3 additions & 3 deletions puppet_forge.gemspec
Expand Up @@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.required_ruby_version = '>= 2.4.0'
spec.required_ruby_version = '>= 2.6.0'

spec.add_runtime_dependency "faraday", "~> 1.3"
spec.add_runtime_dependency "faraday_middleware", "~> 1.0"
spec.add_runtime_dependency "faraday", "~> 2.0"
spec.add_runtime_dependency "faraday-follow_redirects", "~> 0.3.0"
spec.add_dependency "semantic_puppet", "~> 1.0"
spec.add_dependency "minitar"

Expand Down

0 comments on commit 06102bc

Please sign in to comment.