module Sprockets::Rails::Helper

Public Instance Methods

asset_path(source, options = {}) click to toggle source
# File lib/sprockets_better_errors/sprockets_rails_helper.rb, line 44
def asset_path(source, options = {})
  check_errors_for(source)
  path_to_asset(source, options)
end
Also aliased as: orig_asset_path
check_dependencies!(dep) click to toggle source
# File lib/sprockets_better_errors/sprockets_rails_helper.rb, line 13
def check_dependencies!(dep)
  return unless Sprockets::Rails::Helper.raise_asset_errors
  return unless @_dependency_assets
  return if     @_dependency_assets.detect { |asset| asset.include?(dep) }
  raise DependencyError.new(self.pathname, dep)
end
compute_asset_path(path, options = {}) click to toggle source
# File lib/sprockets_better_errors/sprockets_rails_helper.rb, line 21
def compute_asset_path(path, options = {})
  check_dependencies!(path)
  orig_compute_asset_path(path, options)
end
Also aliased as: orig_compute_asset_path
javascript_include_tag(*args) click to toggle source
# File lib/sprockets_better_errors/sprockets_rails_helper.rb, line 50
def javascript_include_tag(*args)
  sources = args.dup
  sources.extract_options!
  sources.map do |source|
    check_errors_for(source)
  end
  orig_javascript_include_tag(*args)
end
Also aliased as: orig_javascript_include_tag
orig_asset_path(source, options = {})
Alias for: asset_path
orig_compute_asset_path(path, options = {})
Alias for: compute_asset_path
orig_javascript_include_tag(*args)

Protected Instance Methods

asset_needs_precompile?(source, filename) click to toggle source

Returns true when an asset will not available after precompile is run

# File lib/sprockets_better_errors/sprockets_rails_helper.rb, line 83
def asset_needs_precompile?(source, filename)
  return true  unless Sprockets::Rails::Helper.assets
  return false if Sprockets::Rails::Helper.assets.send(:matches_filter, Sprockets::Rails::Helper.precompile || [], source.to_s, filename)
  true
end
check_errors_for(source) click to toggle source

Raise errors when source does not exist or is not in the precomiled list

# File lib/sprockets_better_errors/sprockets_rails_helper.rb, line 71
def check_errors_for(source)
  return source unless Sprockets::Rails::Helper.raise_asset_errors
  return source if ["all", "defaults"].include?(source.to_s)
  return ""     if source.blank?
  return source if source =~ URI_REGEXP

  asset = lookup_asset_for_path(source)
  return if asset.blank?
  raise AssetFilteredError.new(source)   if asset_needs_precompile?(source, asset.pathname.to_s)
end