sass 3.3.0 → 3.4.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -1
  3. data/CODE_OF_CONDUCT.md +10 -0
  4. data/CONTRIBUTING.md +148 -0
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +76 -62
  7. data/Rakefile +104 -24
  8. data/VERSION +1 -1
  9. data/VERSION_DATE +1 -1
  10. data/VERSION_NAME +1 -1
  11. data/bin/sass +1 -1
  12. data/bin/scss +1 -1
  13. data/extra/sass-spec-ref.sh +32 -0
  14. data/extra/update_watch.rb +1 -1
  15. data/lib/sass/cache_stores/filesystem.rb +9 -5
  16. data/lib/sass/cache_stores/memory.rb +4 -5
  17. data/lib/sass/callbacks.rb +2 -2
  18. data/lib/sass/css.rb +12 -13
  19. data/lib/sass/deprecation.rb +55 -0
  20. data/lib/sass/engine.rb +106 -70
  21. data/lib/sass/environment.rb +39 -19
  22. data/lib/sass/error.rb +17 -20
  23. data/lib/sass/exec/base.rb +199 -0
  24. data/lib/sass/exec/sass_convert.rb +283 -0
  25. data/lib/sass/exec/sass_scss.rb +440 -0
  26. data/lib/sass/exec.rb +5 -771
  27. data/lib/sass/features.rb +9 -2
  28. data/lib/sass/importers/base.rb +8 -3
  29. data/lib/sass/importers/filesystem.rb +30 -38
  30. data/lib/sass/logger/base.rb +8 -2
  31. data/lib/sass/logger/delayed.rb +50 -0
  32. data/lib/sass/logger.rb +8 -3
  33. data/lib/sass/media.rb +1 -4
  34. data/lib/sass/plugin/compiler.rb +224 -90
  35. data/lib/sass/plugin/configuration.rb +38 -22
  36. data/lib/sass/plugin/merb.rb +2 -2
  37. data/lib/sass/plugin/rack.rb +3 -3
  38. data/lib/sass/plugin/rails.rb +1 -1
  39. data/lib/sass/plugin/staleness_checker.rb +4 -4
  40. data/lib/sass/plugin.rb +6 -5
  41. data/lib/sass/script/css_lexer.rb +1 -1
  42. data/lib/sass/script/css_parser.rb +2 -3
  43. data/lib/sass/script/css_variable_warning.rb +52 -0
  44. data/lib/sass/script/functions.rb +739 -318
  45. data/lib/sass/script/lexer.rb +134 -54
  46. data/lib/sass/script/parser.rb +252 -56
  47. data/lib/sass/script/tree/funcall.rb +13 -6
  48. data/lib/sass/script/tree/interpolation.rb +127 -4
  49. data/lib/sass/script/tree/list_literal.rb +31 -4
  50. data/lib/sass/script/tree/literal.rb +4 -0
  51. data/lib/sass/script/tree/node.rb +21 -3
  52. data/lib/sass/script/tree/operation.rb +54 -1
  53. data/lib/sass/script/tree/selector.rb +26 -0
  54. data/lib/sass/script/tree/string_interpolation.rb +59 -38
  55. data/lib/sass/script/tree/variable.rb +1 -1
  56. data/lib/sass/script/tree.rb +1 -0
  57. data/lib/sass/script/value/base.rb +17 -14
  58. data/lib/sass/script/value/bool.rb +0 -5
  59. data/lib/sass/script/value/color.rb +78 -42
  60. data/lib/sass/script/value/helpers.rb +119 -2
  61. data/lib/sass/script/value/list.rb +0 -15
  62. data/lib/sass/script/value/map.rb +1 -1
  63. data/lib/sass/script/value/null.rb +0 -5
  64. data/lib/sass/script/value/number.rb +112 -31
  65. data/lib/sass/script/value/string.rb +102 -13
  66. data/lib/sass/script/value.rb +0 -1
  67. data/lib/sass/script.rb +3 -3
  68. data/lib/sass/scss/css_parser.rb +24 -4
  69. data/lib/sass/scss/parser.rb +290 -383
  70. data/lib/sass/scss/rx.rb +17 -9
  71. data/lib/sass/scss/static_parser.rb +306 -4
  72. data/lib/sass/scss.rb +0 -2
  73. data/lib/sass/selector/abstract_sequence.rb +35 -18
  74. data/lib/sass/selector/comma_sequence.rb +114 -19
  75. data/lib/sass/selector/pseudo.rb +266 -0
  76. data/lib/sass/selector/sequence.rb +146 -40
  77. data/lib/sass/selector/simple.rb +22 -33
  78. data/lib/sass/selector/simple_sequence.rb +122 -39
  79. data/lib/sass/selector.rb +57 -197
  80. data/lib/sass/shared.rb +2 -2
  81. data/lib/sass/source/map.rb +31 -14
  82. data/lib/sass/source/position.rb +4 -4
  83. data/lib/sass/stack.rb +2 -8
  84. data/lib/sass/supports.rb +10 -13
  85. data/lib/sass/tree/at_root_node.rb +1 -0
  86. data/lib/sass/tree/charset_node.rb +1 -1
  87. data/lib/sass/tree/comment_node.rb +1 -1
  88. data/lib/sass/tree/css_import_node.rb +9 -1
  89. data/lib/sass/tree/directive_node.rb +8 -2
  90. data/lib/sass/tree/error_node.rb +18 -0
  91. data/lib/sass/tree/extend_node.rb +1 -1
  92. data/lib/sass/tree/function_node.rb +9 -0
  93. data/lib/sass/tree/import_node.rb +6 -5
  94. data/lib/sass/tree/keyframe_rule_node.rb +15 -0
  95. data/lib/sass/tree/node.rb +5 -3
  96. data/lib/sass/tree/prop_node.rb +6 -7
  97. data/lib/sass/tree/rule_node.rb +26 -11
  98. data/lib/sass/tree/visitors/check_nesting.rb +56 -32
  99. data/lib/sass/tree/visitors/convert.rb +59 -44
  100. data/lib/sass/tree/visitors/cssize.rb +34 -30
  101. data/lib/sass/tree/visitors/deep_copy.rb +6 -1
  102. data/lib/sass/tree/visitors/extend.rb +15 -13
  103. data/lib/sass/tree/visitors/perform.rb +87 -50
  104. data/lib/sass/tree/visitors/set_options.rb +15 -1
  105. data/lib/sass/tree/visitors/to_css.rb +72 -43
  106. data/lib/sass/util/multibyte_string_scanner.rb +0 -2
  107. data/lib/sass/util/normalized_map.rb +0 -1
  108. data/lib/sass/util/subset_map.rb +2 -3
  109. data/lib/sass/util.rb +334 -154
  110. data/lib/sass/version.rb +7 -7
  111. data/lib/sass.rb +10 -8
  112. data/test/sass/cache_test.rb +62 -20
  113. data/test/sass/callbacks_test.rb +1 -1
  114. data/test/sass/compiler_test.rb +24 -11
  115. data/test/sass/conversion_test.rb +241 -50
  116. data/test/sass/css2sass_test.rb +73 -5
  117. data/test/sass/css_variable_test.rb +132 -0
  118. data/test/sass/encoding_test.rb +219 -0
  119. data/test/sass/engine_test.rb +343 -260
  120. data/test/sass/exec_test.rb +12 -2
  121. data/test/sass/extend_test.rb +333 -44
  122. data/test/sass/functions_test.rb +353 -260
  123. data/test/sass/importer_test.rb +40 -21
  124. data/test/sass/logger_test.rb +1 -1
  125. data/test/sass/more_results/more_import.css +1 -1
  126. data/test/sass/more_templates/more1.sass +10 -10
  127. data/test/sass/more_templates/more_import.sass +2 -2
  128. data/test/sass/plugin_test.rb +24 -21
  129. data/test/sass/results/compact.css +1 -1
  130. data/test/sass/results/complex.css +4 -4
  131. data/test/sass/results/expanded.css +1 -1
  132. data/test/sass/results/import.css +1 -1
  133. data/test/sass/results/import_charset_ibm866.css +2 -2
  134. data/test/sass/results/mixins.css +17 -17
  135. data/test/sass/results/nested.css +1 -1
  136. data/test/sass/results/parent_ref.css +2 -2
  137. data/test/sass/results/script.css +5 -5
  138. data/test/sass/results/scss_import.css +1 -1
  139. data/test/sass/script_conversion_test.rb +71 -39
  140. data/test/sass/script_test.rb +714 -123
  141. data/test/sass/scss/css_test.rb +213 -30
  142. data/test/sass/scss/rx_test.rb +8 -4
  143. data/test/sass/scss/scss_test.rb +766 -22
  144. data/test/sass/source_map_test.rb +263 -95
  145. data/test/sass/superselector_test.rb +210 -0
  146. data/test/sass/templates/_partial.sass +1 -1
  147. data/test/sass/templates/basic.sass +10 -10
  148. data/test/sass/templates/bork1.sass +1 -1
  149. data/test/sass/templates/bork5.sass +1 -1
  150. data/test/sass/templates/compact.sass +10 -10
  151. data/test/sass/templates/complex.sass +187 -187
  152. data/test/sass/templates/compressed.sass +10 -10
  153. data/test/sass/templates/expanded.sass +10 -10
  154. data/test/sass/templates/import.sass +2 -2
  155. data/test/sass/templates/importee.sass +3 -3
  156. data/test/sass/templates/mixins.sass +22 -22
  157. data/test/sass/templates/multiline.sass +4 -4
  158. data/test/sass/templates/nested.sass +13 -13
  159. data/test/sass/templates/parent_ref.sass +12 -12
  160. data/test/sass/templates/script.sass +70 -70
  161. data/test/sass/templates/scss_import.scss +2 -1
  162. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +1 -1
  163. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +2 -2
  164. data/test/sass/templates/subdir/subdir.sass +3 -3
  165. data/test/sass/templates/units.sass +10 -10
  166. data/test/sass/test_helper.rb +1 -1
  167. data/test/sass/util/multibyte_string_scanner_test.rb +11 -3
  168. data/test/sass/util/normalized_map_test.rb +1 -1
  169. data/test/sass/util/subset_map_test.rb +2 -2
  170. data/test/sass/util_test.rb +46 -45
  171. data/test/sass/value_helpers_test.rb +5 -7
  172. data/test/sass-spec.yml +3 -0
  173. data/test/test_helper.rb +7 -6
  174. data/vendor/listen/CHANGELOG.md +1 -228
  175. data/vendor/listen/Gemfile +5 -15
  176. data/vendor/listen/README.md +111 -77
  177. data/vendor/listen/Rakefile +0 -42
  178. data/vendor/listen/lib/listen/adapter.rb +195 -82
  179. data/vendor/listen/lib/listen/adapters/bsd.rb +27 -64
  180. data/vendor/listen/lib/listen/adapters/darwin.rb +21 -58
  181. data/vendor/listen/lib/listen/adapters/linux.rb +23 -55
  182. data/vendor/listen/lib/listen/adapters/polling.rb +25 -34
  183. data/vendor/listen/lib/listen/adapters/windows.rb +50 -46
  184. data/vendor/listen/lib/listen/directory_record.rb +96 -61
  185. data/vendor/listen/lib/listen/listener.rb +135 -37
  186. data/vendor/listen/lib/listen/turnstile.rb +9 -5
  187. data/vendor/listen/lib/listen/version.rb +1 -1
  188. data/vendor/listen/lib/listen.rb +33 -19
  189. data/vendor/listen/listen.gemspec +6 -0
  190. data/vendor/listen/spec/listen/adapter_spec.rb +43 -77
  191. data/vendor/listen/spec/listen/adapters/polling_spec.rb +8 -8
  192. data/vendor/listen/spec/listen/directory_record_spec.rb +81 -56
  193. data/vendor/listen/spec/listen/listener_spec.rb +128 -39
  194. data/vendor/listen/spec/listen_spec.rb +15 -21
  195. data/vendor/listen/spec/spec_helper.rb +4 -0
  196. data/vendor/listen/spec/support/adapter_helper.rb +52 -15
  197. data/vendor/listen/spec/support/directory_record_helper.rb +7 -5
  198. data/vendor/listen/spec/support/listeners_helper.rb +30 -7
  199. metadata +310 -300
  200. data/CONTRIBUTING +0 -3
  201. data/ext/mkrf_conf.rb +0 -27
  202. data/lib/sass/script/value/deprecated_false.rb +0 -55
  203. data/lib/sass/scss/script_lexer.rb +0 -15
  204. data/lib/sass/scss/script_parser.rb +0 -25
  205. data/vendor/listen/lib/listen/dependency_manager.rb +0 -126
  206. data/vendor/listen/lib/listen/multi_listener.rb +0 -143
  207. data/vendor/listen/spec/listen/dependency_manager_spec.rb +0 -107
  208. data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -174
data/lib/sass/selector.rb CHANGED
@@ -1,13 +1,14 @@
1
1
  require 'sass/selector/simple'
2
2
  require 'sass/selector/abstract_sequence'
3
3
  require 'sass/selector/comma_sequence'
4
+ require 'sass/selector/pseudo'
4
5
  require 'sass/selector/sequence'
5
6
  require 'sass/selector/simple_sequence'
6
7
 
7
8
  module Sass
8
9
  # A namespace for nodes in the parse tree for selectors.
9
10
  #
10
- # {CommaSequence} is the toplevel seelctor,
11
+ # {CommaSequence} is the toplevel selector,
11
12
  # representing a comma-separated sequence of {Sequence}s,
12
13
  # such as `foo bar, baz bang`.
13
14
  # {Sequence} is the next level,
@@ -27,19 +28,19 @@ module Sass
27
28
  # The function of this is to be replaced by the parent selector
28
29
  # in the nested hierarchy.
29
30
  class Parent < Simple
30
- # The identifier following the `&`. Often empty.
31
+ # The identifier following the `&`. `nil` indicates no suffix.
31
32
  #
32
- # @return [Array<String, Sass::Script::Tree::Node>]
33
+ # @return [String, nil]
33
34
  attr_reader :suffix
34
35
 
35
- # @param name [Array<String, Sass::Script::Tree::Node>] See \{#suffix}
36
- def initialize(suffix = [])
36
+ # @param name [String, nil] See \{#suffix}
37
+ def initialize(suffix = nil)
37
38
  @suffix = suffix
38
39
  end
39
40
 
40
- # @see Selector#to_a
41
- def to_a
42
- ["&", *@suffix]
41
+ # @see Selector#to_s
42
+ def to_s(opts = {})
43
+ "&" + (@suffix || '')
43
44
  end
44
45
 
45
46
  # Always raises an exception.
@@ -55,17 +56,17 @@ module Sass
55
56
  class Class < Simple
56
57
  # The class name.
57
58
  #
58
- # @return [Array<String, Sass::Script::Tree::Node>]
59
+ # @return [String]
59
60
  attr_reader :name
60
61
 
61
- # @param name [Array<String, Sass::Script::Tree::Node>] The class name
62
+ # @param name [String] The class name
62
63
  def initialize(name)
63
64
  @name = name
64
65
  end
65
66
 
66
- # @see Selector#to_a
67
- def to_a
68
- [".", *@name]
67
+ # @see Selector#to_s
68
+ def to_s(opts = {})
69
+ "." + @name
69
70
  end
70
71
 
71
72
  # @see AbstractSequence#specificity
@@ -78,17 +79,17 @@ module Sass
78
79
  class Id < Simple
79
80
  # The id name.
80
81
  #
81
- # @return [Array<String, Sass::Script::Tree::Node>]
82
+ # @return [String]
82
83
  attr_reader :name
83
84
 
84
- # @param name [Array<String, Sass::Script::Tree::Node>] The id name
85
+ # @param name [String] The id name
85
86
  def initialize(name)
86
87
  @name = name
87
88
  end
88
89
 
89
- # @see Selector#to_a
90
- def to_a
91
- ["#", *@name]
90
+ # @see Selector#to_s
91
+ def to_s(opts = {})
92
+ "#" + @name
92
93
  end
93
94
 
94
95
  # Returns `nil` if `sels` contains an {Id} selector
@@ -113,17 +114,17 @@ module Sass
113
114
  class Placeholder < Simple
114
115
  # The placeholder name.
115
116
  #
116
- # @return [Array<String, Sass::Script::Tree::Node>]
117
+ # @return [String]
117
118
  attr_reader :name
118
119
 
119
- # @param name [Array<String, Sass::Script::Tree::Node>] The placeholder name
120
+ # @param name [String] The placeholder name
120
121
  def initialize(name)
121
122
  @name = name
122
123
  end
123
124
 
124
- # @see Selector#to_a
125
- def to_a
126
- ["%", *@name]
125
+ # @see Selector#to_s
126
+ def to_s(opts = {})
127
+ "%" + @name
127
128
  end
128
129
 
129
130
  # @see AbstractSequence#specificity
@@ -134,22 +135,20 @@ module Sass
134
135
 
135
136
  # A universal selector (`*` in CSS).
136
137
  class Universal < Simple
137
- # The selector namespace.
138
- # `nil` means the default namespace,
139
- # `[""]` means no namespace,
140
- # `["*"]` means any namespace.
138
+ # The selector namespace. `nil` means the default namespace, `""` means no
139
+ # namespace, `"*"` means any namespace.
141
140
  #
142
- # @return [Array<String, Sass::Script::Tree::Node>, nil]
141
+ # @return [String, nil]
143
142
  attr_reader :namespace
144
143
 
145
- # @param namespace [Array<String, Sass::Script::Tree::Node>, nil] See \{#namespace}
144
+ # @param namespace [String, nil] See \{#namespace}
146
145
  def initialize(namespace)
147
146
  @namespace = namespace
148
147
  end
149
148
 
150
- # @see Selector#to_a
151
- def to_a
152
- @namespace ? @namespace + ["|*"] : ["*"]
149
+ # @see Selector#to_s
150
+ def to_s(opts = {})
151
+ @namespace ? "#{@namespace}|*" : "*"
153
152
  end
154
153
 
155
154
  # Unification of a universal selector is somewhat complicated,
@@ -183,7 +182,7 @@ module Sass
183
182
  when Universal; :universal
184
183
  when Element; sels.first.name
185
184
  else
186
- return [self] + sels unless namespace.nil? || namespace == ['*']
185
+ return [self] + sels unless namespace.nil? || namespace == '*'
187
186
  return sels unless sels.empty?
188
187
  return [self]
189
188
  end
@@ -203,27 +202,25 @@ module Sass
203
202
  class Element < Simple
204
203
  # The element name.
205
204
  #
206
- # @return [Array<String, Sass::Script::Tree::Node>]
205
+ # @return [String]
207
206
  attr_reader :name
208
207
 
209
- # The selector namespace.
210
- # `nil` means the default namespace,
211
- # `[""]` means no namespace,
212
- # `["*"]` means any namespace.
208
+ # The selector namespace. `nil` means the default namespace, `""` means no
209
+ # namespace, `"*"` means any namespace.
213
210
  #
214
- # @return [Array<String, Sass::Script::Tree::Node>, nil]
211
+ # @return [String, nil]
215
212
  attr_reader :namespace
216
213
 
217
- # @param name [Array<String, Sass::Script::Tree::Node>] The element name
218
- # @param namespace [Array<String, Sass::Script::Tree::Node>, nil] See \{#namespace}
214
+ # @param name [String] The element name
215
+ # @param namespace [String, nil] See \{#namespace}
219
216
  def initialize(name, namespace)
220
217
  @name = name
221
218
  @namespace = namespace
222
219
  end
223
220
 
224
- # @see Selector#to_a
225
- def to_a
226
- @namespace ? @namespace + ["|"] + @name : @name
221
+ # @see Selector#to_s
222
+ def to_s(opts = {})
223
+ @namespace ? "#{@namespace}|#{@name}" : @name
227
224
  end
228
225
 
229
226
  # Unification of an element selector is somewhat complicated,
@@ -266,32 +263,6 @@ module Sass
266
263
  end
267
264
  end
268
265
 
269
- # Selector interpolation (`#{}` in Sass).
270
- class Interpolation < Simple
271
- # The script to run.
272
- #
273
- # @return [Sass::Script::Tree::Node]
274
- attr_reader :script
275
-
276
- # @param script [Sass::Script::Tree::Node] The script to run
277
- def initialize(script)
278
- @script = script
279
- end
280
-
281
- # @see Selector#to_a
282
- def to_a
283
- [@script]
284
- end
285
-
286
- # Always raises an exception.
287
- #
288
- # @raise [Sass::SyntaxError] Interpolation selectors should be resolved before unification
289
- # @see Selector#unify
290
- def unify(sels)
291
- raise Sass::SyntaxError.new("[BUG] Cannot unify interpolation selectors.")
292
- end
293
- end
294
-
295
266
  # An attribute selector (e.g. `[href^="http://"]`).
296
267
  class Attribute < Simple
297
268
  # The attribute name.
@@ -299,12 +270,10 @@ module Sass
299
270
  # @return [Array<String, Sass::Script::Tree::Node>]
300
271
  attr_reader :name
301
272
 
302
- # The attribute namespace.
303
- # `nil` means the default namespace,
304
- # `[""]` means no namespace,
305
- # `["*"]` means any namespace.
273
+ # The attribute namespace. `nil` means the default namespace, `""` means
274
+ # no namespace, `"*"` means any namespace.
306
275
  #
307
- # @return [Array<String, Sass::Script::Tree::Node>, nil]
276
+ # @return [String, nil]
308
277
  attr_reader :namespace
309
278
 
310
279
  # The matching operator, e.g. `"="` or `"^="`.
@@ -314,23 +283,20 @@ module Sass
314
283
 
315
284
  # The right-hand side of the operator.
316
285
  #
317
- # @return [Array<String, Sass::Script::Tree::Node>]
286
+ # @return [String]
318
287
  attr_reader :value
319
288
 
320
289
  # Flags for the attribute selector (e.g. `i`).
321
290
  #
322
- # @return [Array<String, Sass::Script::Tree::Node>]
291
+ # @return [String]
323
292
  attr_reader :flags
324
293
 
325
- # @param name [Array<String, Sass::Script::Tree::Node>] The attribute name
326
- # @param namespace [Array<String, Sass::Script::Tree::Node>, nil] See \{#namespace}
294
+ # @param name [String] The attribute name
295
+ # @param namespace [String, nil] See \{#namespace}
327
296
  # @param operator [String] The matching operator, e.g. `"="` or `"^="`
328
- # @param value [Array<String, Sass::Script::Tree::Node>] See \{#value}
329
- # @param flags [Array<String, Sass::Script::Tree::Node>] See \{#flags}
330
- # @comment
331
- # rubocop:disable ParameterLists
297
+ # @param value [String] See \{#value}
298
+ # @param flags [String] See \{#flags}
332
299
  def initialize(name, namespace, operator, value, flags)
333
- # rubocop:enable ParameterLists
334
300
  @name = name
335
301
  @namespace = namespace
336
302
  @operator = operator
@@ -338,13 +304,13 @@ module Sass
338
304
  @flags = flags
339
305
  end
340
306
 
341
- # @see Selector#to_a
342
- def to_a
343
- res = ["["]
344
- res.concat(@namespace) << "|" if @namespace
345
- res.concat @name
346
- (res << @operator).concat @value if @value
347
- (res << " ").concat @flags if @flags
307
+ # @see Selector#to_s
308
+ def to_s(opts = {})
309
+ res = "["
310
+ res << @namespace << "|" if @namespace
311
+ res << @name
312
+ res << @operator << @value if @value
313
+ res << " " << @flags if @flags
348
314
  res << "]"
349
315
  end
350
316
 
@@ -353,111 +319,5 @@ module Sass
353
319
  SPECIFICITY_BASE
354
320
  end
355
321
  end
356
-
357
- # A pseudoclass (e.g. `:visited`) or pseudoelement (e.g. `::first-line`) selector.
358
- # It can have arguments (e.g. `:nth-child(2n+1)`).
359
- class Pseudo < Simple
360
- # Some psuedo-class-syntax selectors are actually considered
361
- # pseudo-elements and must be treated differently. This is a list of such
362
- # selectors
363
- #
364
- # @return [Array<String>]
365
- ACTUALLY_ELEMENTS = %w[after before first-line first-letter]
366
-
367
- # Like \{#type}, but returns the type of selector this looks like, rather
368
- # than the type it is semantically. This only differs from type for
369
- # selectors in \{ACTUALLY\_ELEMENTS}.
370
- #
371
- # @return [Symbol]
372
- attr_reader :syntactic_type
373
-
374
- # The name of the selector.
375
- #
376
- # @return [Array<String, Sass::Script::Tree::Node>]
377
- attr_reader :name
378
-
379
- # The argument to the selector,
380
- # or `nil` if no argument was given.
381
- #
382
- # This may include SassScript nodes that will be run during resolution.
383
- # Note that this should not include SassScript nodes
384
- # after resolution has taken place.
385
- #
386
- # @return [Array<String, Sass::Script::Tree::Node>, nil]
387
- attr_reader :arg
388
-
389
- # @param type [Symbol] See \{#type}
390
- # @param name [Array<String, Sass::Script::Tree::Node>] The name of the selector
391
- # @param arg [nil, Array<String, Sass::Script::Tree::Node>] The argument to the selector,
392
- # or nil if no argument was given
393
- def initialize(type, name, arg)
394
- @syntactic_type = type
395
- @name = name
396
- @arg = arg
397
- end
398
-
399
- # The type of the selector. `:class` if this is a pseudoclass selector,
400
- # `:element` if it's a pseudoelement.
401
- #
402
- # @return [Symbol]
403
- def type
404
- ACTUALLY_ELEMENTS.include?(name.first) ? :element : syntactic_type
405
- end
406
-
407
- # @see Selector#to_a
408
- def to_a
409
- res = [syntactic_type == :class ? ":" : "::"] + @name
410
- (res << "(").concat(Sass::Util.strip_string_array(@arg)) << ")" if @arg
411
- res
412
- end
413
-
414
- # Returns `nil` if this is a pseudoelement selector
415
- # and `sels` contains a pseudoelement selector different than this one.
416
- #
417
- # @see Selector#unify
418
- def unify(sels)
419
- return if type == :element && sels.any? do |sel|
420
- sel.is_a?(Pseudo) && sel.type == :element &&
421
- (sel.name != name || sel.arg != arg)
422
- end
423
- super
424
- end
425
-
426
- # @see AbstractSequence#specificity
427
- def specificity
428
- type == :class ? SPECIFICITY_BASE : 1
429
- end
430
- end
431
-
432
- # A pseudoclass selector whose argument is itself a selector
433
- # (e.g. `:not(.foo)` or `:-moz-all(.foo, .bar)`).
434
- class SelectorPseudoClass < Simple
435
- # The name of the pseudoclass.
436
- #
437
- # @return [String]
438
- attr_reader :name
439
-
440
- # The selector argument.
441
- #
442
- # @return [Selector::Sequence]
443
- attr_reader :selector
444
-
445
- # @param name [String] The name of the pseudoclass
446
- # @param selector [Selector::CommaSequence] The selector argument
447
- def initialize(name, selector)
448
- @name = name
449
- @selector = selector
450
- end
451
-
452
- # @see Selector#to_a
453
- def to_a
454
- [":", @name, "("] + @selector.to_a + [")"]
455
- end
456
-
457
- # @see AbstractSequence#specificity
458
- def specificity
459
- SPECIFICITY_BASE
460
- end
461
- end
462
322
  end
463
323
  end
data/lib/sass/shared.rb CHANGED
@@ -31,7 +31,7 @@ module Sass
31
31
  # A `Fixnum` in 1.8, a `String` in 1.9
32
32
  # @param finish [Character] The character closing the balanced pair.
33
33
  # A `Fixnum` in 1.8, a `String` in 1.9
34
- # @param count [Fixnum] The number of opening characters matched
34
+ # @param count [Integer] The number of opening characters matched
35
35
  # before calling this method
36
36
  # @return [(String, String)] The string matched within the balanced pair
37
37
  # and the rest of the string.
@@ -44,7 +44,7 @@ module Sass
44
44
  str << scanner.matched
45
45
  count += 1 if scanner.matched[-1] == start
46
46
  count -= 1 if scanner.matched[-1] == finish
47
- return [str.strip, scanner.rest] if count == 0
47
+ return [str, scanner.rest] if count == 0
48
48
  end
49
49
  end
50
50
 
@@ -37,7 +37,7 @@ module Sass::Source
37
37
 
38
38
  # Shifts all output source ranges forward one or more lines.
39
39
  #
40
- # @param delta [Fixnum] The number of lines to shift the ranges forward.
40
+ # @param delta [Integer] The number of lines to shift the ranges forward.
41
41
  def shift_output_lines(delta)
42
42
  return if delta == 0
43
43
  @data.each do |m|
@@ -49,7 +49,7 @@ module Sass::Source
49
49
  # Shifts any output source ranges that lie on the first line forward one or
50
50
  # more characters on that line.
51
51
  #
52
- # @param delta [Fixnum] The number of characters to shift the ranges
52
+ # @param delta [Integer] The number of characters to shift the ranges
53
53
  # forward.
54
54
  def shift_output_offsets(delta)
55
55
  return if delta == 0
@@ -68,12 +68,6 @@ module Sass::Source
68
68
  # it will be inferred from `:css_path` and `:sourcemap_path` using the
69
69
  # assumption that the local file system has the same layout as the server.
70
70
  #
71
- # If any source stylesheets use the default filesystem importer, sourcemap
72
- # generation will fail unless the `:sourcemap_path` option is specified.
73
- # The layout of the local file system is assumed to be the same as the
74
- # layout of the server for the purposes of linking to source stylesheets
75
- # that use the filesystem importer.
76
- #
77
71
  # Regardless of which options are passed to this method, source stylesheets
78
72
  # that are imported using a non-default importer will only be linked to in
79
73
  # the source map if their importers implement
@@ -85,6 +79,8 @@ module Sass::Source
85
79
  # The local path of the CSS output file.
86
80
  # @option options :sourcemap_path [String]
87
81
  # The (eventual) local path of the sourcemap file.
82
+ # @option options :type [Symbol]
83
+ # `:auto` (default), `:file`, or `:inline`.
88
84
  # @return [String] The JSON string.
89
85
  # @raise [ArgumentError] If neither `:css_uri` nor `:css_path` and
90
86
  # `:sourcemap_path` are specified.
@@ -97,15 +93,17 @@ module Sass::Source
97
93
  raise ArgumentError.new("Sass::Source::Map#to_json requires either " \
98
94
  "the :css_uri option or both the :css_path and :soucemap_path options.")
99
95
  end
100
- css_path &&= Pathname.pwd.join(Sass::Util.pathname(css_path)).cleanpath
101
- sourcemap_path &&= Pathname.pwd.join(Sass::Util.pathname(sourcemap_path)).cleanpath
102
- css_uri ||= css_path.relative_path_from(sourcemap_path.dirname).to_s
96
+ css_path &&= Sass::Util.pathname(Sass::Util.absolute_path(css_path))
97
+ sourcemap_path &&= Sass::Util.pathname(Sass::Util.absolute_path(sourcemap_path))
98
+ css_uri ||= Sass::Util.file_uri_from_path(
99
+ Sass::Util.relative_path_from(css_path, sourcemap_path.dirname))
103
100
 
104
101
  result = "{\n"
105
102
  write_json_field(result, "version", 3, true)
106
103
 
107
104
  source_uri_to_id = {}
108
105
  id_to_source_uri = {}
106
+ id_to_contents = {} if options[:type] == :inline
109
107
  next_source_id = 0
110
108
  line_data = []
111
109
  segment_data_for_line = []
@@ -119,9 +117,17 @@ module Sass::Source
119
117
 
120
118
  @data.each do |m|
121
119
  file, importer = m.input.file, m.input.importer
122
- source_uri = importer &&
123
- importer.public_url(file, sourcemap_path && sourcemap_path.dirname.to_s)
124
- next unless source_uri
120
+
121
+ next unless importer
122
+
123
+ if options[:type] == :inline
124
+ source_uri = file
125
+ else
126
+ sourcemap_dir = sourcemap_path && sourcemap_path.dirname.to_s
127
+ sourcemap_dir = nil if options[:type] == :file
128
+ source_uri = importer.public_url(file, sourcemap_dir)
129
+ next unless source_uri
130
+ end
125
131
 
126
132
  current_source_id = source_uri_to_id[source_uri]
127
133
  unless current_source_id
@@ -130,6 +136,11 @@ module Sass::Source
130
136
 
131
137
  source_uri_to_id[source_uri] = current_source_id
132
138
  id_to_source_uri[current_source_id] = source_uri
139
+
140
+ if options[:type] == :inline
141
+ id_to_contents[current_source_id] =
142
+ importer.find(file, {}).instance_variable_get('@template')
143
+ end
133
144
  end
134
145
 
135
146
  [
@@ -174,6 +185,12 @@ module Sass::Source
174
185
  source_names = []
175
186
  (0...next_source_id).each {|id| source_names.push(id_to_source_uri[id].to_s)}
176
187
  write_json_field(result, "sources", source_names)
188
+
189
+ if options[:type] == :inline
190
+ write_json_field(result, "sourcesContent",
191
+ (0...next_source_id).map {|id| id_to_contents[id]})
192
+ end
193
+
177
194
  write_json_field(result, "names", [])
178
195
  write_json_field(result, "file", css_uri)
179
196
 
@@ -2,17 +2,17 @@ module Sass::Source
2
2
  class Position
3
3
  # The one-based line of the document associated with the position.
4
4
  #
5
- # @return [Fixnum]
5
+ # @return [Integer]
6
6
  attr_accessor :line
7
7
 
8
8
  # The one-based offset in the line of the document associated with the
9
9
  # position.
10
10
  #
11
- # @return [Fixnum]
11
+ # @return [Integer]
12
12
  attr_accessor :offset
13
13
 
14
- # @param line [Fixnum] The source line
15
- # @param offset [Fixnum] The source offset
14
+ # @param line [Integer] The source line
15
+ # @param offset [Integer] The source offset
16
16
  def initialize(line, offset)
17
17
  @line = line
18
18
  @offset = offset
data/lib/sass/stack.rb CHANGED
@@ -101,18 +101,12 @@ module Sass
101
101
  def to_s
102
102
  Sass::Util.enum_with_index(Sass::Util.enum_cons(frames.reverse + [nil], 2)).
103
103
  map do |(frame, caller), i|
104
- "#{i == 0 ? "on" : "from"} line #{frame.line}" +
105
- " of #{frame.filename || "an unknown file"}" +
104
+ "#{i == 0 ? 'on' : 'from'} line #{frame.line}" +
105
+ " of #{frame.filename || 'an unknown file'}" +
106
106
  (caller && caller.name ? ", in `#{caller.name}'" : "")
107
107
  end.join("\n")
108
108
  end
109
109
 
110
- def deep_copy
111
- stack = Stack.new
112
- stack.frames.replace frames
113
- stack
114
- end
115
-
116
110
  private
117
111
 
118
112
  def with_frame(filename, line, type, name = nil)
data/lib/sass/supports.rb CHANGED
@@ -58,11 +58,11 @@ module Sass::Supports
58
58
  end
59
59
 
60
60
  def to_css
61
- "#{left_parens @left.to_css} #{op} #{right_parens @right.to_css}"
61
+ "#{parens @left, @left.to_css} #{op} #{parens @right, @right.to_css}"
62
62
  end
63
63
 
64
64
  def to_src(options)
65
- "#{left_parens @left.to_src(options)} #{op} #{right_parens @right.to_src(options)}"
65
+ "#{parens @left, @left.to_src(options)} #{op} #{parens @right, @right.to_src(options)}"
66
66
  end
67
67
 
68
68
  def deep_copy
@@ -79,14 +79,12 @@ module Sass::Supports
79
79
 
80
80
  private
81
81
 
82
- def left_parens(str)
83
- return "(#{str})" if @left.is_a?(Negation)
84
- str
85
- end
86
-
87
- def right_parens(str)
88
- return "(#{str})" if @right.is_a?(Negation) || @right.is_a?(Operator)
89
- str
82
+ def parens(condition, str)
83
+ if condition.is_a?(Negation) || (condition.is_a?(Operator) && condition.op != op)
84
+ return "(#{str})"
85
+ else
86
+ return str
87
+ end
90
88
  end
91
89
  end
92
90
 
@@ -203,8 +201,7 @@ module Sass::Supports
203
201
  end
204
202
 
205
203
  def perform(env)
206
- val = value.perform(env)
207
- @resolved_value = val.is_a?(Sass::Script::Value::String) ? val.value : val.to_s
204
+ @resolved_value = value.perform(env).to_s(:quote => :none)
208
205
  end
209
206
 
210
207
  def to_css
@@ -212,7 +209,7 @@ module Sass::Supports
212
209
  end
213
210
 
214
211
  def to_src(options)
215
- "\#{#{@value.to_sass(options)}}"
212
+ @value.to_sass(options)
216
213
  end
217
214
 
218
215
  def deep_copy
@@ -70,6 +70,7 @@ module Sass
70
70
  # @return [Boolean]
71
71
  def exclude_node?(node)
72
72
  return exclude?(node.name.gsub(/^@/, '')) if node.is_a?(Sass::Tree::DirectiveNode)
73
+ return exclude?('keyframes') if node.is_a?(Sass::Tree::KeyframeRuleNode)
73
74
  exclude?('rule') && node.is_a?(Sass::Tree::RuleNode)
74
75
  end
75
76
 
@@ -1,5 +1,5 @@
1
1
  module Sass::Tree
2
- # A static node representing an unproccessed Sass `@charset` directive.
2
+ # A static node representing an unprocessed Sass `@charset` directive.
3
3
  #
4
4
  # @see Sass::Tree
5
5
  class CharsetNode < Node
@@ -59,7 +59,7 @@ module Sass::Tree
59
59
 
60
60
  # Returns the number of lines in the comment.
61
61
  #
62
- # @return [Fixnum]
62
+ # @return [Integer]
63
63
  def lines
64
64
  @value.inject(0) do |s, e|
65
65
  next s + e.count("\n") if e.is_a?(String)
@@ -15,6 +15,11 @@ module Sass::Tree
15
15
  # @return [String]
16
16
  attr_accessor :resolved_uri
17
17
 
18
+ # The supports condition for this import.
19
+ #
20
+ # @return [Sass::Supports::Condition]
21
+ attr_accessor :supports_condition
22
+
18
23
  # The media query for this rule, interspersed with
19
24
  # {Sass::Script::Tree::Node}s representing `#{}`-interpolation. Any adjacent
20
25
  # strings will be merged together.
@@ -30,9 +35,11 @@ module Sass::Tree
30
35
 
31
36
  # @param uri [String, Sass::Script::Tree::Node] See \{#uri}
32
37
  # @param query [Array<String, Sass::Script::Tree::Node>] See \{#query}
33
- def initialize(uri, query = [])
38
+ # @param supports_condition [Sass::Supports::Condition] See \{#supports_condition}
39
+ def initialize(uri, query = [], supports_condition = nil)
34
40
  @uri = uri
35
41
  @query = query
42
+ @supports_condition = supports_condition
36
43
  super('')
37
44
  end
38
45
 
@@ -52,6 +59,7 @@ module Sass::Tree
52
59
  @resolved_value ||=
53
60
  begin
54
61
  str = "@import #{resolved_uri}"
62
+ str << " supports(#{supports_condition.to_css})" if supports_condition
55
63
  str << " #{resolved_query.to_css}" if resolved_query
56
64
  str
57
65
  end