class RailsExternalAssets::AssetFinder

Public Class Methods

asset_manifest() click to toggle source
# File lib/rails_external_assets/asset_finder.rb, line 18
def asset_manifest
  return @@manifest_file if @@manifest_file && RailsExternalAssets.config.cache_manifest
  manifest_file = RailsExternalAssets.config.manifest_file
  throw_invalid_manifest(manifest_file) unless File.file? manifest_file
  @@manifest_file = JSON.parse(File.read manifest_file)
end
asset_path(path) click to toggle source
# File lib/rails_external_assets/asset_finder.rb, line 12
def asset_path(path)
  new_path = asset_manifest[path]
  throw_unknown_path(path, RailsExternalAssets.config.manifest_file) unless new_path
  new_path
end
clear_manifest_cache() click to toggle source
# File lib/rails_external_assets/asset_finder.rb, line 25
def clear_manifest_cache
  @@manifest_file = nil
end
external_asset(path) { |external_path| ... } click to toggle source
# File lib/rails_external_assets/asset_finder.rb, line 7
def external_asset(path)
  external_path = File.join(RailsExternalAssets.config.base_path, asset_path(path))
  block_given? ? yield(external_path) : external_path
end

Private Class Methods

throw_invalid_manifest(manifest_file) click to toggle source
# File lib/rails_external_assets/asset_finder.rb, line 35
def throw_invalid_manifest(manifest_file)
    raise Errors::InvalidManifestFile.new("Manifest file, \"#{manifest_file}\", was not found.")
end
throw_unknown_path(path, manifest_file) click to toggle source
# File lib/rails_external_assets/asset_finder.rb, line 31
def throw_unknown_path(path, manifest_file)
    raise Errors::UnknownAssetManifestKey.new("No corresponding file found for \"#{path}\" in \"#{manifest_file}\".")
end