Module: MuxTf::VersionCheck

Defined in:
lib/mux_tf/version_check.rb

Class Method Summary collapse

Class Method Details

.cacheObject



24
25
26
# File 'lib/mux_tf/version_check.rb', line 24

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

.current_gem_versionObject



20
21
22
# File 'lib/mux_tf/version_check.rb', line 20

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

.has_updates?Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)


5
6
7
# File 'lib/mux_tf/version_check.rb', line 5

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

.latest_gem_versionObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/mux_tf/version_check.rb', line 9

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