Sha256: f94f9192d07569fcf879f9c123da8c62f8b4ed3d9291bfe955869646b0117a32

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require "json"
require "net/http"
require "logger"

module Rf
  module Stylez
    # Check for updates to rf-stylez
    module UpdateCheck
      RUBYGEMS_URL = URI("https://rubygems.org/api/v1/gems/rf-stylez.json").freeze

      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
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rf-stylez-1.2.5 lib/rf/stylez/update_check.rb
rf-stylez-1.2.4 lib/rf/stylez/update_check.rb
rf-stylez-1.2.3 lib/rf/stylez/update_check.rb
rf-stylez-1.2.1 lib/rf/stylez/update_check.rb
rf-stylez-1.1.2 lib/rf/stylez/update_check.rb
rf-stylez-1.1.1 lib/rf/stylez/update_check.rb
rf-stylez-1.1.0 lib/rf/stylez/update_check.rb