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 = DockerSyncConfig::global_config end |
Class Method Details
.get_current_version ⇒ Object
34 35 36 37 |
# File 'lib/docker-sync/upgrade_check.rb', line 34 def self.get_current_version path = File.('../../../', __FILE__) return File.read("#{path}/VERSION") end |
Instance Method Details
#check_and_warn ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/docker-sync/upgrade_check.rb', line 46 def check_and_warn # this is the upgrade hook for the unison-unox introduction / rename of unison if Gem::Version.new(last_upgraded_version) < Gem::Version.new('0.1.0') Thor::Shell::Basic.new.say_status 'warning', 'Please be aware that with the strategy "unison" is now called unison-onesided and you might need to migrate. See https://github.com/EugenMayer/docker-sync/wiki/Migration-Guide for more informations', :red unless Thor::Shell::Basic.new.yes?('Shall we continue? (y/N)') exit 1 end end if Gem::Version.new(last_upgraded_version) < Gem::Version.new('0.2.0') Thor::Shell::Basic.new.say_status 'warning', "A lot changed with 0.2.x! Unison is the default sync, unison-onesided has been REMOVED. If you have been using rsync, have been using unison excludes or you are not sure, please read the upgrade guide or your setup will go lala! : \n\n_Please_ read :): https://github.com/EugenMayer/docker-sync/wiki/1.2-Upgrade-Guide\n\n", :red unless Thor::Shell::Basic.new.yes?('Shall we continue - DID you read it? (y/N)') exit 1 end end # update the upgrade_status @config['upgrade_status'] = "#{UpgradeChecker.get_current_version}" DockerSyncConfig::global_config_save(@config) end |
#docker_sync_update_check ⇒ Object
39 40 41 42 43 44 |
# File 'lib/docker-sync/upgrade_check.rb', line 39 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
19 20 21 |
# File 'lib/docker-sync/upgrade_check.rb', line 19 def last_upgraded_version @config['upgrade_status'] || '' end |
#run ⇒ Object
12 13 14 15 16 17 |
# File 'lib/docker-sync/upgrade_check.rb', line 12 def run unless should_run return end check_and_warn end |
#should_run ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/docker-sync/upgrade_check.rb', line 23 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 == '' || Gem::Version.new(upgrade_status) < Gem::Version.new(UpgradeChecker.get_current_version) # thats how we compare the version return true end return false end |