Fix bug get Forbidden last version github

This commit is contained in:
Xavier J 2016-06-09 12:23:50 +02:00
parent e72487bb28
commit 3c75fb27c4
3 changed files with 14 additions and 6 deletions

View file

@ -58,10 +58,14 @@
.row.word.news .row.word.news
.latest_release.col-md-7.col-lg-7 .latest_release.col-md-7.col-lg-7
%h3.text-info - if @latest_release.nil?
= "Dernière version (#{@latest_release.tag_name} - #{@latest_release.published_at})" %p
.body Erreur dans la récupération des données
=@latest_release.body.html_safe -else
%h3.text-info
= "Dernière version (#{@latest_release.tag_name} - #{@latest_release.published_at})"
.body
=@latest_release.body.html_safe
.center .center
\- \-

View file

@ -12,7 +12,9 @@ class Github::API
def self.call(end_point, params = {}) def self.call(end_point, params = {})
RestClient::Resource.new( RestClient::Resource.new(
base_uri+end_point base_uri+end_point, timeout: 5
).get(params: params) ).get(params: params)
rescue RestClient::Forbidden
nil
end end
end end

View file

@ -2,8 +2,10 @@ class Github::Releases
def self.latest def self.latest
release = Hashie::Mash.new JSON.parse(Github::API.latest_release) release = Hashie::Mash.new JSON.parse(Github::API.latest_release)
release.published_at = release.published_at.to_date.strftime('%d/%m/%Y')
return nil if release.nil?
release.published_at = release.published_at.to_date.strftime('%d/%m/%Y')
release release
end end
end end