1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/lib/version.rb
2020-01-14 14:33:00 +01:00

27 lines
690 B
Ruby

# frozen_string_literal: true
# retrieve the current Fab-manager version
class Version
def self.current
package = File.read('package.json')
JSON.parse(package)['version']
end
def self.up_to_date?
hub_version = Setting.find_by(name: 'hub_last_version')&.value
return unless hub_version
json = JSON.parse(hub_version)
json['status']
end
def self.check_and_schedule
VersionCheckWorker.perform_async
# every sunday at 1:15am
m = DateTime.current.minute
h = DateTime.current.hour
d = DateTime.current.cwday
Sidekiq::Cron::Job.create(name: 'Automatic version check', cron: "#{m} #{h} * * #{d}", class: 'VersionCheckWorker')
end
end