Skip to content

Commit

Permalink
Merge pull request #99 from ekohl/faraday-2
Browse files Browse the repository at this point in the history
Move to Faraday 2.x, which requires Ruby 2.6+
  • Loading branch information
barriserloth authored Nov 30, 2022
2 parents 51b76eb + 06102bc commit 614ad2c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ruby-rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ 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
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Build and test with Rspec
run: |
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rspec
run: bundle exec rspec
4 changes: 2 additions & 2 deletions lib/puppet_forge/connection.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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)
11 changes: 4 additions & 7 deletions puppet_forge.gemspec
Original file line number Diff line number Diff line change
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 All @@ -31,8 +31,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "cane"
spec.add_development_dependency "yard"
spec.add_development_dependency "redcarpet"

# Install the right pry debugging combo depending on ruby version.
spec.add_development_dependency "pry-debugger" if RUBY_VERSION <= '1.9.3'
spec.add_development_dependency "pry-byebug" if RUBY_VERSION >= '2.0.0'
spec.add_development_dependency "pry-byebug"
end

0 comments on commit 614ad2c

Please sign in to comment.