Sha256: 429f932442d212048bdc71ebeb3b1dd238befdf51073c96258b753ad5ac7284b

Contents?: true

Size: 795 Bytes

Versions: 9

Compression:

Stored size: 795 Bytes

Contents

# frozen_string_literal: true

module MuxTf
  module VersionCheck
    def has_updates? # rubocop:disable Naming/PredicateName
      current_gem_version < latest_gem_version
    end

    def latest_gem_version
      value = cache.fetch("latest_gem_version") {
        fetcher = Gem::SpecFetcher.fetcher
        dependency = Gem::Dependency.new "mux_tf"
        remotes, = fetcher.search_for_dependency dependency
        remotes.map(&:first).map(&:version).max.to_s
      }

      Gem::Version.new(value)
    end

    def current_gem_version
      Gem::Version.new(MuxTf::VERSION)
    end

    def cache
      @cache ||= YamlCache.new(File.expand_path("~/.mux_tf.yaml"), default_ttl: 1.hour)
    end

    module_function :has_updates?, :latest_gem_version, :current_gem_version, :cache
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mux_tf-0.15.0 lib/mux_tf/version_check.rb
mux_tf-0.14.2 lib/mux_tf/version_check.rb
mux_tf-0.14.1 lib/mux_tf/version_check.rb
mux_tf-0.14.0 lib/mux_tf/version_check.rb
mux_tf-0.13.0 lib/mux_tf/version_check.rb
mux_tf-0.12.0 lib/mux_tf/version_check.rb
mux_tf-0.11.0 lib/mux_tf/version_check.rb
mux_tf-0.10.0 lib/mux_tf/version_check.rb
mux_tf-0.9.0 lib/mux_tf/version_check.rb