Class: Spree::Admin::Updater

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/admin/updater.rb

Constant Summary collapse

SPREE_CLOUD_UPDATES_URL =
'https://spreecloud.io/updates.json'.freeze

Class Method Summary collapse

Class Method Details

.current_releaseObject



19
20
21
# File 'app/models/spree/admin/updater.rb', line 19

def current_release
  Spree.version
end

.fetch_updatesArray<Hash>

Returns the releases newer than the running version, fetched from spreecloud.io and cached for a day. The request carries only the running version, Rails.env, the storefront URL and the anonymous Spree.install_id. Failures are cached as an empty list too, so an unreachable endpoint costs at most one timed-out request per day.

Returns:

  • (Array<Hash>)

    newer releases, newest first



30
31
32
33
34
# File 'app/models/spree/admin/updater.rb', line 30

def fetch_updates
  Rails.cache.fetch("spree/admin/updater/fetch_updates/#{current_release}", expires_in: 1.day) do
    fetch_updates_from_spree_cloud
  end
end

.latest_releaseObject



15
16
17
# File 'app/models/spree/admin/updater.rb', line 15

def latest_release
  fetch_updates.first
end

.update_available?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/models/spree/admin/updater.rb', line 11

def update_available?
  fetch_updates.any?
end