sass 3.2.0.alpha.64 → 3.2.0.alpha.70

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/REVISION CHANGED
@@ -1 +1 @@
1
- 13aa911b7cb8d035e5a613f7d94d9b08241a46cd
1
+ ba7e79376e9d6d6b78d9ddf79fbba00239f6e675
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.0.alpha.64
1
+ 3.2.0.alpha.70
data/lib/sass/css.rb CHANGED
@@ -24,6 +24,8 @@ module Sass
24
24
  # (`:color blue` as opposed to `color: blue`).
25
25
  # This is only meaningful when generating Sass code,
26
26
  # rather than SCSS.
27
+ # @option options :indent [String] (" ")
28
+ # The string to use for indenting each line. Defaults to two spaces.
27
29
  def initialize(template, options = {})
28
30
  if template.is_a? IO
29
31
  template = template.read
data/lib/sass/engine.rb CHANGED
@@ -629,7 +629,7 @@ WARNING
629
629
  type = if silent then :silent elsif loud then :loud else :normal end
630
630
  Tree::CommentNode.new(value, type)
631
631
  else
632
- Tree::RuleNode.new(parse_interp(line))
632
+ Tree::RuleNode.new(parse_interp(line.text))
633
633
  end
634
634
  end
635
635
 
data/lib/sass/exec.rb CHANGED
@@ -404,6 +404,7 @@ MSG
404
404
  raise error unless error.is_a?(::Sass::SyntaxError) && !@options[:stop_on_error]
405
405
  had_error = true
406
406
  puts_action :error, :red, "#{error.sass_filename} (Line #{error.sass_line}: #{error.message})"
407
+ STDOUT.flush
407
408
  end
408
409
 
409
410
  if @options[:update]
@@ -414,9 +415,18 @@ MSG
414
415
 
415
416
  puts ">>> Sass is watching for changes. Press Ctrl-C to stop."
416
417
 
417
- ::Sass::Plugin.on_template_modified {|template| puts ">>> Change detected to: #{template}"}
418
- ::Sass::Plugin.on_template_created {|template| puts ">>> New template detected: #{template}"}
419
- ::Sass::Plugin.on_template_deleted {|template| puts ">>> Deleted template detected: #{template}"}
418
+ ::Sass::Plugin.on_template_modified do |template|
419
+ puts ">>> Change detected to: #{template}"
420
+ STDOUT.flush
421
+ end
422
+ ::Sass::Plugin.on_template_created do |template|
423
+ puts ">>> New template detected: #{template}"
424
+ STDOUT.flush
425
+ end
426
+ ::Sass::Plugin.on_template_deleted do |template|
427
+ puts ">>> Deleted template detected: #{template}"
428
+ STDOUT.flush
429
+ end
420
430
 
421
431
  ::Sass::Plugin.watch(files)
422
432
  end
@@ -515,6 +525,17 @@ END
515
525
  @options[:for_tree][:dasherize] = true
516
526
  end
517
527
 
528
+ opts.on('--indent NUM',
529
+ 'How many spaces to use for each level of indentation. Defaults to 2.',
530
+ '"t" means use hard tabs.') do |indent|
531
+
532
+ if indent == 't'
533
+ @options[:for_tree][:indent] = "\t"
534
+ else
535
+ @options[:for_tree][:indent] = " " * indent.to_i
536
+ end
537
+ end
538
+
518
539
  opts.on('--old', 'Output the old-style ":prop val" property syntax.',
519
540
  'Only meaningful when generating Sass.') do
520
541
  @options[:for_tree][:old] = true
@@ -39,6 +39,10 @@ module Sass
39
39
  def initialize(options)
40
40
  @dependencies = self.class.dependencies_cache
41
41
 
42
+ # URIs that are being actively checked for staleness. Protects against
43
+ # import loops.
44
+ @actively_checking = Set.new
45
+
42
46
  # Entries in the following instance-level caches are never explicitly expired.
43
47
  # Instead they are supposed to automaticaly go out of scope when a series of staleness checks
44
48
  # (this instance of StalenessChecker was created for) is finished.
@@ -148,10 +152,16 @@ module Sass
148
152
 
149
153
  def dependency_updated?(css_mtime)
150
154
  Proc.new do |uri, importer|
151
- sass_mtime = mtime(uri, importer)
152
- !sass_mtime ||
153
- sass_mtime > css_mtime ||
154
- dependencies_stale?(uri, importer, css_mtime)
155
+ next true if @actively_checking.include?(uri)
156
+ begin
157
+ @actively_checking << uri
158
+ sass_mtime = mtime(uri, importer)
159
+ !sass_mtime ||
160
+ sass_mtime > css_mtime ||
161
+ dependencies_stale?(uri, importer, css_mtime)
162
+ ensure
163
+ @actively_checking.delete uri
164
+ end
155
165
  end
156
166
  end
157
167
 
data/lib/sass/repl.rb CHANGED
@@ -34,8 +34,8 @@ module Sass
34
34
  case text
35
35
  when Script::MATCH
36
36
  name = $1
37
- guarded = $3 == '||=' || $4
38
- val = Script::Parser.parse($3, @line, text.size - $3.size)
37
+ guarded = !!$3
38
+ val = Script::Parser.parse($2, @line, text.size - ($3 || '').size - $2.size)
39
39
 
40
40
  unless guarded && environment.var(name)
41
41
  environment.set_var(name, val.perform(environment))
@@ -19,26 +19,157 @@ module Sass::Script
19
19
  class << self; include Sass::Util; end
20
20
 
21
21
  # A hash from color names to `[red, green, blue]` value arrays.
22
- HTML4_COLORS = map_vals({
23
- 'black' => 0x000000,
24
- 'silver' => 0xc0c0c0,
25
- 'gray' => 0x808080,
26
- 'white' => 0xffffff,
27
- 'maroon' => 0x800000,
28
- 'red' => 0xff0000,
29
- 'purple' => 0x800080,
22
+ COLOR_NAMES = map_vals({
23
+ 'aliceblue' => 0xf0f8ff,
24
+ 'antiquewhite' => 0xfaebd7,
25
+ 'aqua' => 0x00ffff,
26
+ 'aquamarine' => 0x7fffd4,
27
+ 'azure' => 0xf0ffff,
28
+ 'beige' => 0xf5f5dc,
29
+ 'bisque' => 0xffe4c4,
30
+ 'black' => 0x000000,
31
+ 'blanchedalmond' => 0xffebcd,
32
+ 'blue' => 0x0000ff,
33
+ 'blueviolet' => 0x8a2be2,
34
+ 'brown' => 0xa52a2a,
35
+ 'burlywood' => 0xdeb887,
36
+ 'cadetblue' => 0x5f9ea0,
37
+ 'chartreuse' => 0x7fff00,
38
+ 'chocolate' => 0xd2691e,
39
+ 'coral' => 0xff7f50,
40
+ 'cornflowerblue' => 0x6495ed,
41
+ 'cornsilk' => 0xfff8dc,
42
+ 'crimson' => 0xdc143c,
43
+ 'cyan' => 0x00ffff,
44
+ 'darkblue' => 0x00008b,
45
+ 'darkcyan' => 0x008b8b,
46
+ 'darkgoldenrod' => 0xb8860b,
47
+ 'darkgray' => 0xa9a9a9,
48
+ 'darkgrey' => 0xa9a9a9,
49
+ 'darkgreen' => 0x006400,
50
+ 'darkkhaki' => 0xbdb76b,
51
+ 'darkmagenta' => 0x8b008b,
52
+ 'darkolivegreen' => 0x556b2f,
53
+ 'darkorange' => 0xff8c00,
54
+ 'darkorchid' => 0x9932cc,
55
+ 'darkred' => 0x8b0000,
56
+ 'darksalmon' => 0xe9967a,
57
+ 'darkseagreen' => 0x8fbc8f,
58
+ 'darkslateblue' => 0x483d8b,
59
+ 'darkslategray' => 0x2f4f4f,
60
+ 'darkslategrey' => 0x2f4f4f,
61
+ 'darkturquoise' => 0x00ced1,
62
+ 'darkviolet' => 0x9400d3,
63
+ 'deeppink' => 0xff1493,
64
+ 'deepskyblue' => 0x00bfff,
65
+ 'dimgray' => 0x696969,
66
+ 'dimgrey' => 0x696969,
67
+ 'dodgerblue' => 0x1e90ff,
68
+ 'firebrick' => 0xb22222,
69
+ 'floralwhite' => 0xfffaf0,
70
+ 'forestgreen' => 0x228b22,
30
71
  'fuchsia' => 0xff00ff,
31
- 'green' => 0x008000,
32
- 'lime' => 0x00ff00,
33
- 'olive' => 0x808000,
34
- 'yellow' => 0xffff00,
35
- 'navy' => 0x000080,
36
- 'blue' => 0x0000ff,
37
- 'teal' => 0x008080,
38
- 'aqua' => 0x00ffff
72
+ 'gainsboro' => 0xdcdcdc,
73
+ 'ghostwhite' => 0xf8f8ff,
74
+ 'gold' => 0xffd700,
75
+ 'goldenrod' => 0xdaa520,
76
+ 'gray' => 0x808080,
77
+ 'green' => 0x008000,
78
+ 'greenyellow' => 0xadff2f,
79
+ 'honeydew' => 0xf0fff0,
80
+ 'hotpink' => 0xff69b4,
81
+ 'indianred' => 0xcd5c5c,
82
+ 'indigo' => 0x4b0082,
83
+ 'ivory' => 0xfffff0,
84
+ 'khaki' => 0xf0e68c,
85
+ 'lavender' => 0xe6e6fa,
86
+ 'lavenderblush' => 0xfff0f5,
87
+ 'lawngreen' => 0x7cfc00,
88
+ 'lemonchiffon' => 0xfffacd,
89
+ 'lightblue' => 0xadd8e6,
90
+ 'lightcoral' => 0xf08080,
91
+ 'lightcyan' => 0xe0ffff,
92
+ 'lightgoldenrodyellow' => 0xfafad2,
93
+ 'lightgreen' => 0x90ee90,
94
+ 'lightgray' => 0xd3d3d3,
95
+ 'lightgrey' => 0xd3d3d3,
96
+ 'lightpink' => 0xffb6c1,
97
+ 'lightsalmon' => 0xffa07a,
98
+ 'lightseagreen' => 0x20b2aa,
99
+ 'lightskyblue' => 0x87cefa,
100
+ 'lightslategray' => 0x778899,
101
+ 'lightslategrey' => 0x778899,
102
+ 'lightsteelblue' => 0xb0c4de,
103
+ 'lightyellow' => 0xffffe0,
104
+ 'lime' => 0x00ff00,
105
+ 'limegreen' => 0x32cd32,
106
+ 'linen' => 0xfaf0e6,
107
+ 'magenta' => 0xff00ff,
108
+ 'maroon' => 0x800000,
109
+ 'mediumaquamarine' => 0x66cdaa,
110
+ 'mediumblue' => 0x0000cd,
111
+ 'mediumorchid' => 0xba55d3,
112
+ 'mediumpurple' => 0x9370db,
113
+ 'mediumseagreen' => 0x3cb371,
114
+ 'mediumslateblue' => 0x7b68ee,
115
+ 'mediumspringgreen' => 0x00fa9a,
116
+ 'mediumturquoise' => 0x48d1cc,
117
+ 'mediumvioletred' => 0xc71585,
118
+ 'midnightblue' => 0x191970,
119
+ 'mintcream' => 0xf5fffa,
120
+ 'mistyrose' => 0xffe4e1,
121
+ 'moccasin' => 0xffe4b5,
122
+ 'navajowhite' => 0xffdead,
123
+ 'navy' => 0x000080,
124
+ 'oldlace' => 0xfdf5e6,
125
+ 'olive' => 0x808000,
126
+ 'olivedrab' => 0x6b8e23,
127
+ 'orange' => 0xffa500,
128
+ 'orangered' => 0xff4500,
129
+ 'orchid' => 0xda70d6,
130
+ 'palegoldenrod' => 0xeee8aa,
131
+ 'palegreen' => 0x98fb98,
132
+ 'paleturquoise' => 0xafeeee,
133
+ 'palevioletred' => 0xdb7093,
134
+ 'papayawhip' => 0xffefd5,
135
+ 'peachpuff' => 0xffdab9,
136
+ 'peru' => 0xcd853f,
137
+ 'pink' => 0xffc0cb,
138
+ 'plum' => 0xdda0dd,
139
+ 'powderblue' => 0xb0e0e6,
140
+ 'purple' => 0x800080,
141
+ 'red' => 0xff0000,
142
+ 'rosybrown' => 0xbc8f8f,
143
+ 'royalblue' => 0x4169e1,
144
+ 'saddlebrown' => 0x8b4513,
145
+ 'salmon' => 0xfa8072,
146
+ 'sandybrown' => 0xf4a460,
147
+ 'seagreen' => 0x2e8b57,
148
+ 'seashell' => 0xfff5ee,
149
+ 'sienna' => 0xa0522d,
150
+ 'silver' => 0xc0c0c0,
151
+ 'skyblue' => 0x87ceeb,
152
+ 'slateblue' => 0x6a5acd,
153
+ 'slategray' => 0x708090,
154
+ 'slategrey' => 0x708090,
155
+ 'snow' => 0xfffafa,
156
+ 'springgreen' => 0x00ff7f,
157
+ 'steelblue' => 0x4682b4,
158
+ 'tan' => 0xd2b48c,
159
+ 'teal' => 0x008080,
160
+ 'thistle' => 0xd8bfd8,
161
+ 'tomato' => 0xff6347,
162
+ 'turquoise' => 0x40e0d0,
163
+ 'violet' => 0xee82ee,
164
+ 'wheat' => 0xf5deb3,
165
+ 'white' => 0xffffff,
166
+ 'whitesmoke' => 0xf5f5f5,
167
+ 'yellow' => 0xffff00,
168
+ 'yellowgreen' => 0x9acd32
39
169
  }) {|color| (0..2).map {|n| color >> (n << 3) & 0xff}.reverse}
170
+
40
171
  # A hash from `[red, green, blue]` value arrays to color names.
41
- HTML4_COLORS_REVERSE = map_hash(HTML4_COLORS) {|k, v| [v, k]}
172
+ COLOR_NAMES_REVERSE = map_hash(COLOR_NAMES) {|k, v| [v, k]}
42
173
 
43
174
  # Constructs an RGB or HSL color object,
44
175
  # optionally with an alpha channel.
@@ -368,7 +499,7 @@ module Sass::Script
368
499
  def to_s(opts = {})
369
500
  return rgba_str if alpha?
370
501
  return smallest if options[:style] == :compressed
371
- return HTML4_COLORS_REVERSE[rgb] if HTML4_COLORS_REVERSE[rgb]
502
+ return COLOR_NAMES_REVERSE[rgb] if COLOR_NAMES_REVERSE[rgb]
372
503
  hex_str
373
504
  end
374
505
  alias_method :to_sass, :to_s
@@ -384,7 +515,7 @@ module Sass::Script
384
515
 
385
516
  def smallest
386
517
  small_hex_str = hex_str.gsub(/^#(.)\1(.)\2(.)\3$/, '#\1\2\3')
387
- return small_hex_str unless (color = HTML4_COLORS_REVERSE[rgb]) &&
518
+ return small_hex_str unless (color = COLOR_NAMES_REVERSE[rgb]) &&
388
519
  color.size <= small_hex_str.size
389
520
  return color
390
521
  end
@@ -99,6 +99,9 @@ module Sass::Script
99
99
  # \{#change_color change-color($color, \[$red\], \[$green\], \[$blue\], \[$hue\], \[$saturation\], \[$lightness\], \[$alpha\]}
100
100
  # : Changes one or more properties of a color.
101
101
  #
102
+ # \{#ie_hex_str ie-hex-str($color)}
103
+ # : Converts a color into the format understood by IE filters.
104
+ #
102
105
  # ## String Functions
103
106
  #
104
107
  # \{#unquote unquote($string)}
@@ -241,7 +244,7 @@ module Sass::Script
241
244
  # to {Sass::Script::Literal}s as the last argument.
242
245
  # In addition, if this is true and `:var_args` is not,
243
246
  # Sass will ensure that the last argument passed is a hash.
244
- #
247
+ #
245
248
  # @example
246
249
  # declare :rgba, [:hex, :alpha]
247
250
  # declare :rgba, [:red, :green, :blue, :alpha]
@@ -733,6 +736,23 @@ module Sass::Script
733
736
  end
734
737
  declare :adjust_hue, [:color, :degrees]
735
738
 
739
+ # Returns an IE hex string for a color with an alpha channel
740
+ # suitable for passing to IE filters.
741
+ #
742
+ # @example
743
+ # ie-hex-str(#abc) => #FFAABBCC
744
+ # ie-hex-str(#3322BB) => #FF3322BB
745
+ # ie-hex-str(rgba(0, 255, 0, 0.5)) => #8000FF00
746
+ # @param color [Color]
747
+ # @return [String]
748
+ # @raise [ArgumentError] If `color` isn't a color
749
+ def ie_hex_str(color)
750
+ assert_type color, :Color
751
+ alpha = (color.alpha * 255).round.to_s(16).rjust(2, '0')
752
+ Sass::Script::String.new("##{alpha}#{color.send(:hex_str)[1..-1]}".upcase)
753
+ end
754
+ declare :ie_hex_str, [:color]
755
+
736
756
  # Adjusts one or more properties of a color.
737
757
  # This can change the red, green, blue, hue, saturation, value, and alpha properties.
738
758
  # The properties are specified as keyword arguments,
@@ -982,14 +1002,23 @@ module Sass::Script
982
1002
  declare :mix, [:color_1, :color_2]
983
1003
  declare :mix, [:color_1, :color_2, :weight]
984
1004
 
985
- # Converts a color to grayscale.
986
- # This is identical to `desaturate(color, 100%)`.
1005
+ # @overload grayscale(color)
1006
+ # Converts a color to grayscale.
1007
+ # This is identical to `desaturate(color, 100%)`.
987
1008
  #
988
- # @param color [Color]
989
- # @return [Color]
990
- # @raise [ArgumentError] if `color` isn't a color
991
- # @see #desaturate
1009
+ # @param color [Color]
1010
+ # @return [Color]
1011
+ # @raise [ArgumentError] if `color` isn't a color
1012
+ # @see #desaturate
1013
+ # @overload grayscale(number)
1014
+ # Returns an unquoted string `grayscale(number)`, as though the function
1015
+ # were not defined. This is for the `grayscale` function used in
1016
+ # `-webkit-filter`.
1017
+ #
1018
+ # @param number [Number]
1019
+ # @return [Sass::Script::String]
992
1020
  def grayscale(color)
1021
+ return Sass::Script::String.new("grayscale(#{color})") if color.is_a?(Sass::Script::Number)
993
1022
  desaturate color, Number.new(100)
994
1023
  end
995
1024
  declare :grayscale, [:color]
@@ -316,7 +316,7 @@ RUBY
316
316
  return if @stop_at && @stop_at.include?(@lexer.peek.value)
317
317
 
318
318
  name = @lexer.next
319
- if color = Color::HTML4_COLORS[name.value.downcase]
319
+ if color = Color::COLOR_NAMES[name.value.downcase]
320
320
  return node(Color.new(color))
321
321
  end
322
322
  node(Script::String.new(name.value, :identifier))
@@ -275,7 +275,7 @@ module Sass
275
275
  end
276
276
 
277
277
  def extend_directive
278
- node(Sass::Tree::ExtendNode.new(expr!(:selector)))
278
+ node(Sass::Tree::ExtendNode.new(expr!(:selector_sequence)))
279
279
  end
280
280
 
281
281
  def import_directive
@@ -16,12 +16,14 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
16
16
  @options = options
17
17
  @format = format
18
18
  @tabs = 0
19
+ # 2 spaces by default
20
+ @tab_chars = @options[:indent] || " "
19
21
  end
20
22
 
21
23
  def visit_children(parent)
22
24
  @tabs += 1
23
25
  return @format == :sass ? "\n" : " {}\n" if parent.children.empty?
24
- (@format == :sass ? "\n" : " {\n") + super.join.rstrip + (@format == :sass ? "\n" : " }\n")
26
+ (@format == :sass ? "\n" : " {\n") + super.join.rstrip + (@format == :sass ? "\n" : "\n#{ @tab_chars * (@tabs-1)}}\n")
25
27
  ensure
26
28
  @tabs -= 1
27
29
  end
@@ -249,7 +251,7 @@ class Sass::Tree::Visitors::Convert < Sass::Tree::Visitors::Base
249
251
  end
250
252
 
251
253
  def tab_str
252
- ' ' * @tabs
254
+ @tab_chars * @tabs
253
255
  end
254
256
 
255
257
  def dasherize(s)
@@ -91,7 +91,7 @@ class Sass::Tree::Visitors::DeepCopy < Sass::Tree::Visitors::Base
91
91
  end
92
92
 
93
93
  def visit_media(node)
94
- node.query = query.deep_copy
94
+ node.query = node.query.deep_copy
95
95
  yield
96
96
  end
97
97
  end
@@ -358,7 +358,9 @@ END
358
358
  def handle_import_loop!(node)
359
359
  msg = "An @import loop has been found:"
360
360
  files = @stack.map {|s| s[:filename]}.compact
361
- raise Sass::SyntaxError.new("#{msg} #{node.filename} imports itself") if files.size == 1
361
+ if node.filename == node.imported_file.options[:filename]
362
+ raise Sass::SyntaxError.new("#{msg} #{node.filename} imports itself")
363
+ end
362
364
 
363
365
  files << node.filename << node.imported_file.options[:filename]
364
366
  msg << "\n" << Sass::Util.enum_cons(files, 2).map do |m1, m2|