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

Fix faraday connectionfailed issue #178

Merged
merged 9 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ rvm:
matrix:
include:
- rvm: *latest_ruby
env: JEKYLL_VERSION=3.7.0
env: JEKYLL_VERSION=3.7.0 FARADAY_VERSION=0.17
- rvm: *latest_ruby
env: JEKYLL_VERSION=4.0.0.pre.alpha1
env: JEKYLL_VERSION=3.7.0 FARADAY_VERSION=1.0
- rvm: *latest_ruby
env: JEKYLL_VERSION=4.0.0.pre.alpha1 FARADAY_VERSION=0.17
DirtyF marked this conversation as resolved.
Show resolved Hide resolved
- rvm: *latest_ruby
env: JEKYLL_VERSION=4.0.0.pre.alpha1 FARADAY_VERSION=1.0
DirtyF marked this conversation as resolved.
Show resolved Hide resolved
branches:
only:
- master
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
source "https://rubygems.org"
gemspec

gem "faraday", "~> #{ENV["FARADAY_VERSION"]}" if ENV["FARADAY_VERSION"]
gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}" if ENV["JEKYLL_VERSION"]

group :test do
Expand Down
11 changes: 10 additions & 1 deletion lib/jekyll-github-metadata/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ 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.
FARADAY_FAILED_CONNECTION =
begin
Faraday::Error::ConnectionFailed
rescue NameError
Faraday::ConnectionFailed
end
Comment on lines +71 to +78
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parkr this tries to detect whether Faraday::Error::ConnectionFailed works or not. This would prevents from locking specific version of Faraday. All tests passes for the both versions v0.17 and v1.0 of Faraday: Build #517 - jekyll/github-metadata - Travis CI.


def save_from_errors(default = false)
unless internet_connected?
GitHubMetadata.log :warn, "No internet connection. GitHub metadata may be missing or incorrect."
Expand All @@ -77,7 +86,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::Error::ConnectionFailed, Octokit::TooManyRequests => e
rescue FARADAY_FAILED_CONNECTION, Octokit::TooManyRequests => e
GitHubMetadata.log :warn, e.message
default
rescue Octokit::NotFound
Expand Down