sass 3.1.0.alpha.18 → 3.1.0.alpha.19

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.
@@ -1 +1 @@
1
- 3.1.0.alpha.18
1
+ 3.1.0.alpha.19
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.0.alpha.18
1
+ 3.1.0.alpha.19
@@ -43,17 +43,21 @@ module Sass
43
43
  # @raise [ArgumentError] if the document uses an unknown encoding with `@charset`
44
44
  #
45
45
  # @overload compile_file(filename, options = {})
46
+ # Return the compiled CSS rather than writing it to a file.
47
+ #
46
48
  # @return [String] The compiled CSS.
47
49
  #
48
50
  # @overload compile_file(filename, css_filename, options = {})
51
+ # Write the compiled CSS to a file.
52
+ #
49
53
  # @param css_filename [String] The location to which to write the compiled CSS.
50
54
  def self.compile_file(filename, *args)
51
55
  options = args.last.is_a?(Hash) ? args.pop : {}
52
- css_filename ||= args.shift
53
- options[:css_filename] = css_filename
56
+ css_filename = args.shift
54
57
  result = Sass::Engine.for_file(filename, options).render
55
58
  if css_filename
56
- open(css_filename,"w") {|css_file| css_file.write(result) }
59
+ options[:css_filename] ||= css_filename
60
+ open(css_filename,"w") {|css_file| css_file.write(result)}
57
61
  nil
58
62
  else
59
63
  result
@@ -158,8 +158,8 @@ module Sass
158
158
  options[:line_comments] ||= options[:line_numbers]
159
159
 
160
160
  options[:load_paths] = options[:load_paths].map do |p|
161
- next p unless p.is_a?(String)
162
- options[:filesystem_importer].new(p)
161
+ next p unless p.is_a?(String) || (defined?(Pathname) && p.is_a?(Pathname))
162
+ options[:filesystem_importer].new(p.to_s)
163
163
  end
164
164
 
165
165
  # Backwards compatibility
@@ -246,24 +246,43 @@ WARNING
246
246
  private
247
247
 
248
248
  LESS_TO_SASS_OPERATORS = {"-" => :minus, "+" => :plus, "*" => :times, "/" => :div, "=" => :single_eq}
249
+
249
250
  def _to_sass_tree(arr)
250
- return Sass::Script::UnaryOperation.new(_to_sass_tree(arr[1..-1]), :minus) if arr[0] == "-"
251
- _to_sass_tree2(*_sass_split(arr))
251
+ e, rest = _to_sass_tree_plus_minus_eq(arr)
252
+ until rest.empty?
253
+ e2, rest = _to_sass_tree_plus_minus_eq(rest)
254
+ e = Sass::Script::Operation.new(e, e2, :concat)
255
+ end
256
+ return e
252
257
  end
253
258
 
254
- def _to_sass_tree2(first, rest)
255
- return first if rest.empty?
256
- if rest[0].is_a?(Operator)
259
+ def _to_sass_tree_plus_minus_eq(arr)
260
+ e, rest = _to_sass_tree_times_div(arr)
261
+ while rest[0] && rest[0].is_a?(Operator) && %w[+ - =].include?(rest[0])
257
262
  op = LESS_TO_SASS_OPERATORS[rest[0]]
258
- if op == :times || op == :div
259
- second, rest = _sass_split(rest[1..-1])
260
- return _to_sass_tree2(Sass::Script::Operation.new(first, second, op), rest)
261
- else
262
- return Sass::Script::Operation.new(first, _to_sass_tree(rest[1..-1]), op)
263
- end
263
+ e2, rest = _to_sass_tree_times_div(rest[1..-1])
264
+ e = Sass::Script::Operation.new(e, e2, op)
264
265
  end
266
+ return e, rest
267
+ end
265
268
 
266
- Sass::Script::Operation.new(first, _to_sass_tree(rest), :concat)
269
+ def _to_sass_tree_times_div(arr)
270
+ e, rest = _to_sass_tree_unary(arr)
271
+ while rest[0] && rest[0].is_a?(Operator) && %w[* /].include?(rest[0])
272
+ op = LESS_TO_SASS_OPERATORS[rest[0]]
273
+ e2, rest = _to_sass_tree_unary(rest[1..-1])
274
+ e = Sass::Script::Operation.new(e, e2, op)
275
+ end
276
+ return e, rest
277
+ end
278
+
279
+ def _to_sass_tree_unary(arr)
280
+ if arr[0] == "-"
281
+ first, rest = _sass_split(arr[1..-1])
282
+ return Sass::Script::UnaryOperation.new(first, :minus), rest
283
+ else
284
+ return _sass_split(arr[0..-1])
285
+ end
267
286
  end
268
287
 
269
288
  def _sass_split(arr)
@@ -1,4 +1,5 @@
1
- require File.join(File.dirname(__FILE__), 'functions')
1
+ require 'sass/script/functions'
2
+
2
3
  module Sass
3
4
  module Script
4
5
  # A SassScript parse node representing a function call.
@@ -130,7 +130,7 @@ module Sass
130
130
  [:times, :div, :mod],
131
131
  ]
132
132
 
133
- ASSOCIATIVE = [:plus, :times]
133
+ ASSOCIATIVE = [:comma, :concat, :plus, :times]
134
134
 
135
135
  class << self
136
136
  # Returns an integer representing the precedence
@@ -5,6 +5,7 @@ require File.dirname(__FILE__) + '/test_helper'
5
5
  require 'sass/engine'
6
6
  require 'stringio'
7
7
  require 'mock_importer'
8
+ require 'pathname'
8
9
 
9
10
  module Sass::Script::Functions::UserFunctions
10
11
  def option(name)
@@ -545,6 +546,15 @@ CSS
545
546
  assert File.exists?(sassc_file)
546
547
  end
547
548
 
549
+ def test_sass_pathname_import
550
+ sassc_file = sassc_path("importee")
551
+ assert !File.exists?(sassc_file)
552
+ renders_correctly("import",
553
+ :style => :compact,
554
+ :load_paths => [Pathname.new(File.dirname(__FILE__) + "/templates")])
555
+ assert File.exists?(sassc_file)
556
+ end
557
+
548
558
  def test_nonexistent_extensionless_import
549
559
  assert_raise_message(Sass::SyntaxError, <<ERR.rstrip) do
550
560
  File to import not found or unreadable: nonexistent.
@@ -14,7 +14,7 @@ module Sass::Script::Functions
14
14
  declare :only_var_args, [], :var_args => true
15
15
 
16
16
  def only_kw_args(kwargs)
17
- Sass::Script::String.new("only-kw-args("+kwargs.keys.join(", ")+")")
17
+ Sass::Script::String.new("only-kw-args(" + kwargs.keys.sort.join(", ") + ")")
18
18
  end
19
19
  declare :only_kw_args, [], :var_kwargs => true
20
20
  end
@@ -629,9 +629,11 @@ MSG
629
629
  def test_only_var_args
630
630
  assert_equal "only-var-args(2px, 3px, 4px)", evaluate("only-var-args(1px, 2px, 3px)")
631
631
  end
632
+
632
633
  def test_only_kw_args
633
634
  assert_equal "only-kw-args(a, b, c)", evaluate("only-kw-args($a: 1, $b: 2, $c: 3)")
634
635
  end
636
+
635
637
  private
636
638
 
637
639
  def evaluate(value)
@@ -326,7 +326,14 @@ foo {
326
326
  d: 1 + 2 - 3 + 4;
327
327
  e: 1 / 2 - 3 / 4;
328
328
  f: 1 - 2 / 3 - 4;
329
- g: 1 / 2 * 3 / 4; }
329
+ g: 1 / 2 * 3 / 4;
330
+ h: (1 + 2) * (3 + 4);
331
+ i: 1 * (2 + 3) * 4;
332
+ j: 1 - (2 + 2) - 4;
333
+ k: 1 + 2 - (3 + 4);
334
+ l: 1 / (2 - 3) / 4;
335
+ m: (1 - 2) / (3 - 4);
336
+ n: 1 / (2 * 3) / 4; }
330
337
  SCSS
331
338
  foo {
332
339
  a: 1 + 2 * 3 + 4;
@@ -335,7 +342,14 @@ foo {
335
342
  d: 1 + 2 - 3 + 4;
336
343
  e: 1 / 2 - 3 / 4;
337
344
  f: 1 - 2 / 3 - 4;
338
- g: 1 / 2 * 3 / 4; }
345
+ g: 1 / 2 * 3 / 4;
346
+ h: (1 + 2) * (3 + 4);
347
+ i: 1 * (2 + 3) * 4;
348
+ j: 1 - (2 + 2) - 4;
349
+ k: 1 + 2 - (3 + 4);
350
+ l: 1 / (2 - 3) / 4;
351
+ m: (1 - 2) / (3 - 4);
352
+ n: 1 / (2 * 3) / 4; }
339
353
  LESS
340
354
  end
341
355
 
@@ -628,5 +642,12 @@ LESS
628
642
  end
629
643
 
630
644
  rescue LoadError => e
631
- puts "\nCouldn't require less, skipping some tests."
645
+ unless defined?(Gem)
646
+ begin
647
+ require 'rubygems'
648
+ retry
649
+ rescue Exception
650
+ end
651
+ end
652
+ puts "\nCouldn't require less, skipping some tests."
632
653
  end
@@ -124,25 +124,33 @@ RUBY
124
124
  end
125
125
 
126
126
  def self.assert_associative(op_name, sibling_name)
127
- op = Sass::Script::Lexer::OPERATORS_REVERSE[op_name]
128
- sibling = Sass::Script::Lexer::OPERATORS_REVERSE[sibling_name]
127
+ op = separator_for(op_name)
128
+ sibling = separator_for(sibling_name)
129
129
  class_eval <<RUBY
130
130
  def test_associative_#{op_name}_#{sibling_name}
131
- assert_renders "$foo #{op} $bar #{op} $baz"
131
+ assert_renders "$foo#{op}$bar#{op}$baz"
132
132
 
133
- assert_equal "$foo #{op} $bar #{op} $baz",
134
- render("$foo #{op} ($bar #{op} $baz)")
135
- assert_equal "$foo #{op} $bar #{op} $baz",
136
- render("($foo #{op} $bar) #{op} $baz")
133
+ assert_equal "$foo#{op}$bar#{op}$baz",
134
+ render("$foo#{op}($bar#{op}$baz)")
135
+ assert_equal "$foo#{op}$bar#{op}$baz",
136
+ render("($foo#{op}$bar)#{op}$baz")
137
137
 
138
- assert_equal "$foo #{op} $bar #{sibling} $baz",
139
- render("$foo #{op} ($bar #{sibling} $baz)")
140
- assert_equal "$foo #{sibling} $bar #{op} $baz",
141
- render("($foo #{sibling} $bar) #{op} $baz")
138
+ assert_equal "$foo#{op}$bar#{sibling}$baz",
139
+ render("$foo#{op}($bar#{sibling}$baz)")
140
+ assert_equal "$foo#{sibling}$bar#{op}$baz",
141
+ render("($foo#{sibling}$bar)#{op}$baz")
142
142
  end
143
143
  RUBY
144
144
  end
145
145
 
146
+ def self.separator_for(op_name)
147
+ case op_name
148
+ when :comma; ", "
149
+ when :concat; " "
150
+ else; " #{Sass::Script::Lexer::OPERATORS_REVERSE[op_name]} "
151
+ end
152
+ end
153
+
146
154
  def self.assert_non_associative(op_name, sibling_name)
147
155
  op = Sass::Script::Lexer::OPERATORS_REVERSE[op_name]
148
156
  sibling = Sass::Script::Lexer::OPERATORS_REVERSE[sibling_name]
@@ -174,6 +182,8 @@ RUBY
174
182
  test_precedence :plus, :div
175
183
  test_precedence :plus, :mod
176
184
 
185
+ assert_associative :comma, :concat
186
+ assert_associative :concat, :or
177
187
  assert_associative :plus, :minus
178
188
  assert_associative :times, :div
179
189
  assert_associative :times, :mod
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.18
4
+ version: 3.1.0.alpha.19
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-10-12 00:00:00 -04:00
14
+ date: 2010-10-19 00:00:00 -04:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -162,16 +162,16 @@ files:
162
162
  - test/sass/plugin_test.rb
163
163
  - test/sass/extend_test.rb
164
164
  - test/sass/functions_test.rb
165
- - test/sass/cache_test.rb
166
165
  - test/sass/less_conversion_test.rb
167
- - test/sass/importer_test.rb
166
+ - test/sass/script_conversion_test.rb
167
+ - test/sass/util/subset_map_test.rb
168
168
  - test/sass/more_results/more1.css
169
169
  - test/sass/more_results/more1_with_line_comments.css
170
170
  - test/sass/more_results/more_import.css
171
171
  - test/sass/more_templates/_more_partial.sass
172
172
  - test/sass/more_templates/more1.sass
173
173
  - test/sass/more_templates/more_import.sass
174
- - test/sass/mock_importer.rb
174
+ - test/sass/cache_test.rb
175
175
  - test/sass/results/alt.css
176
176
  - test/sass/results/basic.css
177
177
  - test/sass/results/compact.css
@@ -193,7 +193,7 @@ files:
193
193
  - test/sass/results/units.css
194
194
  - test/sass/results/warn.css
195
195
  - test/sass/results/warn_imported.css
196
- - test/sass/script_conversion_test.rb
196
+ - test/sass/importer_test.rb
197
197
  - test/sass/script_test.rb
198
198
  - test/sass/scss/css_test.rb
199
199
  - test/sass/scss/rx_test.rb
@@ -234,8 +234,8 @@ files:
234
234
  - test/sass/templates/units.sass
235
235
  - test/sass/templates/warn.sass
236
236
  - test/sass/templates/warn_imported.sass
237
+ - test/sass/mock_importer.rb
237
238
  - test/sass/test_helper.rb
238
- - test/sass/util/subset_map_test.rb
239
239
  - test/sass/util_test.rb
240
240
  - test/test_helper.rb
241
241
  - extra/update_watch.rb
@@ -285,13 +285,13 @@ test_files:
285
285
  - test/sass/plugin_test.rb
286
286
  - test/sass/extend_test.rb
287
287
  - test/sass/functions_test.rb
288
- - test/sass/cache_test.rb
289
288
  - test/sass/less_conversion_test.rb
290
- - test/sass/importer_test.rb
291
289
  - test/sass/script_conversion_test.rb
290
+ - test/sass/util/subset_map_test.rb
291
+ - test/sass/cache_test.rb
292
+ - test/sass/importer_test.rb
292
293
  - test/sass/script_test.rb
293
294
  - test/sass/scss/css_test.rb
294
295
  - test/sass/scss/rx_test.rb
295
296
  - test/sass/scss/scss_test.rb
296
- - test/sass/util/subset_map_test.rb
297
297
  - test/sass/util_test.rb