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 i = 0 processors = [] loop do src = types[i] dst = types[i+1] break unless src && dst 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] i += 1 end if processors.size > 1 compose_processors(*processors.reverse) elsif processors.size == 1 processors.first end end