Module: Rbcli::Autoupdate::Common

Included in:
GemUpdater, GithubUpdater
Defined in:
lib/rbcli/autoupdate/autoupdate.rb

Instance Method Summary collapse

Instance Method Details

#get_latest_version ⇒ Object



40
41
42
# File 'lib/rbcli/autoupdate/autoupdate.rb', line 40

def get_latest_version
  raise Exception.new "Autoupdater type #{self.class.name} must define a 'check_for_updates' method."
end

#show_message ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/rbcli/autoupdate/autoupdate.rb', line 53

def show_message
  puts "WARNING: An update is available to #{Rbcli::Configurate::configuration[:scriptname]}. You are currently running version #{Rbcli.configuration[:version]}; the latest is #{@latest_version || get_latest_version}."
  puts @message || update_message
  puts "\n"
  if @force_update
    puts "This application requires that you update to the latest version to continue using it. It will now exit."
    exit 0
  end
end

#update_available? ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/rbcli/autoupdate/autoupdate.rb', line 48

def update_available?
  @latest_version = get_latest_version
  Gem::Version.new(@latest_version) > Gem::Version.new(Rbcli.configuration[:version])
end

#update_message ⇒ Object



44
45
46
# File 'lib/rbcli/autoupdate/autoupdate.rb', line 44

def update_message
  raise Exception.new "Autoupdater type #{self.class.name} must define an 'update_message' method."
end