Skip to content

Commit

Permalink
Fix faraday connectionfailed issue (#178)
Browse files Browse the repository at this point in the history
Merge pull request 178
  • Loading branch information
satoryu authored and jekyllbot committed Jan 7, 2020
1 parent 9353743 commit 5004444
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ rvm:
matrix:
include:
- rvm: *latest_ruby
env: JEKYLL_VERSION=3.7.0
env: JEKYLL_VERSION=4.0 FARADAY_VERSION=0.17
- rvm: *latest_ruby
env: JEKYLL_VERSION=4.0.0.pre.alpha1
env: JEKYLL_VERSION=3.7 FARADAY_VERSION=0.17
- rvm: *latest_ruby
env: JEKYLL_VERSION=3.7 FARADAY_VERSION=1.0
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: 9 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ build: off
environment:
matrix:
- RUBY_FOLDER_VER: "26"
JEKYLL_VERSION: "3.7.0"
JEKYLL_VERSION: "4.0"
FARADAY_VERSION: "1.0"
- RUBY_FOLDER_VER: "26"
JEKYLL_VERSION: "4.0.0.pre.alpha1"
JEKYLL_VERSION: "4.0"
FARADAY_VERSION: "0.17"
- RUBY_FOLDER_VER: "26"
JEKYLL_VERSION: "3.7"
FARADAY_VERSION: "1.0"
- RUBY_FOLDER_VER: "26"
JEKYLL_VERSION: "3.7"
FARADAY_VERSION: "0.17"
- RUBY_FOLDER_VER: "25"
- RUBY_FOLDER_VER: "24"
- RUBY_FOLDER_VER: "23"
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

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

0 comments on commit 5004444

Please sign in to comment.