Module: Rbcli::Autoupdate::Common

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

Instance Method Summary collapse

Instance Method Details

#get_latest_versionObject



27
28
29
# File 'lib/rbcli/features/autoupdate/common/autoupdate.rb', line 27

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

#show_messageObject



40
41
42
43
44
45
46
47
48
# File 'lib/rbcli/features/autoupdate/common/autoupdate.rb', line 40

def show_message
  puts "WARNING: An update is available to #{Rbcli.configuration(:me, :scriptname)}. You are currently running version #{Rbcli.configuration(:me, :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:



35
36
37
38
# File 'lib/rbcli/features/autoupdate/common/autoupdate.rb', line 35

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

#update_messageObject



31
32
33
# File 'lib/rbcli/features/autoupdate/common/autoupdate.rb', line 31

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