Module: Muxi::VersionCheck

Defined in:
lib/muxi/version_check.rb

Constant Summary collapse

SDK_NAME =
"ruby"
CACHE_FILE =
File.join(Dir.home, ".muxi", "sdk-versions.json")
TWELVE_HOURS =
12 * 60 * 60

Class Method Summary collapse

Class Method Details

.check_for_updates(headers) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/muxi/version_check.rb', line 15

def check_for_updates(headers)
  return if @checked
  @checked = true

  return if ENV["MUXI_SDK_VERSION_NOTIFICATION"] == "0"

  latest = headers["X-Muxi-SDK-Latest"] || headers["x-muxi-sdk-latest"]
  return unless latest

  return unless newer_version?(latest, VERSION)

  update_latest_version(latest)

  unless notified_recently?
    puts "[muxi] SDK update available: #{latest} (current: #{VERSION})"
    puts "[muxi] Run: gem update muxi"
    mark_notified
  end
end