module Sprockets::Transformers
def compose_transformers(transformers, types)
types - Array of mime type steps
transformers - Two level Hash of a source mime type to a target mime type
function.
Internal: Compose multiple transformer steps into a single processor
def compose_transformers(transformers, types) if types.length < 2 raise ArgumentError, "too few transform types: #{types.inspect}" end processors = [] enum = types.each loop do src, dst = enum.next, enum.peek unless processor = transformers[src][dst] raise ArgumentError, "missing transformer for type: #{src} to #{dst}" end processors.concat config[:postprocessors][src] processors << processor processors.concat config[:preprocessors][dst] end if processors.size > 1 compose_processors(*processors.reverse) elsif processors.size == 1 processors.first end end