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

Deprecate unnecessary constant in GitHubMetadata::Client #239

Merged
merged 3 commits into from
Apr 4, 2023
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
9 changes: 7 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ on:

jobs:
ci:
name: 'Ruby ${{ matrix.ruby_version }}'
runs-on: '${{ matrix.os }}'
name: 'Ruby: ${{ matrix.ruby_version }} • Faraday: ~> ${{ matrix.faraday_version }}'
runs-on: ${{ matrix.os }}
env:
FARADAY_VERSION: ${{ matrix.faraday_version }}
strategy:
fail-fast: false
matrix:
Expand All @@ -20,6 +22,9 @@ jobs:
- '3.0'
- '3.1'
- '3.2'
faraday_version:
- '1.0'
- '2.0'
os:
- ubuntu-latest
steps:
Expand Down
12 changes: 9 additions & 3 deletions lib/jekyll-github-metadata/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,20 @@ def method_missing(method_name, *args, &block)
end
end

# NOTE: Faraday's error classes has been promoted to under Faraday module from v1.0.0.
# This patch aims to prevent on locking specific version of Faraday.
# NOTE: Faraday's error classes have been simplified from v1.0.0.
#
# In older versions, both `Faraday::Error::ConnectionFailed` and `Faraday::ConnectionFailed`
# were valid and equivalent to each other.
# From v1.0.0 onwards, `Faraday::Error::ConnectionFailed` no longer exists.
#
# TODO: Remove in v2.0 of this plugin.
FARADAY_FAILED_CONNECTION =
begin
Faraday::Error::ConnectionFailed
rescue NameError
Faraday::ConnectionFailed
end
deprecate_constant :FARADAY_FAILED_CONNECTION

def save_from_errors(default = false)
unless internet_connected?
Expand All @@ -86,7 +92,7 @@ def save_from_errors(default = false)
yield @client
rescue Octokit::Unauthorized
raise BadCredentialsError, "The GitHub API credentials you provided aren't valid."
rescue FARADAY_FAILED_CONNECTION, Octokit::TooManyRequests => e
rescue Faraday::ConnectionFailed, Octokit::TooManyRequests => e
GitHubMetadata.log :warn, e.message
default
rescue Octokit::NotFound
Expand Down