sass 3.2.0.alpha.11 → 3.2.0.alpha.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/REVISION +1 -1
  2. data/VERSION +1 -1
  3. data/lib/sass/cache_stores/base.rb +4 -9
  4. data/lib/sass/cache_stores/filesystem.rb +2 -0
  5. data/lib/sass/css.rb +2 -1
  6. data/lib/sass/engine.rb +28 -8
  7. data/lib/sass/environment.rb +26 -0
  8. data/lib/sass/exec.rb +13 -0
  9. data/lib/sass/importers/base.rb +2 -1
  10. data/lib/sass/script/funcall.rb +8 -0
  11. data/lib/sass/script/interpolation.rb +9 -0
  12. data/lib/sass/script/list.rb +7 -0
  13. data/lib/sass/script/literal.rb +5 -0
  14. data/lib/sass/script/node.rb +8 -0
  15. data/lib/sass/script/number.rb +28 -5
  16. data/lib/sass/script/operation.rb +8 -0
  17. data/lib/sass/script/string_interpolation.rb +9 -0
  18. data/lib/sass/script/unary_operation.rb +7 -0
  19. data/lib/sass/script/variable.rb +5 -0
  20. data/lib/sass/scss/parser.rb +26 -13
  21. data/lib/sass/scss/rx.rb +1 -1
  22. data/lib/sass/scss/static_parser.rb +2 -2
  23. data/lib/sass/tree/content_node.rb +9 -0
  24. data/lib/sass/tree/debug_node.rb +1 -6
  25. data/lib/sass/tree/each_node.rb +1 -7
  26. data/lib/sass/tree/extend_node.rb +1 -1
  27. data/lib/sass/tree/for_node.rb +2 -7
  28. data/lib/sass/tree/function_node.rb +1 -6
  29. data/lib/sass/tree/if_node.rb +1 -19
  30. data/lib/sass/tree/mixin_def_node.rb +5 -6
  31. data/lib/sass/tree/mixin_node.rb +2 -7
  32. data/lib/sass/tree/node.rb +4 -19
  33. data/lib/sass/tree/prop_node.rb +0 -5
  34. data/lib/sass/tree/return_node.rb +1 -6
  35. data/lib/sass/tree/rule_node.rb +9 -7
  36. data/lib/sass/tree/trace_node.rb +32 -0
  37. data/lib/sass/tree/variable_node.rb +1 -7
  38. data/lib/sass/tree/visitors/check_nesting.rb +30 -13
  39. data/lib/sass/tree/visitors/convert.rb +5 -1
  40. data/lib/sass/tree/visitors/cssize.rb +3 -3
  41. data/lib/sass/tree/visitors/deep_copy.rb +87 -0
  42. data/lib/sass/tree/visitors/perform.rb +36 -16
  43. data/lib/sass/tree/visitors/set_options.rb +97 -0
  44. data/lib/sass/tree/visitors/to_css.rb +5 -1
  45. data/lib/sass/tree/warn_node.rb +1 -7
  46. data/lib/sass/tree/while_node.rb +1 -7
  47. data/test/sass/cache_test.rb +15 -0
  48. data/test/sass/conversion_test.rb +38 -0
  49. data/test/sass/css2sass_test.rb +9 -0
  50. data/test/sass/engine_test.rb +248 -17
  51. data/test/sass/scss/css_test.rb +4 -2
  52. data/test/sass/scss/scss_test.rb +53 -12
  53. data/vendor/fssm/Gemfile +3 -0
  54. data/vendor/fssm/LICENSE +1 -1
  55. data/vendor/fssm/README.markdown +55 -27
  56. data/vendor/fssm/Rakefile +6 -54
  57. data/vendor/fssm/example.rb +6 -3
  58. data/vendor/fssm/fssm.gemspec +17 -70
  59. data/vendor/fssm/lib/fssm.rb +7 -3
  60. data/vendor/fssm/lib/fssm/backends/fsevents.rb +1 -1
  61. data/vendor/fssm/lib/fssm/backends/inotify.rb +2 -2
  62. data/vendor/fssm/lib/fssm/backends/polling.rb +2 -2
  63. data/vendor/fssm/lib/fssm/backends/rbfsevent.rb +42 -0
  64. data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +10 -10
  65. data/vendor/fssm/lib/fssm/monitor.rb +19 -9
  66. data/vendor/fssm/lib/fssm/path.rb +24 -21
  67. data/vendor/fssm/lib/fssm/pathname.rb +13 -479
  68. data/vendor/fssm/lib/fssm/state/directory.rb +29 -11
  69. data/vendor/fssm/lib/fssm/state/file.rb +1 -1
  70. data/vendor/fssm/lib/fssm/support.rb +41 -12
  71. data/vendor/fssm/lib/fssm/tree.rb +6 -6
  72. data/vendor/fssm/lib/fssm/version.rb +3 -0
  73. data/vendor/fssm/profile/prof-cache.rb +3 -3
  74. data/vendor/fssm/profile/prof-pathname-rubinius.rb +35 -0
  75. data/vendor/fssm/profile/prof-pathname.rb +7 -7
  76. data/vendor/fssm/spec/count_down_latch.rb +151 -0
  77. data/vendor/fssm/spec/monitor_spec.rb +202 -0
  78. data/vendor/fssm/spec/path_spec.rb +36 -15
  79. data/vendor/fssm/spec/spec_helper.rb +6 -6
  80. metadata +14 -4
  81. data/vendor/fssm/VERSION.yml +0 -5
@@ -110,7 +110,7 @@ module Sass
110
110
  # Custom
111
111
  HEXCOLOR = /\#[0-9a-fA-F]+/
112
112
  INTERP_START = /#\{/
113
- MOZ_ANY = quote(":-moz-any(", Regexp::IGNORECASE)
113
+ ANY = /:(-[-\w]+-)?any\(/i
114
114
 
115
115
  STRING1_NOINTERP = /\"((?:[^\n\r\f\\"#]|#(?!\{)|\\#{NL}|#{ESCAPE})*)\"/
116
116
  STRING2_NOINTERP = /\'((?:[^\n\r\f\\'#]|#(?!\{)|\\#{NL}|#{ESCAPE})*)\'/
@@ -13,12 +13,12 @@ module Sass
13
13
  # Used for error reporting.
14
14
  # @return [Selector::CommaSequence] The parsed selector
15
15
  # @raise [Sass::SyntaxError] if there's a syntax error in the selector
16
- def parse_selector(filename)
16
+ def parse_selector
17
17
  init_scanner!
18
18
  seq = expr!(:selector_comma_sequence)
19
19
  expected("selector") unless @scanner.eos?
20
20
  seq.line = @line
21
- seq.filename = filename
21
+ seq.filename = @filename
22
22
  seq
23
23
  end
24
24
 
@@ -0,0 +1,9 @@
1
+ module Sass
2
+ module Tree
3
+ # A node representing the placement within a mixin of the include statement's content.
4
+ #
5
+ # @see Sass::Tree
6
+ class ContentNode < Node
7
+ end
8
+ end
9
+ end
@@ -6,12 +6,7 @@ module Sass
6
6
  class DebugNode < Node
7
7
  # The expression to print.
8
8
  # @return [Script::Node]
9
- attr_reader :expr
10
-
11
- # Returns sub nodes that are not tree children.
12
- def subnodes
13
- Array(expr)
14
- end
9
+ attr_accessor :expr
15
10
 
16
11
  # @param expr [Script::Node] The expression to print
17
12
  def initialize(expr)
@@ -11,7 +11,7 @@ module Sass::Tree
11
11
 
12
12
  # The parse tree for the list.
13
13
  # @param [Script::Node]
14
- attr_reader :list
14
+ attr_accessor :list
15
15
 
16
16
  # @param var [String] The name of the loop variable
17
17
  # @param list [Script::Node] The parse tree for the list
@@ -20,11 +20,5 @@ module Sass::Tree
20
20
  @list = list
21
21
  super()
22
22
  end
23
-
24
- # Returns sub nodes that are not tree children.
25
- def subnodes
26
- Array(list)
27
- end
28
-
29
23
  end
30
24
  end
@@ -15,7 +15,7 @@ module Sass::Tree
15
15
  # representing `#{}`-interpolation.
16
16
  #
17
17
  # @return [Array<String, Sass::Script::Node>]
18
- attr_reader :selector
18
+ attr_accessor :selector
19
19
 
20
20
  # @param selector [Array<String, Sass::Script::Node>]
21
21
  # The CSS selector to extend,
@@ -11,11 +11,11 @@ module Sass::Tree
11
11
 
12
12
  # The parse tree for the initial expression.
13
13
  # @return [Script::Node]
14
- attr_reader :from
14
+ attr_accessor :from
15
15
 
16
16
  # The parse tree for the final expression.
17
17
  # @return [Script::Node]
18
- attr_reader :to
18
+ attr_accessor :to
19
19
 
20
20
  # Whether to include `to` in the loop or stop just before.
21
21
  # @return [Boolean]
@@ -32,10 +32,5 @@ module Sass::Tree
32
32
  @exclusive = exclusive
33
33
  super()
34
34
  end
35
-
36
- # Returns sub nodes that are not tree children.
37
- def subnodes
38
- Array(from) + Array(to)
39
- end
40
35
  end
41
36
  end
@@ -13,7 +13,7 @@ module Sass
13
13
  # the default value of the argument
14
14
  #
15
15
  # @return [Array<Script::Node>]
16
- attr_reader :args
16
+ attr_accessor :args
17
17
 
18
18
  # @param name [String] The function name
19
19
  # @param args [Array<(Script::Node, Script::Node)>] The arguments for the function.
@@ -22,11 +22,6 @@ module Sass
22
22
  @args = args
23
23
  super()
24
24
  end
25
-
26
- # Returns sub nodes that are not tree children.
27
- def subnodes
28
- Array(args)
29
- end
30
25
  end
31
26
  end
32
27
  end
@@ -13,7 +13,7 @@ module Sass::Tree
13
13
  # If this is nil, this is an `@else` node, not an `@else if`.
14
14
  #
15
15
  # @return [Script::Expr]
16
- attr_reader :expr
16
+ attr_accessor :expr
17
17
 
18
18
  # The next {IfNode} in the if-else list, or `nil`.
19
19
  #
@@ -35,12 +35,6 @@ module Sass::Tree
35
35
  @last_else = node
36
36
  end
37
37
 
38
- # @see Node#options=
39
- def options=(options)
40
- super
41
- self.else.options = options if self.else
42
- end
43
-
44
38
  def _dump(f)
45
39
  Marshal.dump([self.expr, self.else, self.children])
46
40
  end
@@ -54,17 +48,5 @@ module Sass::Tree
54
48
  node.else ? node.else.instance_variable_get('@last_else') : node)
55
49
  node
56
50
  end
57
-
58
- # @see Node#deep_copy
59
- def deep_copy
60
- node = super
61
- node.else = self.else.deep_copy if self.else
62
- node
63
- end
64
-
65
- # Returns sub nodes that are not tree children.
66
- def subnodes
67
- Array(expr) + Array(self.else)
68
- end
69
51
  end
70
52
  end
@@ -13,7 +13,11 @@ module Sass
13
13
  # and the parse tree for the default value of the argument.
14
14
  #
15
15
  # @return [Array<(Script::Node, Script::Node)>]
16
- attr_reader :args
16
+ attr_accessor :args
17
+
18
+ # Whether the mixin uses `@content`. Set during the nesting check phase.
19
+ # @return [Boolean]
20
+ attr_accessor :has_content
17
21
 
18
22
  # @param name [String] The mixin name
19
23
  # @param args [Array<(Script::Node, Script::Node)>] See \{#args}
@@ -22,11 +26,6 @@ module Sass
22
26
  @args = args
23
27
  super()
24
28
  end
25
-
26
- # Returns sub nodes that are not tree children.
27
- def subnodes
28
- Array(args)
29
- end
30
29
  end
31
30
  end
32
31
  end
@@ -13,11 +13,11 @@ module Sass::Tree
13
13
 
14
14
  # The arguments to the mixin.
15
15
  # @return [Array<Script::Node>]
16
- attr_reader :args
16
+ attr_accessor :args
17
17
 
18
18
  # A hash from keyword argument names to values.
19
19
  # @return [{String => Script::Node}]
20
- attr_reader :keywords
20
+ attr_accessor :keywords
21
21
 
22
22
  # @param name [String] The name of the mixin
23
23
  # @param args [Array<Script::Node>] See \{#args}
@@ -28,10 +28,5 @@ module Sass::Tree
28
28
  @keywords = keywords
29
29
  super()
30
30
  end
31
-
32
- # Returns sub nodes that are not tree children.
33
- def subnodes
34
- Array(args) + (keywords||{}).values
35
- end
36
31
  end
37
32
  end
@@ -14,7 +14,8 @@ module Sass
14
14
  # The nodes in this state are in the same structure as the Sass document:
15
15
  # rules and properties are nested beneath one another.
16
16
  # Nodes that can be in this state or in the dynamic state
17
- # are called **static nodes**.
17
+ # are called **static nodes**; nodes that can only be in this state
18
+ # are called **solely static nodes**.
18
19
  #
19
20
  # {Tree::Visitors::Cssize} is then used to create a static CSS tree.
20
21
  # This is like a static Sass tree,
@@ -65,11 +66,7 @@ module Sass
65
66
  # @param options [{Symbol => Object}] The options
66
67
  # @see #options
67
68
  def options=(options)
68
- children.each {|c| c.options = options}
69
- if respond_to?(:subnodes)
70
- subnodes.each {|n| n.options = options if n.respond_to?(:options=)}
71
- end
72
- @options = options
69
+ Sass::Tree::Visitors::SetOptions.visit(self, options)
73
70
  end
74
71
 
75
72
  # @private
@@ -188,19 +185,7 @@ module Sass
188
185
  #
189
186
  # @return [Node]
190
187
  def deep_copy
191
- node = dup
192
- node.children = children.map {|c| c.deep_copy}
193
- node
194
- end
195
-
196
- def before_sass_cache_store
197
- o = self.options
198
- self.options = {}
199
- return o
200
- end
201
-
202
- def after_sass_cache_store(o)
203
- self.options = o
188
+ Sass::Tree::Visitors::DeepCopy.visit(self)
204
189
  end
205
190
 
206
191
  protected
@@ -55,11 +55,6 @@ module Sass::Tree
55
55
  super()
56
56
  end
57
57
 
58
- # Returns sub nodes that are not tree children.
59
- def subnodes
60
- Array(name).select{|n| n.is_a?(Sass::Script::Node)} + [value]
61
- end
62
-
63
58
  # Compares the names and values of two properties.
64
59
  #
65
60
  # @param other [Object] The object to compare with
@@ -6,18 +6,13 @@ module Sass
6
6
  class ReturnNode < Node
7
7
  # The expression to return.
8
8
  # @type [Script::Node]
9
- attr_reader :expr
9
+ attr_accessor :expr
10
10
 
11
11
  # @param expr [Script::Node] The expression to return
12
12
  def initialize(expr)
13
13
  @expr = expr
14
14
  super()
15
15
  end
16
-
17
- # Returns sub nodes that are not tree children.
18
- def subnodes
19
- Array(expr)
20
- end
21
16
  end
22
17
  end
23
18
  end
@@ -50,6 +50,13 @@ module Sass::Tree
50
50
  # @return [Boolean]
51
51
  attr_accessor :group_end
52
52
 
53
+ # The stack trace.
54
+ # This is only readable in a CSS tree as it is written during the perform step
55
+ # and only when the :trace_selectors option is set.
56
+ #
57
+ # @return [Array<String>]
58
+ attr_accessor :stack_trace
59
+
53
60
  # @param rule [Array<String, Sass::Script::Node>]
54
61
  # The CSS rule. See \{#rule}
55
62
  def initialize(rule)
@@ -115,19 +122,14 @@ module Sass::Tree
115
122
  :line => self.line}
116
123
  end
117
124
 
118
- # Returns sub nodes that are not tree children.
119
- def subnodes
120
- rule.select{|r| r.is_a?(Sass::Script::Node)}
121
- end
122
-
123
125
  private
124
126
 
125
127
  def try_to_parse_non_interpolated_rules
126
128
  if @rule.all? {|t| t.kind_of?(String)}
127
129
  # We don't use real filename/line info because we don't have it yet.
128
130
  # When we get it, we'll set it on the parsed rules if possible.
129
- parser = Sass::SCSS::StaticParser.new(@rule.join.strip, 1)
130
- @parsed_rules = parser.parse_selector('') rescue nil
131
+ parser = Sass::SCSS::StaticParser.new(@rule.join.strip, '', 1)
132
+ @parsed_rules = parser.parse_selector rescue nil
131
133
  end
132
134
  end
133
135
  end
@@ -0,0 +1,32 @@
1
+ require 'sass/tree/node'
2
+
3
+ module Sass::Tree
4
+ # A solely static node left over after a mixin include or @content has been performed.
5
+ # Its sole purpose is to wrap exceptions to add to the backtrace.
6
+ #
7
+ # @see Sass::Tree
8
+ class TraceNode < Node
9
+ # The name of the trace entry to add.
10
+ # @return [String]
11
+ attr_reader :name
12
+
13
+ # @param name [String] The name of the trace entry to add.
14
+ def initialize(name)
15
+ @name = name
16
+ self.has_children = true
17
+ super()
18
+ end
19
+
20
+ # Initializes this node from an existing node.
21
+ # @param name [String] The name of the trace entry to add.
22
+ # @param mixin [Node] The node to copy information from.
23
+ # @return [TraceNode]
24
+ def self.from_node(name, node)
25
+ trace = new(name)
26
+ trace.line = node.line
27
+ trace.filename = node.filename
28
+ trace.options = node.options
29
+ trace
30
+ end
31
+ end
32
+ end
@@ -10,7 +10,7 @@ module Sass
10
10
 
11
11
  # The parse tree for the variable value.
12
12
  # @return [Script::Node]
13
- attr_reader :expr
13
+ attr_accessor :expr
14
14
 
15
15
  # Whether this is a guarded variable assignment (`!default`).
16
16
  # @return [Boolean]
@@ -25,12 +25,6 @@ module Sass
25
25
  @guarded = guarded
26
26
  super()
27
27
  end
28
-
29
- # Returns sub nodes that are not tree children.
30
- def subnodes
31
- Array(expr)
32
- end
33
-
34
28
  end
35
29
  end
36
30
  end
@@ -18,7 +18,7 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
18
18
  end
19
19
 
20
20
  PARENT_CLASSES = [ Sass::Tree::EachNode, Sass::Tree::ForNode, Sass::Tree::IfNode,
21
- Sass::Tree::ImportNode, Sass::Tree::MixinNode, Sass::Tree::WhileNode]
21
+ Sass::Tree::ImportNode, Sass::Tree::TraceNode, Sass::Tree::WhileNode]
22
22
  def visit_children(parent)
23
23
  old_parent = @parent
24
24
  @parent = parent unless is_any_of?(parent, PARENT_CLASSES)
@@ -44,13 +44,29 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
44
44
  raise e
45
45
  end
46
46
 
47
+ def visit_mixindef(node)
48
+ @current_mixin_def, old_mixin_def = node, @current_mixin_def
49
+ yield
50
+ ensure
51
+ @current_mixin_def = old_mixin_def
52
+ end
53
+
54
+ def invalid_content_parent?(parent, child)
55
+ if @current_mixin_def
56
+ @current_mixin_def.has_content = true
57
+ nil
58
+ else
59
+ "@content may only be used within a mixin."
60
+ end
61
+ end
62
+
47
63
  def invalid_charset_parent?(parent, child)
48
64
  "@charset may only be used at the root of a document." unless parent.is_a?(Sass::Tree::RootNode)
49
65
  end
50
66
 
51
- INVALID_EXTEND_PARENTS = [Sass::Tree::RuleNode, Sass::Tree::MixinDefNode]
67
+ VALID_EXTEND_PARENTS = [Sass::Tree::RuleNode, Sass::Tree::MixinDefNode, Sass::Tree::MixinNode]
52
68
  def invalid_extend_parent?(parent, child)
53
- unless is_any_of?(parent, INVALID_EXTEND_PARENTS)
69
+ unless is_any_of?(parent, VALID_EXTEND_PARENTS)
54
70
  "Extend directives may only be used within rules."
55
71
  end
56
72
  end
@@ -59,20 +75,20 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
59
75
  "Functions may only be defined at the root of a document." unless parent.is_a?(Sass::Tree::RootNode)
60
76
  end
61
77
 
62
- INVALID_FUNCTION_CHILDREN = [
78
+ VALID_FUNCTION_CHILDREN = [
63
79
  Sass::Tree::CommentNode, Sass::Tree::DebugNode, Sass::Tree::EachNode,
64
80
  Sass::Tree::ForNode, Sass::Tree::IfNode, Sass::Tree::ReturnNode,
65
81
  Sass::Tree::VariableNode, Sass::Tree::WarnNode, Sass::Tree::WhileNode
66
82
  ]
67
83
  def invalid_function_child?(parent, child)
68
- unless is_any_of?(child, INVALID_FUNCTION_CHILDREN)
84
+ unless is_any_of?(child, VALID_FUNCTION_CHILDREN)
69
85
  "Functions can only contain variable declarations and control directives."
70
86
  end
71
87
  end
72
88
 
73
89
  INVALID_IMPORT_PARENTS = [
74
- Sass::Tree::IfNode, Sass::Tree::ForNode, Sass::Tree::WhileNode,
75
- Sass::Tree::EachNode, Sass::Tree::MixinDefNode
90
+ Sass::Tree::IfNode, Sass::Tree::ForNode, Sass::Tree::WhileNode,
91
+ Sass::Tree::EachNode, Sass::Tree::MixinDefNode, Sass::Tree::MixinNode
76
92
  ]
77
93
  def invalid_import_parent?(parent, child)
78
94
  if is_any_of?(@real_parent, INVALID_IMPORT_PARENTS)
@@ -98,18 +114,19 @@ class Sass::Tree::Visitors::CheckNesting < Sass::Tree::Visitors::Base
98
114
  "Mixins may only be defined at the root of a document." unless parent.is_a?(Sass::Tree::RootNode)
99
115
  end
100
116
 
101
- INVALID_PROP_CHILDREN = [Sass::Tree::CommentNode, Sass::Tree::PropNode]
117
+ VALID_PROP_CHILDREN = [Sass::Tree::CommentNode, Sass::Tree::PropNode]
102
118
  def invalid_prop_child?(parent, child)
103
- unless is_any_of?(child, INVALID_PROP_CHILDREN)
119
+ unless is_any_of?(child, VALID_PROP_CHILDREN)
104
120
  "Illegal nesting: Only properties may be nested beneath properties."
105
121
  end
106
122
  end
107
123
 
108
- INVALID_PROP_PARENTS = [Sass::Tree::RuleNode, Sass::Tree::PropNode,
109
- Sass::Tree::MixinDefNode, Sass::Tree::DirectiveNode]
124
+ VALID_PROP_PARENTS = [Sass::Tree::RuleNode, Sass::Tree::PropNode,
125
+ Sass::Tree::MixinDefNode, Sass::Tree::DirectiveNode,
126
+ Sass::Tree::MixinNode]
110
127
  def invalid_prop_parent?(parent, child)
111
- unless is_any_of?(parent, INVALID_PROP_PARENTS)
112
- "Properties are only allowed within rules, directives, or other properties." + child.pseudo_class_selector_message
128
+ unless is_any_of?(parent, VALID_PROP_PARENTS)
129
+ "Properties are only allowed within rules, directives, mixin includes, or other properties." + child.pseudo_class_selector_message
113
130
  end
114
131
  end
115
132