technekes/nib

View on GitHub
lib/nib/check_for_update.rb

Summary

Maintainability
A
0 mins
Test Coverage
B
80%
require 'net/http'

class Nib::CheckForUpdate
  def self.execute(_, _)
    return if installed == latest

    puts <<-MESSAGE.strip_heredoc

      An update is available for nib: #{latest}
      Use 'nib update' to install the latest version
    MESSAGE
  end

  def self.installed
    Nib::VERSION
  end

  def self.latest
    url = 'https://raw.githubusercontent.com/technekes/nib/master/VERSION'

    Net::HTTP.get(URI.parse(url))
  end
end