class Roadie::PathRewriterProvider

]
Roadie::NetHttpProvider.new
# Any other asset should be downloaded like normal
},
uri.path if uri.host == “myapp.com”
uri = URI.parse(url)
Roadie::PathRewriterProvider.new(document.asset_providers) { |url|
# Look for assets from “myapp.com” just like if we just specified a local path
document.external_asset_providers = [
@example Handling “external” app assets as local assets
}
path =~ /email/ ? path : nil
only_email_provider = Roadie::PathRewriterProvider.new(other_provider) { |path|
# Only assets containing “email” in the path will be considered by other_provider
@example Filtering assets
}
+.css$/, ‘.css’)
provider = Roadie::PathRewriterProvider.new(other_provider) { |path|
@example Simple regex
use this provider as a filter only.
invoked and it will be treated as “not found”. This makes it possible to
If the block returns {nil} or {false}, the upstream provider will not be
on to the “upstream” provider (or {ProviderList}).
is that a path is sent in to this provider, maybe modified and then passed
There might be other useful things you could use it for. The basic premise
* Skipping known-bad paths.
* Handle query string logic.
* Removing digests from filenames.
* Changing path structure of filenames.
* Convert between external DNS name into internal naming.
* Convert absolute URLs into local filesystem paths.
you to make changes to the requested path. Some uses of this include:
This provider acts a bit like a pipeline in normal UNIX parlour by enabling
@api public

def find_stylesheet(path)

def find_stylesheet(path)
  new_path = filter.call(path)
  provider.find_stylesheet(new_path) if new_path
end

def find_stylesheet!(path)

def find_stylesheet!(path)
  new_path = filter.call(path)
  if new_path
    provider.find_stylesheet!(new_path)
  else
    raise CssNotFound.new(
      css_name: path,
      message: "Filter returned #{new_path.inspect}"
    )
  end
end

def initialize(provider, &filter)

def initialize(provider, &filter)
  @provider = provider
  @filter = filter
end