PageRenderTime 28ms CodeModel.GetById 18ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/scalate-jruby/src/main/resources/haml-3.0.25/lib/sass/tree/warn_node.rb

http://github.com/scalate/scalate
Ruby | 42 lines | 30 code | 3 blank | 9 comment | 1 complexity | b3eb89e13d2f71b697dd0d365a083cbb MD5 | raw file
 1module Sass
 2  module Tree
 3    # A dynamic node representing a Sass `@warn` statement.
 4    #
 5    # @see Sass::Tree
 6    class WarnNode < Node
 7      # @param expr [Script::Node] The expression to print
 8      def initialize(expr)
 9        @expr = expr
10        super()
11      end
12
13      protected
14
15      # @see Node#to_src
16      def to_src(tabs, opts, fmt)
17        "#{'  ' * tabs}@warn #{@expr.to_sass(opts)}#{semi fmt}\n"
18      end
19
20      # Prints the expression to STDERR with a stylesheet trace.
21      #
22      # @param environment [Sass::Environment] The lexical environment containing
23      #   variable and mixin values
24      def _perform(environment)
25        environment.push_frame(:filename => filename, :line => line)
26        res = @expr.perform(environment)
27        res = res.value if res.is_a?(Sass::Script::String)
28        msg = "WARNING: #{res}\n"
29        environment.stack.reverse.each_with_index do |entry, i|
30          msg << "        #{i == 0 ? "on" : "from"} line #{entry[:line]}" <<
31            " of #{entry[:filename] || "an unknown file"}"
32          msg << ", in `#{entry[:mixin]}'" if entry[:mixin]
33          msg << "\n"
34        end
35        Haml::Util.haml_warn msg
36        []
37      ensure
38        environment.pop_frame
39      end
40    end
41  end
42end