Class: UpgradeChecker
- Inherits:
-
Object
- Object
- UpgradeChecker
- Includes:
- Thor::Shell
- Defined in:
- lib/docker-sync/upgrade_check.rb
Class Method Summary collapse
Instance Method Summary collapse
- #check_and_warn ⇒ Object
- #docker_sync_update_check ⇒ Object
-
#initialize ⇒ UpgradeChecker
constructor
A new instance of UpgradeChecker.
- #last_upgraded_version ⇒ Object
- #run ⇒ Object
- #should_run ⇒ Object
Constructor Details
#initialize ⇒ UpgradeChecker
Returns a new instance of UpgradeChecker.
8 9 10 |
# File 'lib/docker-sync/upgrade_check.rb', line 8 def initialize @config = DockerSync::GlobalConfig.load end |
Class Method Details
.get_current_version ⇒ Object
40 41 42 43 44 45 |
# File 'lib/docker-sync/upgrade_check.rb', line 40 def self.get_current_version path = File.('../../../', __FILE__) version = File.read("#{path}/VERSION") version.strip version end |
Instance Method Details
#check_and_warn ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/docker-sync/upgrade_check.rb', line 54 def check_and_warn return if ENV['DOCKER_SYNC_SKIP_UPGRADE'] if Gem::Version.new(last_upgraded_version) < Gem::Version.new('0.5.6') Thor::Shell::Basic.new.say_status 'warning', "If you are upgrading from 0.5.4 or below, please run `brew update && brew upgrade unison` AND `docker-compose down && docker-sync clean` or `docker-sync-stack clean` since you need to recreate the sync container", :red unless Thor::Shell::Basic.new.yes?('Sync will fail otherwise. Continue? (y/N)') exit 1 end end if Gem::Version.new(last_upgraded_version) < Gem::Version.new('0.5.12') Thor::Shell::Basic.new.say_status 'warning', "0.5.12 uses a newer OCALM 4.08.1 version in the Unison image. If you use the unison strategy, please upgrade your local unison to be compiled against OCALM 4.08.1", :red unless Thor::Shell::Basic.new.yes?('Sync will fail otherwise. Continue? (y/N)') exit 1 end end # update the upgrade_status @config.update! 'upgrade_status' => "#{UpgradeChecker.get_current_version}" end |
#docker_sync_update_check ⇒ Object
47 48 49 50 51 52 |
# File 'lib/docker-sync/upgrade_check.rb', line 47 def docker_sync_update_check gem_name = 'docker-sync' current_version = UpgradeChecker.get_current_version checker = GemUpdateChecker::Client.new(gem_name, current_version) return checker end |
#last_upgraded_version ⇒ Object
20 21 22 |
# File 'lib/docker-sync/upgrade_check.rb', line 20 def last_upgraded_version @config['upgrade_status'] end |
#run ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/docker-sync/upgrade_check.rb', line 12 def run return if ENV['DOCKER_SYNC_SKIP_UPGRADE'] unless should_run return end check_and_warn end |
#should_run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/docker-sync/upgrade_check.rb', line 24 def should_run # get the update_status which is the version of the update hook which has been run already upgrade_status = last_upgraded_version if upgrade_status == '' @config.update! 'upgrade_status' => "#{UpgradeChecker.get_current_version}" return end if Gem::Version.new(upgrade_status) < Gem::Version.new(UpgradeChecker.get_current_version) # thats how we compare the version return true end return false end |