Method: AssetTrip::LoadPath#resolve

Defined in:
lib/asset_trip/load_path.rb

#resolve(file) ⇒ Object

TODO: Refactor

Raises:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/asset_trip/load_path.rb', line 20

def resolve(file)
  raise UnknownAssetError.new("Could not find #{file} in paths: #{@paths.inspect}") if file.nil?

  file_paths = @paths.map do |path|
    path.join(file).expand_path
  end

  result = file_paths.detect do |file_path|
    File.exist?(file_path)
  end

  if result
    return result
  else
    raise UnknownAssetError.new("Could not find #{file} in paths: #{@paths.inspect}")
  end
end