sass 3.1.0.alpha.28 → 3.1.0.alpha.29

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- 3.1.0.alpha.28
1
+ 3.1.0.alpha.29
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.0.alpha.28
1
+ 3.1.0.alpha.29
@@ -123,9 +123,18 @@ module Sass
123
123
  # @param color [Symbol] The name of the color to use for this action.
124
124
  # Can be `:red`, `:green`, or `:yellow`.
125
125
  def puts_action(name, color, arg)
126
+ return if @options[:for_engine][:quiet]
126
127
  printf color(color, "%11s %s\n"), name, arg
127
128
  end
128
129
 
130
+ # Same as \{Kernel.puts}, but doesn't print anything if the `--quiet` option is set.
131
+ #
132
+ # @param args [Array] Passed on to \{Kernel.puts}
133
+ def puts(*args)
134
+ return if @options[:for_engine][:quiet]
135
+ Kernel.puts(*args)
136
+ end
137
+
129
138
  # Wraps the given string in terminal escapes
130
139
  # causing it to have the given color.
131
140
  # If terminal esapes aren't supported on this platform,
@@ -219,7 +228,7 @@ END
219
228
  'Output style. Can be nested (default), compact, compressed, or expanded.') do |name|
220
229
  @options[:for_engine][:style] = name.to_sym
221
230
  end
222
- opts.on('-q', '--quiet', 'Silence warnings during compilation.') do
231
+ opts.on('-q', '--quiet', 'Silence warnings and status messages during compilation.') do
223
232
  @options[:for_engine][:quiet] = true
224
233
  end
225
234
  opts.on('-g', '--debug-info',
@@ -99,7 +99,7 @@ module Sass
99
99
  end
100
100
 
101
101
  DIRECTIVES = Set[:mixin, :include, :debug, :warn, :for, :each, :while, :if,
102
- :extend, :import, :media, :charset]
102
+ :else, :extend, :import, :media, :charset]
103
103
 
104
104
  def directive
105
105
  return unless tok(/@/)
@@ -192,12 +192,14 @@ module Sass
192
192
  ss
193
193
  node = block(node(Sass::Tree::IfNode.new(expr)), :directive)
194
194
  pos = @scanner.pos
195
+ line = @line
195
196
  ss
196
197
 
197
198
  else_block(node) ||
198
199
  begin
199
200
  # Backtrack in case there are any comments we want to parse
200
201
  @scanner.pos = pos
202
+ @line = line
201
203
  node
202
204
  end
203
205
  end
@@ -210,16 +212,23 @@ module Sass
210
212
  :directive)
211
213
  node.add_else(else_node)
212
214
  pos = @scanner.pos
215
+ line = @line
213
216
  ss
214
217
 
215
218
  else_block(node) ||
216
219
  begin
217
220
  # Backtrack in case there are any comments we want to parse
218
221
  @scanner.pos = pos
222
+ @line = line
219
223
  node
220
224
  end
221
225
  end
222
226
 
227
+ def else_directive
228
+ raise Sass::SyntaxError.new(
229
+ "Invalid CSS: @else must come after @if", :line => @line)
230
+ end
231
+
223
232
  def extend_directive
224
233
  node(Sass::Tree::ExtendNode.new(expr!(:selector)))
225
234
  end
@@ -17,6 +17,11 @@ module Sass
17
17
  # @api public
18
18
  RUBY_VERSION = ::RUBY_VERSION.split(".").map {|s| s.to_i}
19
19
 
20
+ # The Ruby engine we're running under. Defaults to `"ruby"`
21
+ # if the top-level constant is undefined.
22
+ # @api public
23
+ RUBY_ENGINE = defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "ruby"
24
+
20
25
  # Returns the path of a file relative to the Sass root directory.
21
26
  #
22
27
  # @param file [String] The filename relative to the Sass root
@@ -416,13 +421,25 @@ module Sass
416
421
  RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i
417
422
  end
418
423
 
424
+ # Whether or not this is running on IronRuby.
425
+ #
426
+ # @return [Boolean]
427
+ def ironruby?
428
+ RUBY_ENGINE == "ironruby"
429
+ end
430
+
419
431
  ## Cross-Ruby-Version Compatibility
420
432
 
421
433
  # Whether or not this is running under Ruby 1.8 or lower.
422
434
  #
435
+ # Note that IronRuby counts as Ruby 1.8,
436
+ # because it doesn't support the Ruby 1.9 encoding API.
437
+ #
423
438
  # @return [Boolean]
424
439
  def ruby1_8?
425
- Sass::Util::RUBY_VERSION[0] == 1 && Sass::Util::RUBY_VERSION[1] < 9
440
+ # IronRuby says its version is 1.9, but doesn't support any of the encoding APIs.
441
+ # We have to fall back to 1.8 behavior.
442
+ ironruby? || (Sass::Util::RUBY_VERSION[0] == 1 && Sass::Util::RUBY_VERSION[1] < 9)
426
443
  end
427
444
 
428
445
  # Whether or not this is running under Ruby 1.8.6 or lower.
@@ -1050,6 +1050,14 @@ MESSAGE
1050
1050
  SCSS
1051
1051
  end
1052
1052
 
1053
+ def test_no_lonely_else
1054
+ assert_raise_message(Sass::SyntaxError, <<MESSAGE.rstrip) {render <<SCSS}
1055
+ Invalid CSS: @else must come after @if
1056
+ MESSAGE
1057
+ @else {foo: bar}
1058
+ SCSS
1059
+ end
1060
+
1053
1061
  # Regression
1054
1062
 
1055
1063
  def test_weird_added_space
@@ -1173,6 +1181,12 @@ b {
1173
1181
  }
1174
1182
  }
1175
1183
  SCSS
1184
+ end
1176
1185
 
1186
+ def test_if_error_line
1187
+ assert_raise_line(2) {render(<<SCSS)}
1188
+ @if true {foo: bar}
1189
+ }
1190
+ SCSS
1177
1191
  end
1178
1192
  end
@@ -61,4 +61,12 @@ class Test::Unit::TestCase
61
61
  else
62
62
  flunk "Expected exception #{klass}, none raised"
63
63
  end
64
+
65
+ def assert_raise_line(line)
66
+ yield
67
+ rescue Sass::SyntaxError => e
68
+ assert_equal(line, e.sass_line)
69
+ else
70
+ flunk "Expected exception on line #{line}, none raised"
71
+ end
64
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.alpha.28
4
+ version: 3.1.0.alpha.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2010-11-11 00:00:00 -05:00
14
+ date: 2010-11-16 00:00:00 -05:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -84,10 +84,10 @@ files:
84
84
  - lib/sass/script/operation.rb
85
85
  - lib/sass/script/parser.rb
86
86
  - lib/sass/script/string.rb
87
+ - lib/sass/script/list.rb
87
88
  - lib/sass/script/string_interpolation.rb
88
89
  - lib/sass/script/unary_operation.rb
89
90
  - lib/sass/script/variable.rb
90
- - lib/sass/script/list.rb
91
91
  - lib/sass/scss.rb
92
92
  - lib/sass/scss/css_parser.rb
93
93
  - lib/sass/scss/parser.rb
@@ -108,19 +108,19 @@ files:
108
108
  - lib/sass/tree/debug_node.rb
109
109
  - lib/sass/tree/directive_node.rb
110
110
  - lib/sass/tree/extend_node.rb
111
+ - lib/sass/tree/node.rb
111
112
  - lib/sass/tree/for_node.rb
112
113
  - lib/sass/tree/if_node.rb
113
114
  - lib/sass/tree/import_node.rb
114
- - lib/sass/tree/mixin_def_node.rb
115
115
  - lib/sass/tree/mixin_node.rb
116
- - lib/sass/tree/node.rb
116
+ - lib/sass/tree/mixin_def_node.rb
117
117
  - lib/sass/tree/prop_node.rb
118
118
  - lib/sass/tree/root_node.rb
119
119
  - lib/sass/tree/rule_node.rb
120
- - lib/sass/tree/variable_node.rb
121
120
  - lib/sass/tree/warn_node.rb
122
- - lib/sass/tree/while_node.rb
123
121
  - lib/sass/tree/each_node.rb
122
+ - lib/sass/tree/variable_node.rb
123
+ - lib/sass/tree/while_node.rb
124
124
  - lib/sass/tree/media_node.rb
125
125
  - lib/sass/util.rb
126
126
  - lib/sass/util/subset_map.rb