Sha256: b78d83e61a4debe0732ca665b47515c4a34ded97988804e472694503e78ff279
Contents?: true
Size: 957 Bytes
Versions: 4
Compression:
Stored size: 957 Bytes
Contents
require 'net/http' require 'json' require 'uri' module Spree module Admin class Updater SPREE_CLOUD_UPDATES_URL = 'https://spreecloud.io/updates.json' @updates = nil def self.update_available? fetch_updates.any? end def self.fetch_updates @updates ||= Rails.cache.fetch("spree/admin/updater/fetch_updates/#{Spree.version}", expires_in: 1.day) do uri = URI(SPREE_CLOUD_UPDATES_URL) params = { version: Spree.version } uri.query = URI.encode_www_form(params) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme == 'https' http.open_timeout = 1 # 1s timeout for opening the connection http.read_timeout = 1 # 1s timeout for reading the response response = http.get(uri) return {} unless response.is_a?(Net::HTTPSuccess) JSON.parse(response.body) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems