PageRenderTime 23ms CodeModel.GetById 15ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/scalate-jruby/src/main/resources/haml-3.0.25/lib/sass/plugin/rack.rb

http://github.com/scalate/scalate
Ruby | 47 lines | 14 code | 2 blank | 31 comment | 0 complexity | b7b10db154dd7c16af28ad2f353b8371 MD5 | raw file
 1module Sass
 2  module Plugin
 3    # Rack middleware for compiling Sass code.
 4    #
 5    # ## Activate
 6    #
 7    #     require 'sass/plugin/rack'
 8    #     use Sass::Plugin::Rack
 9    #
10    # ## Customize
11    #
12    #     Sass::Plugin.options.merge(
13    #       :cache_location => './tmp/sass-cache',
14    #       :never_update => environment != :production,
15    #       :full_exception => environment != :production)
16    #
17    # {file:SASS_REFERENCE.md#options See the Reference for more options}.
18    #
19    # ## Use
20    #
21    # Put your Sass files in `public/stylesheets/sass`.
22    # Your CSS will be generated in `public/stylesheets`,
23    # and regenerated every request if necessary.
24    # The locations and frequency {file:SASS_REFERENCE.md#options can be customized}.
25    # That's all there is to it!
26    class Rack
27      # Initialize the middleware.
28      #
29      # @param app [#call] The Rack application
30      def initialize(app)
31        @app = app
32      end
33
34      # Process a request, checking the Sass stylesheets for changes
35      # and updating them if necessary.
36      #
37      # @param env The Rack request environment
38      # @return [(#to_i, {String => String}, Object)] The Rack response
39      def call(env)
40        Sass::Plugin.check_for_updates
41        @app.call(env)
42      end
43    end
44  end
45end
46
47require 'sass/plugin'