haml-edge 2.3.197 → 2.3.198

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/EDGE_GEM_VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.197
1
+ 2.3.198
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.197
1
+ 2.3.198
data/lib/haml/exec.rb CHANGED
@@ -276,6 +276,9 @@ END
276
276
  'Output style. Can be nested (default), compact, compressed, or expanded.') do |name|
277
277
  @options[:for_engine][:style] = name.to_sym
278
278
  end
279
+ opts.on('-q', '--quiet', 'Silence warnings during compilation.') do
280
+ @options[:for_engine][:quiet] = true
281
+ end
279
282
  opts.on('-g', '--debug-info',
280
283
  'Emit extra information in the generated CSS that can be used by the FireSass Firebug plugin.') do
281
284
  @options[:for_engine][:debug_info] = true
data/lib/sass/engine.rb CHANGED
@@ -13,6 +13,7 @@ require 'sass/tree/if_node'
13
13
  require 'sass/tree/while_node'
14
14
  require 'sass/tree/for_node'
15
15
  require 'sass/tree/debug_node'
16
+ require 'sass/tree/warn_node'
16
17
  require 'sass/tree/import_node'
17
18
  require 'sass/environment'
18
19
  require 'sass/script'
@@ -164,9 +165,9 @@ module Sass
164
165
  # @return [String] The CSS
165
166
  # @raise [Sass::SyntaxError] if there's an error in the document
166
167
  def render
167
- to_tree.render
168
+ return _to_tree.render unless @options[:quiet]
169
+ Haml::Util.silence_haml_warnings {_to_tree.render}
168
170
  end
169
-
170
171
  alias_method :to_css, :render
171
172
 
172
173
  # Parses the document into its parse tree.
@@ -174,6 +175,13 @@ module Sass
174
175
  # @return [Sass::Tree::Node] The root of the parse tree.
175
176
  # @raise [Sass::SyntaxError] if there's an error in the document
176
177
  def to_tree
178
+ return _to_tree unless @options[:quiet]
179
+ Haml::Util.silence_haml_warnings {_to_tree}
180
+ end
181
+
182
+ private
183
+
184
+ def _to_tree
177
185
  @template = check_encoding(@template) {|msg, line| raise Sass::SyntaxError.new(msg, :line => line)}
178
186
 
179
187
  if @options[:syntax] == :scss
@@ -191,8 +199,6 @@ module Sass
191
199
  raise e
192
200
  end
193
201
 
194
- private
195
-
196
202
  def tabulate(string)
197
203
  tab_str = nil
198
204
  comment_tab_str = nil
@@ -488,6 +494,12 @@ WARNING
488
494
  :line => @line + 1) unless line.children.empty?
489
495
  offset = line.offset + line.text.index(value).to_i
490
496
  Tree::DebugNode.new(parse_script(value, :offset => offset))
497
+ elsif directive == "warn"
498
+ raise SyntaxError.new("Invalid warn directive '@warn': expected expression.") unless value
499
+ raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath warn directives.",
500
+ :line => @line + 1) unless line.children.empty?
501
+ offset = line.offset + line.text.index(value).to_i
502
+ Tree::WarnNode.new(parse_script(value, :offset => offset))
491
503
  else
492
504
  Tree::DirectiveNode.new(line.text)
493
505
  end
@@ -23,7 +23,7 @@ module Sass
23
23
  @vars = {}
24
24
  @mixins = {}
25
25
  @parent = parent
26
-
26
+ @stack = [] unless parent
27
27
  set_var("important", Script::String.new("!important")) unless @parent
28
28
  end
29
29
 
@@ -35,6 +35,52 @@ module Sass
35
35
  @options || (parent && parent.options) || {}
36
36
  end
37
37
 
38
+ # Push a new stack frame onto the mixin/include stack.
39
+ #
40
+ # @param frame_info [{Symbol => Object}]
41
+ # Frame information has the following keys:
42
+ #
43
+ # `:filename`
44
+ # : The name of the file in which the lexical scope changed.
45
+ #
46
+ # `:mixin`
47
+ # : The name of the mixin in which the lexical scope changed,
48
+ # or `nil` if it wasn't within in a mixin.
49
+ #
50
+ # `:line`
51
+ # : The line of the file on which the lexical scope changed. Never nil.
52
+ def push_frame(frame_info)
53
+ if stack.last && stack.last[:prepared]
54
+ stack.last.delete(:prepared)
55
+ stack.last.merge!(frame_info)
56
+ else
57
+ stack.push(frame_info)
58
+ end
59
+ end
60
+
61
+ # Like \{#push\_frame}, but next time a stack frame is pushed,
62
+ # it will be merged with this frame.
63
+ #
64
+ # @param frame_info [{Symbol => Object}] Same as for \{#push\_frame}.
65
+ def prepare_frame(frame_info)
66
+ push_frame(frame_info.merge(:prepared => true))
67
+ end
68
+
69
+ # Pop a stack frame from the mixin/include stack.
70
+ def pop_frame
71
+ stack.pop if stack.last[:prepared]
72
+ stack.pop
73
+ end
74
+
75
+ # A list of stack frames in the mixin/include stack.
76
+ # The last element in the list is the most deeply-nested frame.
77
+ #
78
+ # @return [Array<{Symbol => Object}>] The stack frames,
79
+ # of the form passed to \{#push}.
80
+ def stack
81
+ @stack ||= @parent.stack
82
+ end
83
+
38
84
  class << self
39
85
  private
40
86
 
data/lib/sass/files.rb CHANGED
@@ -76,8 +76,11 @@ module Sass
76
76
  return filename
77
77
  end
78
78
 
79
- new_filename = find_full_path("#{filename}.sass", load_paths) unless was_scss
80
- new_filename ||= find_full_path("#{filename}.scss", load_paths) unless was_sass
79
+ new_filename = nil
80
+ load_paths.each do |load_path|
81
+ new_filename ||= find_full_path("#{filename}.sass", load_path) unless was_scss
82
+ new_filename ||= find_full_path("#{filename}.scss", load_path) unless was_sass
83
+ end
81
84
 
82
85
  return new_filename if new_filename
83
86
  unless was_sass || was_scss
@@ -134,7 +137,7 @@ END
134
137
  end
135
138
  end
136
139
 
137
- def find_full_path(filename, load_paths)
140
+ def find_full_path(filename, load_path)
138
141
  partial_name = File.join(File.dirname(filename), "_#{File.basename(filename)}")
139
142
 
140
143
  if Pathname.new(filename).absolute?
@@ -144,13 +147,9 @@ END
144
147
  return nil
145
148
  end
146
149
 
147
- load_paths.each do |path|
148
- [partial_name, filename].each do |name|
149
- full_path = File.join(path, name)
150
- if File.readable?(full_path)
151
- return full_path
152
- end
153
- end
150
+ [partial_name, filename].each do |name|
151
+ full_path = File.join(load_path, name)
152
+ return full_path if File.readable?(full_path)
154
153
  end
155
154
  nil
156
155
  end
@@ -14,6 +14,7 @@ unless defined?(Sass::MERB_LOADED)
14
14
  :css_location => root + '/public/stylesheets',
15
15
  :cache_location => root + '/tmp/sass-cache',
16
16
  :always_check => env != "production",
17
+ :quiet => env != "production",
17
18
  :full_exception => env != "production")
18
19
  config = Merb::Plugins.config[:sass] || Merb::Plugins.config["sass"] || {}
19
20
 
@@ -5,6 +5,7 @@ unless defined?(Sass::RAILS_LOADED)
5
5
  :css_location => Haml::Util.rails_root + '/public/stylesheets',
6
6
  :cache_location => Haml::Util.rails_root + '/tmp/sass-cache',
7
7
  :always_check => Haml::Util.rails_env != "production",
8
+ :quiet => Haml::Util.rails_env != "production",
8
9
  :full_exception => Haml::Util.rails_env != "production")
9
10
 
10
11
  if defined?(Rails.configuration) && defined?(Rails.configuration.middleware)
@@ -105,6 +105,20 @@ module Sass::Script
105
105
  # \{#abs}
106
106
  # : Returns the absolute value of a number.
107
107
  #
108
+ # ## Introspection Functions
109
+ #
110
+ # \{#type_of}
111
+ # : Returns the type of a value.
112
+ #
113
+ # \{#unit}
114
+ # : Returns the units associated with a number.
115
+ #
116
+ # \{#unitless}
117
+ # : Returns whether a number has units or not.
118
+ #
119
+ # \{#comparable}
120
+ # : Returns whether two numbers can be added or compared.
121
+ #
108
122
  # These functions are described in more detail below.
109
123
  #
110
124
  # ## Adding Custom Functions
@@ -669,6 +683,71 @@ module Sass::Script
669
683
  Sass::Script::String.new(str.value, :string)
670
684
  end
671
685
 
686
+ # Inspects the type of the argument, returning it as an unquoted string.
687
+ # For example:
688
+ #
689
+ # type-of(100px) => number
690
+ # type-of(asdf) => string
691
+ # type-of("asdf") => string
692
+ # type-of(true) => bool
693
+ # type-of(#fff) => color
694
+ # type-of(blue) => color
695
+ #
696
+ # @param obj [Literal] The object to inspect
697
+ # @return [String] The unquoted string name of the literal's type
698
+ def type_of(obj)
699
+ Sass::Script::String.new(obj.class.name.gsub(/Sass::Script::/,'').downcase)
700
+ end
701
+
702
+ # Inspects the unit of the number, returning it as a quoted string.
703
+ # Complex units are sorted in alphabetical order by numerator and denominator.
704
+ # For example:
705
+ #
706
+ # unit(100) => ""
707
+ # unit(100px) => "px"
708
+ # unit(3em) => "em"
709
+ # unit(10px * 5em) => "em*px"
710
+ # unit(10px * 5em / 30cm / 1rem) => "em*px/cm*rem"
711
+ #
712
+ # @param number [Literal] The number to inspect
713
+ # @return [String] The unit(s) of the number
714
+ # @raise [ArgumentError] if `number` isn't a number
715
+ def unit(number)
716
+ assert_type number, :Number
717
+ Sass::Script::String.new(number.unit_str, :string)
718
+ end
719
+
720
+ # Inspects the unit of the number, returning a boolean indicating if it is unitless.
721
+ # For example:
722
+ #
723
+ # unitless(100) => true
724
+ # unitless(100px) => false
725
+ #
726
+ # @param number [Literal] The number to inspect
727
+ # @return [Bool] Whether or not the number is unitless
728
+ # @raise [ArgumentError] if `number` isn't a number
729
+ def unitless(number)
730
+ assert_type number, :Number
731
+ Sass::Script::Bool.new(number.unitless?)
732
+ end
733
+
734
+ # Returns true if two numbers are similar enough to be added, subtracted, or compared.
735
+ # For example:
736
+ #
737
+ # comparable(2px, 1px) => true
738
+ # comparable(100px, 3em) => false
739
+ # comparable(10cm, 3mm) => true
740
+ #
741
+ # @param number1 [Number]
742
+ # @param number2 [Number]
743
+ # @return [Bool] indicating if the numbers can be compared.
744
+ # @raise [ArgumentError] if `number1` or `number2` aren't numbers
745
+ def comparable(number1, number2)
746
+ assert_type number1, :Number
747
+ assert_type number2, :Number
748
+ Sass::Script::Bool.new(number1.comparable_to?(number2))
749
+ end
750
+
672
751
  # Converts a decimal number to a percentage.
673
752
  # For example:
674
753
  #
@@ -299,6 +299,30 @@ module Sass::Script
299
299
  end, num_units, den_units)
300
300
  end
301
301
 
302
+ # @param other [Number] A number to decide if it can be compared with this number.
303
+ # @return [Boolean] Whether or not this number can be compared with the other.
304
+ def comparable_to?(other)
305
+ begin
306
+ self.operate(other, :+)
307
+ true
308
+ rescue Sass::UnitConversionError
309
+ false
310
+ end
311
+ end
312
+
313
+ # Returns a human readable representation of the units in this number.
314
+ # For complex units this takes the form of:
315
+ # numerator_unit1 * numerator_unit2 / denominator_unit1 * denominator_unit2
316
+ # @return [String] a string that represents the units in this number
317
+ def unit_str
318
+ rv = numerator_units.sort.join("*")
319
+ if denominator_units.any?
320
+ rv << "/"
321
+ rv << denominator_units.sort.join("*")
322
+ end
323
+ rv
324
+ end
325
+
302
326
  protected
303
327
 
304
328
  def operate(other, operation)
@@ -343,15 +367,6 @@ module Sass::Script
343
367
  end
344
368
  end
345
369
 
346
- def unit_str
347
- rv = numerator_units.join("*")
348
- if denominator_units.any?
349
- rv << "/"
350
- rv << denominator_units.join("*")
351
- end
352
- rv
353
- end
354
-
355
370
  def normalize!
356
371
  return if unitless?
357
372
  @numerator_units, @denominator_units = sans_common_units(numerator_units, denominator_units)
@@ -77,7 +77,7 @@ module Sass
77
77
  node << comment
78
78
  end
79
79
 
80
- DIRECTIVES = Set[:mixin, :include, :debug, :for, :while, :if, :import, :media]
80
+ DIRECTIVES = Set[:mixin, :include, :debug, :warn, :for, :while, :if, :import, :media]
81
81
 
82
82
  def directive
83
83
  return unless tok(/@/)
@@ -127,6 +127,10 @@ module Sass
127
127
  node(Sass::Tree::DebugNode.new(sass_script(:parse)))
128
128
  end
129
129
 
130
+ def warn
131
+ node(Sass::Tree::WarnNode.new(sass_script(:parse)))
132
+ end
133
+
130
134
  def for
131
135
  tok!(/\$/)
132
136
  var = tok! IDENT
@@ -13,7 +13,7 @@ module Sass
13
13
  protected
14
14
 
15
15
  def to_src(tabs, opts, fmt)
16
- "#{' ' * tabs}@debug #{@expr.to_sass}#{semi fmt}\n"
16
+ "#{' ' * tabs}@debug #{@expr.to_sass(opts)}#{semi fmt}\n"
17
17
  end
18
18
 
19
19
  # Prints the expression to STDERR.
@@ -62,6 +62,7 @@ module Sass
62
62
  # @param environment [Sass::Environment] The lexical environment containing
63
63
  # variable and mixin values
64
64
  def perform!(environment)
65
+ environment.push_frame(:filename => @filename, :line => @line)
65
66
  root = Sass::Files.tree_for(full_filename, @options)
66
67
  @template = root.template
67
68
  self.children = root.children
@@ -70,6 +71,8 @@ module Sass
70
71
  e.modify_backtrace(:filename => full_filename)
71
72
  e.add_backtrace(:filename => @filename, :line => @line)
72
73
  raise e
74
+ ensure
75
+ environment.pop_frame
73
76
  end
74
77
 
75
78
  private
@@ -50,13 +50,15 @@ module Sass::Tree
50
50
  # @raise [Sass::SyntaxError] if an incorrect number of arguments was passed
51
51
  # @see Sass::Tree
52
52
  def perform!(environment)
53
+ original_env = environment
54
+ original_env.push_frame(:filename => filename, :line => line)
55
+ original_env.prepare_frame(:mixin => @name)
53
56
  raise Sass::SyntaxError.new("Undefined mixin '#{@name}'.") unless mixin = environment.mixin(@name)
54
57
 
55
58
  raise Sass::SyntaxError.new(<<END.gsub("\n", "")) if mixin.args.size < @args.size
56
59
  Mixin #{@name} takes #{mixin.args.size} argument#{'s' if mixin.args.size != 1}
57
60
  but #{@args.size} #{@args.size == 1 ? 'was' : 'were'} passed.
58
61
  END
59
-
60
62
  environment = mixin.args.zip(@args).
61
63
  inject(Sass::Environment.new(mixin.environment)) do |env, ((var, default), value)|
62
64
  env.set_local_var(var.name,
@@ -78,6 +80,8 @@ END
78
80
  e.modify_backtrace(:mixin => @name, :line => @line)
79
81
  e.add_backtrace(:line => @line)
80
82
  raise e
83
+ ensure
84
+ original_env.pop_frame
81
85
  end
82
86
  end
83
87
  end
@@ -0,0 +1,41 @@
1
+ module 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
+ def to_src(tabs, opts, fmt)
16
+ "#{' ' * tabs}@warn #{@expr.to_sass(opts)}#{semi fmt}\n"
17
+ end
18
+
19
+ # Prints the expression to STDERR with a stylesheet trace.
20
+ #
21
+ # @param environment [Sass::Environment] The lexical environment containing
22
+ # variable and mixin values
23
+ def _perform(environment)
24
+ environment.push_frame(:filename => filename, :line => line)
25
+ res = @expr.perform(environment)
26
+ res = res.value if res.is_a?(Sass::Script::String)
27
+ msg = "WARNING: #{res}\n"
28
+ environment.stack.reverse.each_with_index do |entry, i|
29
+ msg << " #{i == 0 ? "on" : "from"} line #{entry[:line]}" <<
30
+ " of #{entry[:filename] || "an unknown file"}"
31
+ msg << ", in `#{entry[:mixin]}'" if entry[:mixin]
32
+ msg << "\n"
33
+ end
34
+ Haml::Util.haml_warn msg
35
+ []
36
+ ensure
37
+ environment.pop_frame
38
+ end
39
+ end
40
+ end
41
+ end
@@ -107,6 +107,9 @@ MSG
107
107
  '@if' => "Invalid if directive '@if': expected expression.",
108
108
  '@while' => "Invalid while directive '@while': expected expression.",
109
109
  '@debug' => "Invalid debug directive '@debug': expected expression.",
110
+ %Q{@debug "a message"\n "nested message"} => "Illegal nesting: Nothing may be nested beneath debug directives.",
111
+ '@warn' => "Invalid warn directive '@warn': expected expression.",
112
+ %Q{@warn "a message"\n "nested message"} => "Illegal nesting: Nothing may be nested beneath warn directives.",
110
113
  "/* foo\n bar\n baz" => "Inconsistent indentation: previous line was indented by 4 spaces, but this line was indented by 2 spaces.",
111
114
 
112
115
  # Regression tests
@@ -1709,6 +1712,58 @@ SASS
1709
1712
  end
1710
1713
  end
1711
1714
 
1715
+ def test_warn_directive
1716
+ expected_warning = <<EXPECTATION
1717
+ WARNING: this is a warning
1718
+ on line 4 of test_warn_directive_inline.sass
1719
+
1720
+ WARNING: this is a mixin warning
1721
+ on line 2 of test_warn_directive_inline.sass, in `foo'
1722
+ from line 7 of test_warn_directive_inline.sass
1723
+ EXPECTATION
1724
+ assert_warning expected_warning do
1725
+ assert_equal <<CSS, render(<<SASS)
1726
+ bar {
1727
+ c: d; }
1728
+ CSS
1729
+ =foo
1730
+ @warn "this is a mixin warning"
1731
+
1732
+ @warn "this is a warning"
1733
+ bar
1734
+ c: d
1735
+ +foo
1736
+ SASS
1737
+ end
1738
+ end
1739
+
1740
+ def test_warn_directive_when_quiet
1741
+ assert_warning "" do
1742
+ assert_equal <<CSS, render(<<SASS, :quiet => true)
1743
+ CSS
1744
+ @warn "this is a warning"
1745
+ SASS
1746
+ end
1747
+ end
1748
+
1749
+ def test_warn_with_imports
1750
+ expected_warning = <<WARN
1751
+ WARNING: In the main file
1752
+ on line 1 of #{File.dirname(__FILE__)}/templates/warn.sass
1753
+
1754
+ WARNING: Imported
1755
+ on line 1 of #{File.dirname(__FILE__)}/templates/warn_imported.sass
1756
+ from line 2 of #{File.dirname(__FILE__)}/templates/warn.sass
1757
+
1758
+ WARNING: In an imported mixin
1759
+ on line 4 of #{File.dirname(__FILE__)}/templates/warn_imported.sass, in `emits-a-warning'
1760
+ from line 3 of #{File.dirname(__FILE__)}/templates/warn.sass
1761
+ WARN
1762
+ assert_warning expected_warning do
1763
+ renders_correctly "warn", :style => :compact, :load_paths => [File.dirname(__FILE__) + "/templates"]
1764
+ end
1765
+ end
1766
+
1712
1767
  # Regression tests
1713
1768
 
1714
1769
  def test_parens_in_mixins
@@ -505,6 +505,37 @@ The #options attribute is not set on this Sass::Script::String.
505
505
  MSG
506
506
  end
507
507
 
508
+ def test_type_of
509
+ assert_equal("string", evaluate("type-of(\"asdf\")"))
510
+ assert_equal("string", evaluate("type-of(asdf)"))
511
+ assert_equal("number", evaluate("type-of(1px)"))
512
+ assert_equal("bool", evaluate("type-of(true)"))
513
+ assert_equal("color", evaluate("type-of(#fff)"))
514
+ end
515
+
516
+ def test_unit
517
+ assert_equal(%Q{""}, evaluate("unit(100)"))
518
+ assert_equal(%Q{"px"}, evaluate("unit(100px)"))
519
+ assert_equal(%Q{"em*px"}, evaluate("unit(10px * 5em)"))
520
+ assert_equal(%Q{"em*px"}, evaluate("unit(5em * 10px)"))
521
+ assert_equal(%Q{"em*px/cm*rem"}, evaluate("unit(10px * 5em / 30cm / 1rem)"))
522
+ assert_error_message("#ff0000 is not a number for `unit'", "unit(#f00)")
523
+ end
524
+
525
+ def test_unitless
526
+ assert_equal(%Q{true}, evaluate("unitless(100)"))
527
+ assert_equal(%Q{false}, evaluate("unitless(100px)"))
528
+ assert_error_message("#ff0000 is not a number for `unitless'", "unitless(#f00)")
529
+ end
530
+
531
+ def test_comparable
532
+ assert_equal(%Q{true}, evaluate("comparable(2px, 1px)"))
533
+ assert_equal(%Q{true}, evaluate("comparable(10cm, 3mm)"))
534
+ assert_equal(%Q{false}, evaluate("comparable(100px, 3em)"))
535
+ assert_error_message("#ff0000 is not a number for `comparable'", "comparable(#f00, 1px)")
536
+ assert_error_message("#ff0000 is not a number for `comparable'", "comparable(1px, #f00)")
537
+ end
538
+
508
539
  private
509
540
 
510
541
  def evaluate(value)
@@ -14,7 +14,7 @@ class SassPluginTest < Test::Unit::TestCase
14
14
  FileUtils.mkdir tempfile_loc
15
15
  FileUtils.mkdir tempfile_loc(nil,"more_")
16
16
  set_plugin_opts
17
- Sass::Plugin.update_stylesheets
17
+ update_all_stylesheets!
18
18
  reset_mtimes
19
19
  end
20
20
 
@@ -34,21 +34,21 @@ class SassPluginTest < Test::Unit::TestCase
34
34
  def test_no_update
35
35
  File.delete(tempfile_loc('basic'))
36
36
  assert_needs_update 'basic'
37
- Sass::Plugin.update_stylesheets
37
+ update_all_stylesheets!
38
38
  assert_stylesheet_updated 'basic'
39
39
  end
40
40
 
41
41
  def test_update_needed_when_modified
42
42
  touch 'basic'
43
43
  assert_needs_update 'basic'
44
- Sass::Plugin.update_stylesheets
44
+ update_all_stylesheets!
45
45
  assert_stylesheet_updated 'basic'
46
46
  end
47
47
 
48
48
  def test_update_needed_when_dependency_modified
49
49
  touch 'basic'
50
50
  assert_needs_update 'import'
51
- Sass::Plugin.update_stylesheets
51
+ update_all_stylesheets!
52
52
  assert_stylesheet_updated 'basic'
53
53
  assert_stylesheet_updated 'import'
54
54
  end
@@ -56,7 +56,7 @@ class SassPluginTest < Test::Unit::TestCase
56
56
  def test_update_needed_when_scss_dependency_modified
57
57
  touch 'scss_importee'
58
58
  assert_needs_update 'import'
59
- Sass::Plugin.update_stylesheets
59
+ update_all_stylesheets!
60
60
  assert_stylesheet_updated 'scss_importee'
61
61
  assert_stylesheet_updated 'import'
62
62
  end
@@ -64,14 +64,14 @@ class SassPluginTest < Test::Unit::TestCase
64
64
  def test_scss_update_needed_when_dependency_modified
65
65
  touch 'basic'
66
66
  assert_needs_update 'scss_import'
67
- Sass::Plugin.update_stylesheets
67
+ update_all_stylesheets!
68
68
  assert_stylesheet_updated 'basic'
69
69
  assert_stylesheet_updated 'scss_import'
70
70
  end
71
71
 
72
72
  def test_full_exception_handling
73
73
  File.delete(tempfile_loc('bork1'))
74
- Sass::Plugin.update_stylesheets
74
+ update_all_stylesheets!
75
75
  File.open(tempfile_loc('bork1')) do |file|
76
76
  assert_equal(<<CSS.strip, file.read.split("\n")[0...6].join("\n"))
77
77
  /*
@@ -90,7 +90,7 @@ CSS
90
90
  Sass::Plugin.options[:full_exception] = false
91
91
 
92
92
  File.delete(tempfile_loc('bork1'))
93
- assert_raise(Sass::SyntaxError) {Sass::Plugin.update_stylesheets}
93
+ assert_raise(Sass::SyntaxError) {update_all_stylesheets!}
94
94
  ensure
95
95
  Sass::Plugin.options[:full_exception] = old_full_exception
96
96
  end
@@ -100,7 +100,7 @@ CSS
100
100
  template_loc => tempfile_loc,
101
101
  template_loc(nil,'more_') => tempfile_loc(nil,'more_')
102
102
  }
103
- Sass::Plugin.update_stylesheets
103
+ update_all_stylesheets!
104
104
  ['more1', 'more_import'].each { |name| assert_renders_correctly(name, :prefix => 'more_') }
105
105
  end
106
106
 
@@ -111,7 +111,7 @@ CSS
111
111
  template_loc => tempfile_loc,
112
112
  template_loc(nil,'more_') => tempfile_loc(nil,'more_')
113
113
  }
114
- Sass::Plugin.update_stylesheets
114
+ update_all_stylesheets!
115
115
  assert_renders_correctly('more1_with_line_comments', 'more1', :prefix => 'more_')
116
116
  end
117
117
 
@@ -157,7 +157,7 @@ CSS
157
157
 
158
158
  def test_updating_stylesheets_callback_with_individual_files
159
159
  files = [[template_loc("basic"), tempfile_loc("basic")]]
160
- assert_callback(:updating_stylesheets, files) {Sass::Plugin.update_stylesheets(files)}
160
+ assert_callback(:updating_stylesheets, files) {Haml::Util.silence_haml_warnings{Sass::Plugin.update_stylesheets(files)}}
161
161
  end
162
162
 
163
163
  def test_updating_stylesheets_callback_with_never_update
@@ -248,7 +248,7 @@ CSS
248
248
 
249
249
  touch 'basic', 'more_'
250
250
  assert_needs_update "import"
251
- Sass::Plugin.update_stylesheets
251
+ update_all_stylesheets!
252
252
  assert_renders_correctly("import")
253
253
  ensure
254
254
  FileUtils.mv(template_loc("basic", "more_"), template_loc("basic"))
@@ -299,7 +299,7 @@ CSS
299
299
  if block_given?
300
300
  yield
301
301
  else
302
- Sass::Plugin.update_stylesheets
302
+ update_all_stylesheets!
303
303
  end
304
304
 
305
305
  assert run, "Expected #{name} callback to be run with arguments:\n #{expected_args.inspect}"
@@ -322,17 +322,17 @@ CSS
322
322
  if block_given?
323
323
  yield
324
324
  else
325
- Sass::Plugin.update_stylesheets
325
+ update_all_stylesheets!
326
326
  end
327
327
  end
328
328
 
329
329
  def assert_callbacks(*args)
330
- return Sass::Plugin.update_stylesheets if args.empty?
330
+ return update_all_stylesheets! if args.empty?
331
331
  assert_callback(*args.pop) {assert_callbacks(*args)}
332
332
  end
333
333
 
334
334
  def assert_no_callbacks(*args)
335
- return Sass::Plugin.update_stylesheets if args.empty?
335
+ return update_all_stylesheets! if args.empty?
336
336
  assert_no_callback(*args.pop) {assert_no_callbacks(*args)}
337
337
  end
338
338
 
@@ -340,6 +340,12 @@ CSS
340
340
  Sass::Plugin.instance_variable_set('@_sass_callbacks', {})
341
341
  end
342
342
 
343
+ def update_all_stylesheets!
344
+ Haml::Util.silence_haml_warnings do
345
+ Sass::Plugin.update_stylesheets
346
+ end
347
+ end
348
+
343
349
  def assert_needs_update(name)
344
350
  assert(Sass::Plugin.stylesheet_needs_update?(tempfile_loc(name), template_loc(name)),
345
351
  "Expected #{template_loc(name)} to need an update.")
File without changes
File without changes
@@ -113,6 +113,27 @@ SCSS
113
113
  end
114
114
  end
115
115
 
116
+ def test_warn_directive
117
+ expected_warning = <<EXPECTATION
118
+ WARNING: this is a warning
119
+ on line 2 of test_warn_directive_inline.scss
120
+
121
+ WARNING: this is a mixin
122
+ on line 1 of test_warn_directive_inline.scss, in `foo'
123
+ from line 3 of test_warn_directive_inline.scss
124
+ EXPECTATION
125
+ assert_warning expected_warning do
126
+ assert_equal <<CSS, render(<<SCSS)
127
+ bar {
128
+ c: d; }
129
+ CSS
130
+ @mixin foo { @warn "this is a mixin";}
131
+ @warn "this is a warning";
132
+ bar {c: d; @include foo;}
133
+ SCSS
134
+ end
135
+ end
136
+
116
137
  def test_for_directive
117
138
  assert_equal <<CSS, render(<<SCSS)
118
139
  .foo {
@@ -0,0 +1,3 @@
1
+ @warn "In the main file"
2
+ @import warn_imported.sass
3
+ +emits-a-warning
@@ -0,0 +1,4 @@
1
+ @warn "Imported"
2
+
3
+ =emits-a-warning
4
+ @warn "In an imported mixin"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml-edge
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.197
4
+ version: 2.3.198
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum
@@ -119,6 +119,7 @@ files:
119
119
  - lib/sass/tree/variable_node.rb
120
120
  - lib/sass/tree/while_node.rb
121
121
  - lib/sass/tree/root_node.rb
122
+ - lib/sass/tree/warn_node.rb
122
123
  - lib/sass/scss/css_parser.rb
123
124
  - lib/sass/scss/parser.rb
124
125
  - lib/sass/scss/rx.rb
@@ -262,6 +263,8 @@ files:
262
263
  - test/sass/results/subdir/nested_subdir/nested_subdir.css
263
264
  - test/sass/results/subdir/subdir.css
264
265
  - test/sass/results/units.css
266
+ - test/sass/results/warn.css
267
+ - test/sass/results/warn_imported.css
265
268
  - test/sass/callbacks_test.rb
266
269
  - test/sass/conversion_test.rb
267
270
  - test/sass/templates/_partial.sass
@@ -296,6 +299,8 @@ files:
296
299
  - test/sass/templates/subdir/nested_subdir/nested_subdir.sass
297
300
  - test/sass/templates/subdir/subdir.sass
298
301
  - test/sass/templates/scss_importee.scss
302
+ - test/sass/templates/warn.sass
303
+ - test/sass/templates/warn_imported.sass
299
304
  - test/sass/script_conversion_test.rb
300
305
  - test/test_helper.rb
301
306
  - extra/haml-mode.el