class Sprockets::DirectiveProcessor
def compile_header_pattern(comments)
Directives in comments after the first non-whitespace line
Ruby (#) comments are supported.
of the source file. C style (/* */), JavaScript (//), and
Directives will only be picked up if they are in the header
def compile_header_pattern(comments) re = comments.map { |c| case c when String "(?:#{Regexp.escape(c)}.*\\n?)+" when Array "(?:#{Regexp.escape(c[0])}(?m:.*?)#{Regexp.escape(c[1])})" else raise TypeError, "unknown comment type: #{c.class}" end }.join("|") Regexp.compile("\\A(?:(?m:\\s*)(?:#{re}))+") end