class Locomotive::Steam::ThemeAssetUrlService

Public Instance Methods

build(path) click to toggle source
# File lib/locomotive/steam/services/theme_asset_url_service.rb, line 8
def build(path)
  # keep the query string safe
  path.gsub!(/(\?+.+)$/, '')
  query_string = $1

  # build the url of the theme asset based on the persistence layer
  _url = repository.url_for(path)

  # get a timestamp only if the source url doesn't include a query string
  timestamp = query_string.blank? ? checksums[path] : nil

  # prefix by a asset host if given
  url = asset_host ? asset_host.compute(_url, timestamp) : _url

  query_string ? "#{url}#{query_string}" : url
end
checksum?() click to toggle source
# File lib/locomotive/steam/services/theme_asset_url_service.rb, line 33
def checksum?
  !!checksum
end
checksums() click to toggle source
# File lib/locomotive/steam/services/theme_asset_url_service.rb, line 25
def checksums
  if checksum?
    @checksums ||= fetch_checksums
  else
    {}
  end
end

Private Instance Methods

fetch_checksums() click to toggle source
# File lib/locomotive/steam/services/theme_asset_url_service.rb, line 39
def fetch_checksums
  repository.checksums
end