Class Juicer::Asset::PathResolver
In: lib/juicer/asset/path_resolver.rb
Parent: Object

Factory class that creates Juicer::Asset::Path objects from a common set of options. Also facilitates asset host cycling on a set of asset paths.

  path_resolver = Juicer::Asset::PathResolver.new(
                    :document_root => "/var/www",
                    :hosts => ["assets1.mysite.com", "assets2.mysite.com"]
                  )

  asset = path_resolver.resolve("../images/logo.png")
  asset.document_root
  #=> "/var/www"

  asset.absolute_path(path_resolver.cycle_hosts)
  #=> "http://assets1.mysite.com/images/logo.png"

  asset = path_resolver.resolve("/favicon.ico")
  asset.absolute_path(path_resolver.cycle_hosts)
  #=> "http://assets2.mysite.com/favicon.ico"
Author:Christian Johansen (christian@cjohansen.no)
Copyright:Copyright (c) 2009 Christian Johansen
License:BSD

Methods

base=   cycle_hosts   host   new   resolve  

Attributes

base  [R] 
document_root  [R] 
hosts  [R] 

Public Class methods

Initialize resolver. All options set on the resolver will be carried on to the resolved assets.

Public Instance methods

Set new base directory. Will affect any assets resolved from here, but any assets previously resolved will not be changed

Cycle asset hosts. Returns an asset host

host()

Alias for cycle_hosts

Returns a Juicer::Asset::Path object for the given path, and the options set on the resolver.

[Validate]