I'm trying to create a sprockets preprocessor for Rails that finds .png.rb
files in the asset pipeline and uses them to generate png screenshots of various pages in my application.
I've read up on this topic quite a bit but I can't seem to find any straightforward documentation on how to get this set up. Help, please?
Here's what I have so far:
/initializers/sprockets.rb
:
require 'screenshot_preprocessor'
Rails.application.assets.register_mime_type('screenshot/png', '.png.rb')
Rails.application.assets.register_preprocessor('screenshot/png', ScreenshotPreprocessor)
/lib/screenshot_preprocessor.rb:
class ScreenshotPreprocessor
# What API do I need to provide here?
# - What methods do I need to provide?
# - What parameters does Sprockets pass me?
# - What do I need to return to Sprockets?
end