Change place lib repository

This commit is contained in:
Xavier J 2016-12-02 17:03:52 +01:00
parent 27cc62ea1e
commit 1a3e23c6ef
21 changed files with 0 additions and 0 deletions

20
app/lib/github/api.rb Normal file
View file

@ -0,0 +1,20 @@
class Github::API
def self.base_uri
'https://api.github.com'
end
def self.latest_release
call '/repos/sgmap/tps/releases/latest'
end
private
def self.call(end_point, params = {})
RestClient::Resource.new(
base_uri+end_point, timeout: 5
).get(params: params)
rescue RestClient::Forbidden
nil
end
end

View file

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