class Sprockets::DirectiveProcessor

def extract_directives(header)


[[1, "require", "foo"], [2, "require", "bar"]]

arguments.
directive name as the second element, followed by any
is an Array with the line number as the first element, the
Returns an Array of directive structures. Each structure
def extract_directives(header)
  processed_header = +""
  directives = []
  header.lines.each_with_index do |line, index|
    if directive = line[DIRECTIVE_PATTERN, 1]
      name, *args = Shellwords.shellwords(directive)
      if respond_to?("process_#{name}_directive", true)
        directives << [index + 1, name, *args]
        # Replace directive line with a clean break
        line = "\n"
      end
    end
    processed_header << line
  end
  processed_header.chomp!
  # Ensure header ends in a new line like before it was processed
  processed_header << "\n" if processed_header.length > 0 && header[-1] == "\n"
  return processed_header, directives
end