sprockets

https://github.com/rails/sprockets

Ruby

Rack-based asset packaging system

Sprockets::DirectiveProcessor#process_directives

Gathers comment directives in the source and processes them.
Any directive method matching `process_*_directive` will
automatically be available. This makes it easy to extend the
processor.

To implement a custom directive called `require_glob`, subclass
`Sprockets::DirectiveProcessor`, then add a method called
`process_require_glob_directive`.

    class DirectiveProcessor < Sprockets::DirectiveProcessor
      def process_require_glob_directive(glob)
        Dir["#{dirname}/#{glob}"].sort.each do |filename|
          require(filename)
        end
      end
    end

Replace the current processor on the environment with your own:

    env.unregister_processor('text/css', Sprockets::DirectiveProcessor)
    env.register_processor('text/css', DirectiveProcessor)

Source | Google | Stack overflow

Edit

git clone [email protected]:rails/sprockets.git

cd sprockets

open lib/sprockets/directive_processor.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Sprockets--DirectiveProcessor-process_directives-for-pr


# Commit to git

git add lib/sprockets/directive_processor.rbgit commit -m "better docs for Sprockets::DirectiveProcessor#process_directives"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Sprockets--DirectiveProcessor-process_directives-for-pr

hub pull-request


# Celebrate!