2009-11-09 18:03:02 -08:00
|
|
|
module Sass
|
|
|
|
module Plugin
|
2009-11-09 18:09:20 -08:00
|
|
|
# Rack middleware for compiling Sass code.
|
|
|
|
#
|
|
|
|
# ## Activate
|
|
|
|
#
|
|
|
|
# require 'sass/plugin/rack'
|
|
|
|
# use Sass::Plugin::Rack
|
|
|
|
#
|
|
|
|
# ## Customize
|
|
|
|
#
|
|
|
|
# Sass::Plugin.options.merge(
|
|
|
|
# :cache_location => './tmp/sass-cache',
|
|
|
|
# :never_update => environment != :production,
|
|
|
|
# :full_exception => environment != :production)
|
|
|
|
#
|
|
|
|
# {file:SASS_REFERENCE.md#options See the Reference for more options}.
|
|
|
|
#
|
|
|
|
# ## Use
|
|
|
|
#
|
|
|
|
# Put your Sass files in `public/stylesheets/sass`.
|
|
|
|
# Your CSS will be generated in `public/stylesheets`,
|
|
|
|
# and regenerated every request if necessary.
|
|
|
|
# The locations and frequency {file:SASS_REFERENCE.md#options can be customized}.
|
|
|
|
# That's all there is to it!
|
2009-11-09 18:03:02 -08:00
|
|
|
class Rack
|
2009-11-09 18:09:20 -08:00
|
|
|
# Initialize the middleware.
|
|
|
|
#
|
|
|
|
# @param app [#call] The Rack application
|
2009-11-09 18:03:02 -08:00
|
|
|
def initialize(app)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
2009-11-09 18:09:20 -08:00
|
|
|
# Process a request, checking the Sass stylesheets for changes
|
|
|
|
# and updating them if necessary.
|
|
|
|
#
|
|
|
|
# @param env The Rack request environment
|
2009-12-01 18:25:49 -08:00
|
|
|
# @return [(#to_i, {String => String}, Object)] The Rack response
|
2009-11-09 18:03:02 -08:00
|
|
|
def call(env)
|
|
|
|
Sass::Plugin.check_for_updates
|
|
|
|
@app.call(env)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-05-10 19:48:46 -07:00
|
|
|
|
|
|
|
require 'sass/plugin'
|