sass 3.1.0.alpha.221 → 3.1.0.alpha.246

Sign up to get free protection for your applications and to get access to all the features.
data/REVISION CHANGED
@@ -1 +1 @@
1
- a8bdef1b0251ef20490c2df9fa0daac9419238c4
1
+ 7dc3a7bda300a9a18b37b58776ebe02915b49e82
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ task :default => :test
11
11
  require 'rake/testtask'
12
12
 
13
13
  Rake::TestTask.new do |t|
14
- t.libs << 'lib'
14
+ t.libs << 'test'
15
15
  test_files = FileList[scope('test/**/*_test.rb')]
16
16
  test_files.exclude(scope('test/rails/*'))
17
17
  test_files.exclude(scope('test/plugins/*'))
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.0.alpha.221
1
+ 3.1.0.alpha.246
@@ -29,17 +29,19 @@ module Sass
29
29
 
30
30
  # @see Base#\_store
31
31
  def _store(key, version, sha, contents)
32
- return unless File.writable?(File.dirname(@cache_location))
33
- return if File.exists?(@cache_location) && !File.writable?(@cache_location)
32
+ # return unless File.writable?(File.dirname(@cache_location))
33
+ # return if File.exists?(@cache_location) && !File.writable?(@cache_location)
34
34
  compiled_filename = path_to(key)
35
- return if File.exists?(File.dirname(compiled_filename)) && !File.writable?(File.dirname(compiled_filename))
36
- return if File.exists?(compiled_filename) && !File.writable?(compiled_filename)
35
+ # return if File.exists?(File.dirname(compiled_filename)) && !File.writable?(File.dirname(compiled_filename))
36
+ # return if File.exists?(compiled_filename) && !File.writable?(compiled_filename)
37
37
  FileUtils.mkdir_p(File.dirname(compiled_filename))
38
38
  File.open(compiled_filename, "wb") do |f|
39
39
  f.puts(version)
40
40
  f.puts(sha)
41
41
  f.write(contents)
42
42
  end
43
+ rescue Errno::EACCES
44
+ #pass
43
45
  end
44
46
 
45
47
  private
@@ -97,10 +97,6 @@ module Sass
97
97
  # The character that begins a CSS property.
98
98
  PROPERTY_CHAR = ?:
99
99
 
100
- # The character that designates that
101
- # a property should be assigned to a SassScript expression.
102
- SCRIPT_CHAR = ?=
103
-
104
100
  # The character that designates the beginning of a comment,
105
101
  # either Sass or CSS.
106
102
  COMMENT_CHAR = ?/
@@ -125,16 +121,9 @@ module Sass
125
121
  # Includes named mixin declared using MIXIN_DEFINITION_CHAR
126
122
  MIXIN_INCLUDE_CHAR = ?+
127
123
 
128
- # The regex that matches properties of the form `name: prop`.
129
- PROPERTY_NEW_MATCHER = /^[^\s:"\[]+\s*[=:](\s|$)/
130
-
131
- # The regex that matches and extracts data from
132
- # properties of the form `name: prop`.
133
- PROPERTY_NEW = /^([^\s=:"]+)\s*(=|:)(?:\s+|$)(.*)/
134
-
135
124
  # The regex that matches and extracts data from
136
125
  # properties of the form `:name prop`.
137
- PROPERTY_OLD = /^:([^\s=:"]+)\s*(=?)(?:\s+|$)(.*)/
126
+ PROPERTY_OLD = /^:([^\s=:"]+)\s*(?:\s+|$)(.*)/
138
127
 
139
128
  # The default options for Sass::Engine.
140
129
  # @api public
@@ -533,19 +522,19 @@ WARNING
533
522
  when PROPERTY_CHAR
534
523
  if line.text[1] == PROPERTY_CHAR ||
535
524
  (@options[:property_syntax] == :new &&
536
- line.text =~ PROPERTY_OLD && $3.empty?)
525
+ line.text =~ PROPERTY_OLD && $2.empty?)
537
526
  # Support CSS3-style pseudo-elements,
538
527
  # which begin with ::,
539
528
  # as well as pseudo-classes
540
529
  # if we're using the new property syntax
541
530
  Tree::RuleNode.new(parse_interp(line.text))
542
531
  else
543
- name, eq, value = line.text.scan(PROPERTY_OLD)[0]
532
+ name, value = line.text.scan(PROPERTY_OLD)[0]
544
533
  raise SyntaxError.new("Invalid property: \"#{line.text}\".",
545
534
  :line => @line) if name.nil? || value.nil?
546
- parse_property(name, parse_interp(name), eq, value, :old, line)
535
+ parse_property(name, parse_interp(name), value, :old, line)
547
536
  end
548
- when ?!, ?$
537
+ when ?$
549
538
  parse_variable(line)
550
539
  when COMMENT_CHAR
551
540
  parse_comment(line.text)
@@ -580,48 +569,39 @@ WARNING
580
569
  end
581
570
 
582
571
  name = line.text[0...scanner.pos]
583
- if scanner.scan(/\s*([:=])(?:\s|$)/)
584
- parse_property(name, res, scanner[1], scanner.rest, :new, line)
572
+ if scanner.scan(/\s*:(?:\s|$)/)
573
+ parse_property(name, res, scanner.rest, :new, line)
585
574
  else
586
575
  res.pop if comment
587
576
  Tree::RuleNode.new(res + parse_interp(scanner.rest))
588
577
  end
589
578
  end
590
579
 
591
- def parse_property(name, parsed_name, eq, value, prop, line)
580
+ def parse_property(name, parsed_name, value, prop, line)
592
581
  if value.strip.empty?
593
582
  expr = Sass::Script::String.new("")
594
583
  else
584
+ important = false
585
+ if value =~ Sass::SCSS::RX::IMPORTANT
586
+ important = true
587
+ value = value.gsub(Sass::SCSS::RX::IMPORTANT,"")
588
+ end
595
589
  expr = parse_script(value, :offset => line.offset + line.text.index(value))
596
590
 
597
- if eq.strip[0] == SCRIPT_CHAR
598
- expr.context = :equals
599
- Script.equals_warning("properties", name,
600
- Sass::Tree::PropNode.val_to_sass(expr, @options), false,
601
- @line, line.offset + 1, @options[:filename])
602
- end
603
591
  end
604
- Tree::PropNode.new(parse_interp(name), expr, prop)
592
+ Tree::PropNode.new(parse_interp(name), expr, important, prop)
605
593
  end
606
594
 
607
595
  def parse_variable(line)
608
- name, op, value, default = line.text.scan(Script::MATCH)[0]
609
- guarded = op =~ /^\|\|/
596
+ name, value, default = line.text.scan(Script::MATCH)[0]
610
597
  raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath variable declarations.",
611
598
  :line => @line + 1) unless line.children.empty?
612
599
  raise SyntaxError.new("Invalid variable: \"#{line.text}\".",
613
600
  :line => @line) unless name && value
614
- Script.var_warning(name, @line, line.offset + 1, @options[:filename]) if line.text[0] == ?!
615
601
 
616
602
  expr = parse_script(value, :offset => line.offset + line.text.index(value))
617
- if op =~ /=$/
618
- expr.context = :equals
619
- type = guarded ? "variable defaults" : "variables"
620
- Script.equals_warning(type, "$#{name}", expr.to_sass,
621
- guarded, @line, line.offset + 1, @options[:filename])
622
- end
623
603
 
624
- Tree::VariableNode.new(name, expr, default || guarded)
604
+ Tree::VariableNode.new(name, expr, default)
625
605
  end
626
606
 
627
607
  def parse_comment(line)
@@ -712,11 +692,8 @@ WARNING
712
692
  raise SyntaxError.new("Invalid for directive '@for #{text}': expected #{expected}.")
713
693
  end
714
694
  raise SyntaxError.new("Invalid variable \"#{var}\".") unless var =~ Script::VALIDATE
715
- if var.slice!(0) == ?!
716
- offset = line.offset + line.text.index("!" + var) + 1
717
- Script.var_warning(var, @line, offset, @options[:filename])
718
- end
719
695
 
696
+ var = var[1..-1]
720
697
  parsed_from = parse_script(from_expr, :offset => line.offset + line.text.index(from_expr))
721
698
  parsed_to = parse_script(to_expr, :offset => line.offset + line.text.index(to_expr))
722
699
  Tree::ForNode.new(var, parsed_from, parsed_to, to_name == 'to')
@@ -734,11 +711,8 @@ WARNING
734
711
  raise SyntaxError.new("Invalid for directive '@each #{text}': expected #{expected}.")
735
712
  end
736
713
  raise SyntaxError.new("Invalid variable \"#{var}\".") unless var =~ Script::VALIDATE
737
- if var.slice!(0) == ?!
738
- offset = line.offset + line.text.index("!" + var) + 1
739
- Script.var_warning(var, @line, offset, @options[:filename])
740
- end
741
714
 
715
+ var = var[1..-1]
742
716
  parsed_list = parse_script(list_expr, :offset => line.offset + line.text.index(list_expr))
743
717
  Tree::EachNode.new(var, parsed_list)
744
718
  end
@@ -325,6 +325,7 @@ END
325
325
  end
326
326
  end
327
327
  Compass.add_project_configuration
328
+ Compass.configuration.project_path ||= Dir.pwd
328
329
  @options[:for_engine][:load_paths] += Compass.configuration.sass_load_paths
329
330
  end
330
331
 
@@ -447,12 +448,11 @@ Options:
447
448
  END
448
449
 
449
450
  opts.on('-F', '--from FORMAT',
450
- 'The format to convert from. Can be css, scss, sass, less, or sass2.',
451
- 'sass2 is the same as sass, but updates more old syntax to new.',
451
+ 'The format to convert from. Can be css, scss, sass, less.',
452
452
  'By default, this is inferred from the input filename.',
453
453
  'If there is none, defaults to css.') do |name|
454
454
  @options[:from] = name.downcase.to_sym
455
- unless [:css, :scss, :sass, :less, :sass2].include?(@options[:from])
455
+ unless [:css, :scss, :sass, :less].include?(@options[:from])
456
456
  raise "Unknown format for sass-convert --from: #{name}"
457
457
  end
458
458
  try_less_note if @options[:from] == :less
@@ -536,14 +536,12 @@ END
536
536
  @options[:output] ||= @options[:input]
537
537
 
538
538
  from = @options[:from]
539
- from = :sass if from == :sass2
540
539
  if @options[:to] == @options[:from] && !@options[:in_place]
541
540
  fmt = @options[:from]
542
541
  raise "Error: converting from #{fmt} to #{fmt} without --in-place"
543
542
  end
544
543
 
545
544
  ext = @options[:from]
546
- ext = :sass if ext == :sass2
547
545
  Dir.glob("#{@options[:input]}/**/*.#{ext}") do |f|
548
546
  output =
549
547
  if @options[:in_place]
@@ -594,11 +592,6 @@ END
594
592
  end
595
593
  end
596
594
 
597
- if @options[:from] == :sass2
598
- @options[:from] = :sass
599
- @options[:for_engine][:sass2] = true
600
- end
601
-
602
595
  @options[:from] ||= :css
603
596
  @options[:to] ||= :sass
604
597
  @options[:for_engine][:syntax] = @options[:from]
@@ -25,8 +25,8 @@ module Sass
25
25
 
26
26
  # @see Base#mtime
27
27
  def mtime(name, options)
28
- file = find_real_file(@root, name)
29
- File.mtime(name)
28
+ file, s = find_real_file(@root, name)
29
+ File.mtime(file) if file
30
30
  rescue Errno::ENOENT
31
31
  nil
32
32
  end
@@ -67,13 +67,12 @@ module Sass
67
67
  sorted_exts = extensions.sort
68
68
  syntax = extensions[extname]
69
69
 
70
- Sass::Util.flatten(
71
- ["#{dirname}/#{basename}", "#{dirname}/_#{basename}"].map do |name|
72
- next [["#{name}.#{extensions.invert[syntax]}", syntax]] if syntax
73
- sorted_exts.map {|ext, syn| ["#{name}.#{ext}", syn]}
74
- end, 1)
70
+ return [["#{dirname}/{_,}#{basename}.#{extensions.invert[syntax]}", syntax]] if syntax
71
+ sorted_exts.map {|ext, syn| ["#{dirname}/{_,}#{basename}.#{ext}", syn]}
75
72
  end
76
73
 
74
+
75
+ REDUNDANT_DIRECTORY = %r{#{Regexp.escape(File::SEPARATOR)}\.#{Regexp.escape(File::SEPARATOR)}}
77
76
  # Given a base directory and an `@import`ed name,
78
77
  # finds an existant file that matches the name.
79
78
  #
@@ -81,8 +80,10 @@ module Sass
81
80
  # @param name [String] The filename to search for.
82
81
  # @return [(String, Symbol)] A filename-syntax pair.
83
82
  def find_real_file(dir, name)
84
- possible_files(name).each do |f, s|
85
- if File.exists?(full_path = join(dir, f))
83
+ for (f,s) in possible_files(name)
84
+ path = (dir == ".") ? f : "#{dir}/#{f}"
85
+ if full_path = Dir[path].first
86
+ full_path.gsub!(REDUNDANT_DIRECTORY,File::SEPARATOR)
86
87
  return full_path, s
87
88
  end
88
89
  end
@@ -225,7 +225,7 @@ WARNING
225
225
  class Property
226
226
  def to_sass_tree
227
227
  return if hide_in_sass
228
- Sass::Tree::PropNode.new([self], @value.to_sass_tree, :new)
228
+ Sass::Tree::PropNode.new([self], @value.to_sass_tree, false, :new)
229
229
  end
230
230
  end
231
231
 
@@ -41,7 +41,7 @@ module Sass
41
41
  # (in this Ruby instance).
42
42
  #
43
43
  # @return [Boolean]
44
- attr_reader :checked_for_updates
44
+ attr_accessor :checked_for_updates
45
45
 
46
46
  # Same as \{#update\_stylesheets}, but respects \{#checked\_for\_updates}
47
47
  # and the {file:SASS_REFERENCE.md#always_update-option `:always_update`}
@@ -161,7 +161,7 @@ module Sass::Plugin
161
161
  # the second is the location of the CSS file that it should be compiled to.
162
162
  def update_stylesheets(individual_files = [])
163
163
  run_updating_stylesheets individual_files
164
- @checked_for_updates = true
164
+ Sass::Plugin.checked_for_updates = true
165
165
  staleness_checker = StalenessChecker.new(engine_options)
166
166
 
167
167
  individual_files.each do |t, c|
@@ -174,7 +174,7 @@ module Sass::Plugin
174
174
 
175
175
  Dir.glob(File.join(template_location, "**", "[^_]*.s[ca]ss")).sort.each do |file|
176
176
  # Get the relative path to the file
177
- name = file.sub(template_location.sub(/\/*$/, '/'), "")
177
+ name = file.sub(template_location.to_s.sub(/\/*$/, '/'), "")
178
178
  css = css_filename(name, css_location)
179
179
 
180
180
  if options[:always_update] || staleness_checker.stylesheet_needs_update?(css, file)
@@ -13,10 +13,10 @@ module Sass
13
13
  # This module contains code that handles the parsing and evaluation of SassScript.
14
14
  module Script
15
15
  # The regular expression used to parse variables.
16
- MATCH = /^[!\$](#{Sass::SCSS::RX::IDENT})\s*((?:\|\|)?=|:)\s*(.+?)(!(?i:default))?$/
16
+ MATCH = /^\$(#{Sass::SCSS::RX::IDENT})\s*:\s*(.+?)(!(?i:default))?$/
17
17
 
18
18
  # The regular expression used to validate variables without matching.
19
- VALIDATE = /^[!\$]#{Sass::SCSS::RX::IDENT}$/
19
+ VALIDATE = /^\$#{Sass::SCSS::RX::IDENT}$/
20
20
 
21
21
  # Parses a string of SassScript
22
22
  #
@@ -36,28 +36,5 @@ module Sass
36
36
  raise e
37
37
  end
38
38
 
39
- # @private
40
- def self.var_warning(varname, line, offset, filename)
41
- Sass::Util.sass_warn <<MESSAGE
42
- DEPRECATION WARNING:
43
- On line #{line}, character #{offset}#{" of '#{filename}'" if filename}
44
- Variables with ! have been deprecated and will be removed in version 3.2.
45
- Use \"$#{varname}\" instead.
46
-
47
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
48
- MESSAGE
49
- end
50
-
51
- # @private
52
- def self.equals_warning(types, name, val, guarded, line, offset, filename)
53
- Sass::Util.sass_warn <<MESSAGE
54
- DEPRECATION WARNING:
55
- On line #{line}#{", character #{offset}" if offset}#{" of '#{filename}'" if filename}
56
- Setting #{types} with #{"||" if guarded}= has been deprecated and will be removed in version 3.2.
57
- Use "#{name}: #{val}#{" !default" if guarded}" instead.
58
-
59
- You can use `sass-convert --in-place --from sass2 file.sass' to convert files automatically.
60
- MESSAGE
61
- end
62
39
  end
63
40
  end
@@ -182,17 +182,6 @@ module Sass::Script
182
182
  alpha < 1
183
183
  end
184
184
 
185
- # @deprecated This will be removed in version 3.2.
186
- # @see #rgb
187
- def value
188
- Sass::Util.sass_warn <<END
189
- DEPRECATION WARNING:
190
- The Sass::Script::Color #value attribute is deprecated and will be
191
- removed in version 3.2. Use the #rgb attribute instead.
192
- END
193
- rgb
194
- end
195
-
196
185
  # Returns the red, green, and blue components of the color.
197
186
  #
198
187
  # @return [Array<Fixnum>] A frozen three-element array of the red, green, and blue
@@ -23,15 +23,6 @@ module Sass
23
23
  # @return [{String => Script::Node}]
24
24
  attr_reader :keywords
25
25
 
26
- # Don't set the context for child nodes if this is `url()`,
27
- # since `url()` allows quoted strings.
28
- #
29
- # @param context [Symbol]
30
- # @see Node#context=
31
- def context=(context)
32
- super unless @name == "url"
33
- end
34
-
35
26
  # @param name [String] See \{#name}
36
27
  # @param args [Array<Script::Node>] See \{#args}
37
28
  # @param keywords [{String => Script::Node}] See \{#keywords}
@@ -329,30 +329,20 @@ module Sass::Script
329
329
  end
330
330
 
331
331
  class << self
332
- FUNCTIONS = Set.new
333
-
334
332
  # Returns whether user function with a given name exists.
335
333
  #
336
334
  # @param function_name [String]
337
335
  # @return [Boolean]
338
- def callable?(function_name)
339
- FUNCTIONS.include?(function_name)
340
- end
336
+ alias_method :callable?, :public_method_defined?
341
337
 
342
338
  private
343
339
  def include(*args)
344
340
  r = super
345
- update_callable_functions
346
341
  # We have to re-include ourselves into EvaluationContext to work around
347
342
  # an icky Ruby restriction.
348
343
  EvaluationContext.send :include, self
349
344
  r
350
345
  end
351
-
352
- def update_callable_functions
353
- FUNCTIONS.clear
354
- public_instance_methods.each {|function_name| FUNCTIONS << function_name.to_s}
355
- end
356
346
  end
357
347
 
358
348
  # Creates a {Color} object from red, green, and blue values.
@@ -1347,15 +1337,5 @@ module Sass::Script
1347
1337
  color.with(attr => Sass::Util.restrict(
1348
1338
  color.send(attr).send(op, amount.value), range))
1349
1339
  end
1350
-
1351
- class << self
1352
- private
1353
- def method_added(name)
1354
- update_callable_functions
1355
- super
1356
- end
1357
- end
1358
-
1359
- update_callable_functions # generate the initial set
1360
1340
  end
1361
1341
  end
@@ -87,7 +87,7 @@ module Sass
87
87
  :whitespace => /\s+/,
88
88
  :comment => COMMENT,
89
89
  :single_line_comment => SINGLE_LINE_COMMENT,
90
- :variable => /([!\$])(#{IDENT})/,
90
+ :variable => /(\$)(#{IDENT})/,
91
91
  :ident => /(#{IDENT})(\()?/,
92
92
  :number => /(-)?(?:(\d*\.\d+)|(\d+))([a-zA-Z%]+)?/,
93
93
  :color => HEXCOLOR,
@@ -242,9 +242,6 @@ module Sass
242
242
  line = @line
243
243
  offset = @offset
244
244
  return unless scan(rx)
245
- if @scanner[1] == '!' && @scanner[2] != 'important'
246
- Script.var_warning(@scanner[2], line, offset + 1, @options[:filename])
247
- end
248
245
 
249
246
  [:const, @scanner[2]]
250
247
  end