2013-02-19 14:16:50 -06:00
|
|
|
module DiscourseUpdates
|
|
|
|
|
|
|
|
class << self
|
|
|
|
|
|
|
|
def check_version
|
|
|
|
DiscourseVersionCheck.new(
|
|
|
|
latest_version: latest_version || Discourse::VERSION::STRING,
|
2013-02-21 12:26:30 -06:00
|
|
|
critical_updates: critical_update_available?,
|
2013-02-19 14:16:50 -06:00
|
|
|
installed_version: Discourse::VERSION::STRING,
|
2013-03-05 17:14:51 -06:00
|
|
|
installed_sha: (Discourse.git_version == 'unknown' ? nil : Discourse.git_version),
|
|
|
|
missing_versions_count: missing_versions_count || nil
|
2013-02-19 14:16:50 -06:00
|
|
|
# TODO: more info, like links and release messages
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def latest_version
|
|
|
|
$redis.get latest_version_key
|
|
|
|
end
|
|
|
|
|
2013-03-05 17:14:51 -06:00
|
|
|
def missing_versions_count
|
|
|
|
$redis.get(missing_versions_count_key).try(:to_i)
|
2013-02-19 14:16:50 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def critical_update_available?
|
|
|
|
($redis.get(critical_updates_available_key) || false) == 'true'
|
|
|
|
end
|
|
|
|
|
2013-03-05 17:14:51 -06:00
|
|
|
['latest_version', 'missing_versions_count', 'critical_update_available'].each do |name|
|
|
|
|
eval "define_method :#{name}= do |arg|
|
|
|
|
$redis.set #{name}_key, arg
|
|
|
|
end"
|
|
|
|
end
|
|
|
|
|
2013-02-19 14:16:50 -06:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def latest_version_key
|
|
|
|
'discourse_latest_version'
|
|
|
|
end
|
|
|
|
|
|
|
|
def critical_updates_available_key
|
|
|
|
'critical_updates_available'
|
|
|
|
end
|
2013-03-05 17:14:51 -06:00
|
|
|
|
|
|
|
def missing_versions_count_key
|
|
|
|
'missing_versions_count'
|
|
|
|
end
|
2013-02-19 14:16:50 -06:00
|
|
|
end
|
|
|
|
end
|