Sha256: 63106930cf41b0f9e042cfd073acf4297cb917f70313967ed1d5f51b9bf78725

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

module Qcmd
  VERSION = "0.1.16.pre"

  class << self
    def installed_version
      Gem.loaded_specs["qcmd"].version
    end

    def rubygems_uri
      @rubygems_uri ||= URI.parse("http://rubygems.org/api/v1/gems/qcmd.json")
    end

    def available_version
      @available_version ||= begin
                              require "net/http"
                              require "uri"

                              begin
                                # Shortcut
                                response = Net::HTTP.get_response(rubygems_uri)
                              rescue => ex
                                Qcmd.debug "error loading #{ rubygems_uri }"
                                Qcmd.debug "couldn't load remote qcmd version: #{ ex.message }"
                                return false
                              end

                              begin
                                JSON.parse(response.body)['version']
                              rescue => ex
                                Qcmd.debug "error parsing #{ rubygems_uri }"
                                Qcmd.debug "couldn't parse remote qcmd version: #{ ex.message }"
                                false
                              end
                             end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qcmd-0.1.16.pre lib/qcmd/version.rb