class BooticCli::Themes::APIAsset
Constants
- REQUEST_OPTS
Public Instance Methods
==(other)
click to toggle source
Calls superclass method
BooticCli::Themes::ItemWithTime#==
# File lib/bootic_cli/themes/api_theme.rb, line 27 def ==(other) if digest.to_s == '' || other.digest.to_s == '' # puts "One or the other digest is empty: #{digest} -- #{other.digest}" return super end # file sizes may differ as they are served by CDN (that shrinks them) self.digest == other.digest # && self.file_size == other.file_size end
fetch_data(attempt = 1, skip_verify = false)
click to toggle source
# File lib/bootic_cli/themes/api_theme.rb, line 37 def fetch_data(attempt = 1, skip_verify = false) uri = URI.parse(rels[:file].href) opts = REQUEST_OPTS.merge({ verify_mode: skip_verify ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER, use_ssl: uri.port == 443 }) Net::HTTP.start(uri.host, uri.port, opts) do |http| resp = http.get(uri.path) raise "Invalid response: #{resp.code}" unless resp.code.to_i == 200 resp.body end rescue Net::OpenTimeout, Net::ReadTimeout => e raise if attempt > 3 # max attempts # puts "#{e.class} for #{File.basename(uri.path)}! Retrying request..." fetch_data(attempt + 1) rescue OpenSSL::SSL::SSLError => e # retry but skipping verification fetch_data(attempt + 1, true) end
file()
click to toggle source
# File lib/bootic_cli/themes/api_theme.rb, line 23 def file @file ||= StringIO.new(fetch_data) end