Skip to content

Commit

Permalink
Deprecate unnecessary constant in GitHubMetadata::Client (#239)
Browse files Browse the repository at this point in the history
Merge pull request 239
  • Loading branch information
ashmaroli committed Apr 4, 2023
1 parent f0635ef commit a540088
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
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

0 comments on commit a540088

Please sign in to comment.