Module: Rf::Stylez::UpdateCheck

Defined in:
lib/rf/stylez/update_check.rb

Overview

Check for updates to rf-stylez

Constant Summary collapse

RUBYGEMS_URL =
URI("https://rubygems.org/api/v1/gems/rf-stylez.json").freeze

Class Method Summary collapse

Class Method Details

.checkObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rf/stylez/update_check.rb', line 13

def self.check
  logger = Logger.new($stdout)
  current_version = Gem::Version.new(VERSION)

  remote_version = Gem::Version.new(
    JSON.parse(Net::HTTP.get(RUBYGEMS_URL))["version"] # rubocop:disable Lint/NoJSON
  )
  if current_version >= remote_version
    logger.info("You are running latest rf-stylez ")
    logger.info("(•_•) ( •_•)>⌐■-■ (⌐■_■)")
  else
    logger.warn("RF Stylez is out of date!")
    logger.warn("Newest version is: #{remote_version}")
    logger.warn("You are running: #{current_version}")
    logger.warn("Please update: `gem update rf-stylez`")
  end
rescue SocketError
  logger.info("Offline, cannot check for rf-stylez updates")
end