class Potassium::NewestVersionEnsurer

Attributes

installed_version[RW]
published_version[RW]
text_spinner[RW]

Public Class Methods

new() click to toggle source
# File lib/potassium/newest_version_ensurer.rb, line 10
def initialize
  self.installed_version = Semantic::Version.new(Potassium::VERSION)
  self.text_spinner = Potassium::TextSpinner.new
end

Public Instance Methods

ensure!() click to toggle source
# File lib/potassium/newest_version_ensurer.rb, line 15
def ensure!
  spin_text('Checking your Potassium installation') { published_version }

  self.published_version = Semantic::Version.new(Gems.versions('potassium').first['number'])
  raise VersionError.new(update_message) if published_version > installed_version
end

Private Instance Methods

spin_text(message, &block) click to toggle source
# File lib/potassium/newest_version_ensurer.rb, line 34
def spin_text(message, &block)
  text_spinner.wait_condition = block
  text_spinner.base_message = message
  text_spinner.start
end
update_message() click to toggle source
# File lib/potassium/newest_version_ensurer.rb, line 26
    def update_message
      <<~HERE
        Your potassium installation is not up to date.
        The last available version is #{published_version} while the running version is #{installed_version}.
        If you really need to run this outdated version of potassium, re-run this command with the `--no-version-check` flag.
      HERE
    end