Change place lib repository
This commit is contained in:
parent
27cc62ea1e
commit
1a3e23c6ef
21 changed files with 0 additions and 0 deletions
20
app/lib/github/api.rb
Normal file
20
app/lib/github/api.rb
Normal 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
|
11
app/lib/github/releases.rb
Normal file
11
app/lib/github/releases.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue