2013-02-20 04:16:50 +08:00
|
|
|
module DiscourseUpdates
|
|
|
|
|
|
|
|
class << self
|
|
|
|
|
|
|
|
def check_version
|
|
|
|
DiscourseVersionCheck.new(
|
|
|
|
latest_version: latest_version || Discourse::VERSION::STRING,
|
2013-02-22 02:26:30 +08:00
|
|
|
critical_updates: critical_update_available?,
|
2013-02-20 04:16:50 +08:00
|
|
|
installed_version: Discourse::VERSION::STRING,
|
2013-03-06 07:14:51 +08:00
|
|
|
installed_sha: (Discourse.git_version == 'unknown' ? nil : Discourse.git_version),
|
|
|
|
missing_versions_count: missing_versions_count || nil
|
2013-02-20 04:16:50 +08:00
|
|
|
# TODO: more info, like links and release messages
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def latest_version
|
|
|
|
$redis.get latest_version_key
|
|
|
|
end
|
|
|
|
|
2013-03-06 07:14:51 +08:00
|
|
|
def missing_versions_count
|
|
|
|
$redis.get(missing_versions_count_key).try(:to_i)
|
2013-02-20 04:16:50 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def critical_update_available?
|
|
|
|
($redis.get(critical_updates_available_key) || false) == 'true'
|
|
|
|
end
|
|
|
|
|
2013-03-06 07:14:51 +08: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-20 04:16:50 +08:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def latest_version_key
|
|
|
|
'discourse_latest_version'
|
|
|
|
end
|
|
|
|
|
|
|
|
def critical_updates_available_key
|
|
|
|
'critical_updates_available'
|
|
|
|
end
|
2013-03-06 07:14:51 +08:00
|
|
|
|
|
|
|
def missing_versions_count_key
|
|
|
|
'missing_versions_count'
|
|
|
|
end
|
2013-02-20 04:16:50 +08:00
|
|
|
end
|
|
|
|
end
|