mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 01:31:39 -05:00
23 lines
462 B
Ruby
23 lines
462 B
Ruby
# frozen_string_literal: true
|
|
|
|
class CheckAppVersion
|
|
VERSION_CACHE_KEY = 'dawarich/app-version-check'
|
|
|
|
def initialize
|
|
@repo_url = 'https://api.github.com/repos/Freika/dawarich/tags'
|
|
end
|
|
|
|
def call
|
|
latest_version != APP_VERSION
|
|
rescue StandardError
|
|
false
|
|
end
|
|
|
|
private
|
|
|
|
def latest_version
|
|
Rails.cache.fetch(VERSION_CACHE_KEY, expires_in: 6.hours) do
|
|
JSON.parse(Net::HTTP.get(URI.parse(@repo_url)))[0]['name']
|
|
end
|
|
end
|
|
end
|