class RailsExternalAssetPipeline::Manifest

Public Class Methods

new(manifests_path, type) click to toggle source
# File lib/rails_external_asset_pipeline/manifest.rb, line 3
def initialize(manifests_path, type)
  @manifests_path = manifests_path
  @type = type
end

Public Instance Methods

fetch(asset_name) click to toggle source
# File lib/rails_external_asset_pipeline/manifest.rb, line 8
def fetch(asset_name)
  parsed_manifest.fetch(asset_name)
rescue KeyError
  raise "The asset '#{asset_name}' of type '#{@type}' was not in the manifest"
end

Private Instance Methods

full_manifest_path() click to toggle source
# File lib/rails_external_asset_pipeline/manifest.rb, line 28
def full_manifest_path
  File.join(Rails.root, manifest_path)
end
manifest_path() click to toggle source
# File lib/rails_external_asset_pipeline/manifest.rb, line 32
def manifest_path
  File.join(@manifests_path, "#{@type}.json")
end
parsed_manifest() click to toggle source
# File lib/rails_external_asset_pipeline/manifest.rb, line 16
def parsed_manifest
  JSON.parse(unparsed_manifest)
rescue JSON::ParserError
  raise "The manifest file '#{manifest_path}' is invalid JSON"
end
unparsed_manifest() click to toggle source
# File lib/rails_external_asset_pipeline/manifest.rb, line 22
def unparsed_manifest
  File.read(full_manifest_path)
rescue Errno::ENOENT
  raise "The manifest file '#{manifest_path}' is missing"
end