Class: WildayUi::VersionCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/wilday_ui/version_check.rb

Class Method Summary collapse

Class Method Details

.check_for_updateObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/wilday_ui/version_check.rb', line 7

def self.check_for_update
  return unless Rails.env.development?

  current_version = Gem.loaded_specs["wilday_ui"]&.version&.to_s || WildayUi::VERSION
  latest_version = fetch_latest_version

  if latest_version && Gem::Version.new(latest_version) > Gem::Version.new(current_version)
    puts "\n\e[33m[Wilday UI] Update available!"
    puts "You are using version #{current_version}, but the latest version is #{latest_version}."
    puts "To update, run: `bundle update wilday_ui` or update your Gemfile to the latest version\e[0m\n"
    Rails.logger.warn "      [Wilday UI] You are using version \#{current_version}, but the latest version is \#{latest_version}.\n      To update, run `bundle update wilday_ui` or update your Gemfile to the latest version.\n    WARNING\n  end\nend\n"