sass 3.4.25 → 3.7.4

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.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/CODE_OF_CONDUCT.md +1 -1
  3. data/CONTRIBUTING.md +3 -3
  4. data/README.md +17 -9
  5. data/VERSION +1 -1
  6. data/VERSION_DATE +1 -1
  7. data/VERSION_NAME +1 -1
  8. data/extra/sass-spec-ref.sh +9 -1
  9. data/lib/sass.rb +0 -7
  10. data/lib/sass/cache_stores/filesystem.rb +1 -1
  11. data/lib/sass/css.rb +1 -2
  12. data/lib/sass/engine.rb +39 -29
  13. data/lib/sass/environment.rb +26 -5
  14. data/lib/sass/error.rb +2 -2
  15. data/lib/sass/exec/base.rb +2 -13
  16. data/lib/sass/exec/sass_scss.rb +1 -5
  17. data/lib/sass/features.rb +1 -0
  18. data/lib/sass/importers/filesystem.rb +6 -4
  19. data/lib/sass/logger/base.rb +11 -0
  20. data/lib/sass/plugin/compiler.rb +20 -50
  21. data/lib/sass/plugin/configuration.rb +2 -2
  22. data/lib/sass/railtie.rb +1 -1
  23. data/lib/sass/script/css_parser.rb +4 -1
  24. data/lib/sass/script/functions.rb +308 -81
  25. data/lib/sass/script/lexer.rb +63 -9
  26. data/lib/sass/script/parser.rb +287 -118
  27. data/lib/sass/script/tree/funcall.rb +35 -34
  28. data/lib/sass/script/tree/interpolation.rb +0 -3
  29. data/lib/sass/script/tree/list_literal.rb +23 -8
  30. data/lib/sass/script/tree/map_literal.rb +2 -2
  31. data/lib/sass/script/tree/node.rb +0 -8
  32. data/lib/sass/script/tree/operation.rb +1 -8
  33. data/lib/sass/script/value.rb +2 -0
  34. data/lib/sass/script/value/arg_list.rb +1 -1
  35. data/lib/sass/script/value/base.rb +17 -0
  36. data/lib/sass/script/value/callable.rb +25 -0
  37. data/lib/sass/script/value/color.rb +8 -2
  38. data/lib/sass/script/value/function.rb +19 -0
  39. data/lib/sass/script/value/helpers.rb +37 -11
  40. data/lib/sass/script/value/list.rb +35 -14
  41. data/lib/sass/script/value/map.rb +2 -2
  42. data/lib/sass/script/value/number.rb +3 -2
  43. data/lib/sass/scss/css_parser.rb +6 -1
  44. data/lib/sass/scss/parser.rb +145 -56
  45. data/lib/sass/scss/rx.rb +5 -11
  46. data/lib/sass/scss/static_parser.rb +20 -42
  47. data/lib/sass/selector.rb +4 -0
  48. data/lib/sass/selector/abstract_sequence.rb +7 -6
  49. data/lib/sass/selector/comma_sequence.rb +9 -5
  50. data/lib/sass/selector/pseudo.rb +20 -3
  51. data/lib/sass/selector/sequence.rb +35 -10
  52. data/lib/sass/selector/simple.rb +9 -2
  53. data/lib/sass/selector/simple_sequence.rb +8 -4
  54. data/lib/sass/source/map.rb +2 -6
  55. data/lib/sass/stack.rb +21 -1
  56. data/lib/sass/tree/charset_node.rb +1 -1
  57. data/lib/sass/tree/prop_node.rb +45 -53
  58. data/lib/sass/tree/rule_node.rb +6 -8
  59. data/lib/sass/tree/visitors/check_nesting.rb +1 -1
  60. data/lib/sass/tree/visitors/convert.rb +2 -3
  61. data/lib/sass/tree/visitors/cssize.rb +4 -15
  62. data/lib/sass/tree/visitors/deep_copy.rb +1 -1
  63. data/lib/sass/tree/visitors/extend.rb +2 -8
  64. data/lib/sass/tree/visitors/perform.rb +23 -15
  65. data/lib/sass/tree/visitors/set_options.rb +1 -1
  66. data/lib/sass/tree/visitors/to_css.rb +49 -22
  67. data/lib/sass/util.rb +72 -310
  68. data/lib/sass/util/multibyte_string_scanner.rb +127 -131
  69. data/lib/sass/util/normalized_map.rb +1 -8
  70. data/lib/sass/version.rb +0 -4
  71. metadata +55 -202
  72. data/Rakefile +0 -453
  73. data/lib/sass/script/css_variable_warning.rb +0 -52
  74. data/lib/sass/util/cross_platform_random.rb +0 -19
  75. data/lib/sass/util/ordered_hash.rb +0 -192
  76. data/test/sass-spec.yml +0 -3
  77. data/test/sass/cache_test.rb +0 -131
  78. data/test/sass/callbacks_test.rb +0 -61
  79. data/test/sass/compiler_test.rb +0 -236
  80. data/test/sass/conversion_test.rb +0 -2188
  81. data/test/sass/css2sass_test.rb +0 -526
  82. data/test/sass/css_variable_test.rb +0 -132
  83. data/test/sass/data/hsl-rgb.txt +0 -319
  84. data/test/sass/encoding_test.rb +0 -219
  85. data/test/sass/engine_test.rb +0 -3447
  86. data/test/sass/exec_test.rb +0 -96
  87. data/test/sass/extend_test.rb +0 -1733
  88. data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
  89. data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
  90. data/test/sass/functions_test.rb +0 -1977
  91. data/test/sass/importer_test.rb +0 -421
  92. data/test/sass/logger_test.rb +0 -58
  93. data/test/sass/mock_importer.rb +0 -49
  94. data/test/sass/more_results/more1.css +0 -9
  95. data/test/sass/more_results/more1_with_line_comments.css +0 -26
  96. data/test/sass/more_results/more_import.css +0 -29
  97. data/test/sass/more_templates/_more_partial.sass +0 -2
  98. data/test/sass/more_templates/more1.sass +0 -23
  99. data/test/sass/more_templates/more_import.sass +0 -11
  100. data/test/sass/plugin_test.rb +0 -556
  101. data/test/sass/results/alt.css +0 -4
  102. data/test/sass/results/basic.css +0 -9
  103. data/test/sass/results/cached_import_option.css +0 -3
  104. data/test/sass/results/compact.css +0 -5
  105. data/test/sass/results/complex.css +0 -86
  106. data/test/sass/results/compressed.css +0 -1
  107. data/test/sass/results/expanded.css +0 -19
  108. data/test/sass/results/filename_fn.css +0 -3
  109. data/test/sass/results/if.css +0 -3
  110. data/test/sass/results/import.css +0 -31
  111. data/test/sass/results/import_charset.css +0 -5
  112. data/test/sass/results/import_charset_1_8.css +0 -5
  113. data/test/sass/results/import_charset_ibm866.css +0 -5
  114. data/test/sass/results/import_content.css +0 -1
  115. data/test/sass/results/line_numbers.css +0 -49
  116. data/test/sass/results/mixins.css +0 -95
  117. data/test/sass/results/multiline.css +0 -24
  118. data/test/sass/results/nested.css +0 -22
  119. data/test/sass/results/options.css +0 -1
  120. data/test/sass/results/parent_ref.css +0 -13
  121. data/test/sass/results/script.css +0 -16
  122. data/test/sass/results/scss_import.css +0 -31
  123. data/test/sass/results/scss_importee.css +0 -2
  124. data/test/sass/results/subdir/nested_subdir/nested_subdir.css +0 -1
  125. data/test/sass/results/subdir/subdir.css +0 -3
  126. data/test/sass/results/units.css +0 -11
  127. data/test/sass/results/warn.css +0 -0
  128. data/test/sass/results/warn_imported.css +0 -0
  129. data/test/sass/script_conversion_test.rb +0 -357
  130. data/test/sass/script_test.rb +0 -1431
  131. data/test/sass/scss/css_test.rb +0 -1281
  132. data/test/sass/scss/rx_test.rb +0 -160
  133. data/test/sass/scss/scss_test.rb +0 -4205
  134. data/test/sass/scss/test_helper.rb +0 -37
  135. data/test/sass/source_map_test.rb +0 -1055
  136. data/test/sass/superselector_test.rb +0 -210
  137. data/test/sass/templates/_cached_import_option_partial.scss +0 -1
  138. data/test/sass/templates/_double_import_loop2.sass +0 -1
  139. data/test/sass/templates/_filename_fn_import.scss +0 -11
  140. data/test/sass/templates/_imported_charset_ibm866.sass +0 -4
  141. data/test/sass/templates/_imported_charset_utf8.sass +0 -4
  142. data/test/sass/templates/_imported_content.sass +0 -3
  143. data/test/sass/templates/_partial.sass +0 -2
  144. data/test/sass/templates/_same_name_different_partiality.scss +0 -1
  145. data/test/sass/templates/alt.sass +0 -16
  146. data/test/sass/templates/basic.sass +0 -23
  147. data/test/sass/templates/bork1.sass +0 -2
  148. data/test/sass/templates/bork2.sass +0 -2
  149. data/test/sass/templates/bork3.sass +0 -2
  150. data/test/sass/templates/bork4.sass +0 -2
  151. data/test/sass/templates/bork5.sass +0 -3
  152. data/test/sass/templates/cached_import_option.scss +0 -3
  153. data/test/sass/templates/compact.sass +0 -17
  154. data/test/sass/templates/complex.sass +0 -305
  155. data/test/sass/templates/compressed.sass +0 -15
  156. data/test/sass/templates/double_import_loop1.sass +0 -1
  157. data/test/sass/templates/expanded.sass +0 -17
  158. data/test/sass/templates/filename_fn.scss +0 -18
  159. data/test/sass/templates/if.sass +0 -11
  160. data/test/sass/templates/import.sass +0 -12
  161. data/test/sass/templates/import_charset.sass +0 -9
  162. data/test/sass/templates/import_charset_1_8.sass +0 -6
  163. data/test/sass/templates/import_charset_ibm866.sass +0 -11
  164. data/test/sass/templates/import_content.sass +0 -4
  165. data/test/sass/templates/importee.less +0 -2
  166. data/test/sass/templates/importee.sass +0 -19
  167. data/test/sass/templates/line_numbers.sass +0 -13
  168. data/test/sass/templates/mixin_bork.sass +0 -5
  169. data/test/sass/templates/mixins.sass +0 -76
  170. data/test/sass/templates/multiline.sass +0 -20
  171. data/test/sass/templates/nested.sass +0 -25
  172. data/test/sass/templates/nested_bork1.sass +0 -2
  173. data/test/sass/templates/nested_bork2.sass +0 -2
  174. data/test/sass/templates/nested_bork3.sass +0 -2
  175. data/test/sass/templates/nested_bork4.sass +0 -2
  176. data/test/sass/templates/nested_import.sass +0 -2
  177. data/test/sass/templates/nested_mixin_bork.sass +0 -6
  178. data/test/sass/templates/options.sass +0 -2
  179. data/test/sass/templates/parent_ref.sass +0 -25
  180. data/test/sass/templates/same_name_different_ext.sass +0 -2
  181. data/test/sass/templates/same_name_different_ext.scss +0 -1
  182. data/test/sass/templates/same_name_different_partiality.scss +0 -1
  183. data/test/sass/templates/script.sass +0 -101
  184. data/test/sass/templates/scss_import.scss +0 -12
  185. data/test/sass/templates/scss_importee.scss +0 -1
  186. data/test/sass/templates/single_import_loop.sass +0 -1
  187. data/test/sass/templates/subdir/import_up1.scss +0 -1
  188. data/test/sass/templates/subdir/import_up2.scss +0 -1
  189. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +0 -2
  190. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +0 -3
  191. data/test/sass/templates/subdir/subdir.sass +0 -6
  192. data/test/sass/templates/units.sass +0 -11
  193. data/test/sass/templates/warn.sass +0 -3
  194. data/test/sass/templates/warn_imported.sass +0 -4
  195. data/test/sass/test_helper.rb +0 -8
  196. data/test/sass/util/multibyte_string_scanner_test.rb +0 -155
  197. data/test/sass/util/normalized_map_test.rb +0 -51
  198. data/test/sass/util/subset_map_test.rb +0 -91
  199. data/test/sass/util_test.rb +0 -438
  200. data/test/sass/value_helpers_test.rb +0 -179
  201. data/test/test_helper.rb +0 -110
  202. data/vendor/listen/CHANGELOG.md +0 -1
  203. data/vendor/listen/CONTRIBUTING.md +0 -38
  204. data/vendor/listen/Gemfile +0 -20
  205. data/vendor/listen/Guardfile +0 -8
  206. data/vendor/listen/LICENSE +0 -20
  207. data/vendor/listen/README.md +0 -349
  208. data/vendor/listen/Rakefile +0 -5
  209. data/vendor/listen/Vagrantfile +0 -96
  210. data/vendor/listen/lib/listen.rb +0 -54
  211. data/vendor/listen/lib/listen/adapter.rb +0 -327
  212. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  213. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  214. data/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  215. data/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  216. data/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  217. data/vendor/listen/lib/listen/directory_record.rb +0 -406
  218. data/vendor/listen/lib/listen/listener.rb +0 -323
  219. data/vendor/listen/lib/listen/turnstile.rb +0 -32
  220. data/vendor/listen/lib/listen/version.rb +0 -3
  221. data/vendor/listen/listen.gemspec +0 -28
  222. data/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  223. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  224. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  225. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  226. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  227. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  228. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  229. data/vendor/listen/spec/listen/listener_spec.rb +0 -258
  230. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  231. data/vendor/listen/spec/listen_spec.rb +0 -67
  232. data/vendor/listen/spec/spec_helper.rb +0 -25
  233. data/vendor/listen/spec/support/adapter_helper.rb +0 -666
  234. data/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  235. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  236. data/vendor/listen/spec/support/listeners_helper.rb +0 -179
  237. data/vendor/listen/spec/support/platform_helper.rb +0 -15
@@ -1,52 +0,0 @@
1
- module Sass
2
- module Script
3
- # An object tracking whether a warning has been emitted for a given script
4
- # tree.
5
- #
6
- # This is shared among all objects in a script tree. Whenever any of those
7
- # objects encounters a situation in which it wouldn't produce semantically
8
- # identical CSS to its input, it calls \{#warn!\}. The first time \{#warn!}
9
- # is called for a given warning object, it prints a deprecation warning.
10
- class CssVariableWarning
11
- def initialize
12
- @warned = false
13
- @value = nil
14
- end
15
-
16
- # Sets the root of the script tree that this warning refers to.
17
- #
18
- # @param value [Sass::Script::Tree::Node]
19
- def value=(value)
20
- warn_called = @warned && !@value
21
- @value = value
22
- print_warning if warn_called
23
- end
24
-
25
- # The first time this is called, it prints a deprecation warning.
26
- #
27
- # This may be called before \{#value=}. If it is, the warning is emitted
28
- # once the script tree is set.
29
- def warn!
30
- return if @warned
31
- @warned = true
32
- return unless @value
33
-
34
- print_warning
35
- end
36
-
37
- private
38
-
39
- # Prints this node's warning.
40
- def print_warning
41
- of_filename = " of #{@value.filename}" if @value.filename
42
- Sass::Util.sass_warn(
43
- "DEPRECATION WARNING on line #{@value.line}#{of_filename}:\n" +
44
- "Sass 3.6 will change the way CSS variables are parsed. Instead of being parsed as\n" +
45
- "normal properties, they will not allow any Sass-specific behavior other than \#{}.\n" +
46
- "For forwards-compatibility, use \#{}:\n" +
47
- "\n" +
48
- " --variable: \#{#{@value.to_sass}};")
49
- end
50
- end
51
- end
52
- end
@@ -1,19 +0,0 @@
1
- module Sass
2
- module Util
3
- # Ruby 1.8 doesn't support an actual Random class with a settable seed.
4
- class CrossPlatformRandom
5
- def initialize(seed = nil)
6
- if Sass::Util.ruby1_8?
7
- srand(seed) if seed
8
- else
9
- @random = seed ? ::Random.new(seed) : ::Random.new
10
- end
11
- end
12
-
13
- def rand(*args)
14
- return @random.rand(*args) if @random
15
- Kernel.rand(*args)
16
- end
17
- end
18
- end
19
- end
@@ -1,192 +0,0 @@
1
- # Copyright (c) 2005-2013 David Heinemeier Hansson
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- # This class was copied from an old version of ActiveSupport.
23
- class OrderedHash < ::Hash
24
- # In MRI the Hash class is core and written in C. In particular, methods are
25
- # programmed with explicit C function calls and polymorphism is not honored.
26
- #
27
- # For example, []= is crucial in this implementation to maintain the @keys
28
- # array but hash.c invokes rb_hash_aset() originally. This prevents method
29
- # reuse through inheritance and forces us to reimplement stuff.
30
- #
31
- # For instance, we cannot use the inherited #merge! because albeit the algorithm
32
- # itself would work, our []= is not being called at all by the C code.
33
-
34
- def initialize(*args)
35
- super
36
- @keys = []
37
- end
38
-
39
- def self.[](*args)
40
- ordered_hash = new
41
-
42
- if args.length == 1 && args.first.is_a?(Array)
43
- args.first.each do |key_value_pair|
44
- next unless key_value_pair.is_a?(Array)
45
- ordered_hash[key_value_pair[0]] = key_value_pair[1]
46
- end
47
-
48
- return ordered_hash
49
- end
50
-
51
- unless args.size.even?
52
- raise ArgumentError.new("odd number of arguments for Hash")
53
- end
54
-
55
- args.each_with_index do |val, ind|
56
- next if ind.odd?
57
- ordered_hash[val] = args[ind + 1]
58
- end
59
-
60
- ordered_hash
61
- end
62
-
63
- def initialize_copy(other)
64
- super
65
- # make a deep copy of keys
66
- @keys = other.keys
67
- end
68
-
69
- def []=(key, value)
70
- @keys << key unless has_key?(key)
71
- super
72
- end
73
-
74
- def delete(key)
75
- if has_key? key
76
- index = @keys.index(key)
77
- @keys.delete_at index
78
- end
79
- super
80
- end
81
-
82
- def delete_if
83
- super
84
- sync_keys!
85
- self
86
- end
87
-
88
- def reject!
89
- super
90
- sync_keys!
91
- self
92
- end
93
-
94
- def reject
95
- dup.reject! {|h, k| yield h, k}
96
- end
97
-
98
- def keys
99
- @keys.dup
100
- end
101
-
102
- def values
103
- @keys.map {|key| self[key]}
104
- end
105
-
106
- def to_hash
107
- self
108
- end
109
-
110
- def to_a
111
- @keys.map {|key| [key, self[key]]}
112
- end
113
-
114
- def each_key
115
- return to_enum(:each_key) unless block_given?
116
- @keys.each {|key| yield key}
117
- self
118
- end
119
-
120
- def each_value
121
- return to_enum(:each_value) unless block_given?
122
- @keys.each {|key| yield self[key]}
123
- self
124
- end
125
-
126
- def each
127
- return to_enum(:each) unless block_given?
128
- @keys.each {|key| yield [key, self[key]]}
129
- self
130
- end
131
-
132
- def each_pair
133
- return to_enum(:each_pair) unless block_given?
134
- @keys.each {|key| yield key, self[key]}
135
- self
136
- end
137
-
138
- alias_method :select, :find_all
139
-
140
- def clear
141
- super
142
- @keys.clear
143
- self
144
- end
145
-
146
- def shift
147
- k = @keys.first
148
- v = delete(k)
149
- [k, v]
150
- end
151
-
152
- def merge!(other_hash)
153
- if block_given?
154
- other_hash.each {|k, v| self[k] = key?(k) ? yield(k, self[k], v) : v}
155
- else
156
- other_hash.each {|k, v| self[k] = v}
157
- end
158
- self
159
- end
160
-
161
- alias_method :update, :merge!
162
-
163
- def merge(other_hash)
164
- if block_given?
165
- dup.merge!(other_hash) {|k, v1, v2| yield k, v1, v2}
166
- else
167
- dup.merge!(other_hash)
168
- end
169
- end
170
-
171
- # When replacing with another hash, the initial order of our keys must come from the other hash --
172
- # ordered or not.
173
- def replace(other)
174
- super
175
- @keys = other.keys
176
- self
177
- end
178
-
179
- def invert
180
- OrderedHash[to_a.map! {|key_value_pair| key_value_pair.reverse}]
181
- end
182
-
183
- def inspect
184
- "#<OrderedHash #{super}>"
185
- end
186
-
187
- private
188
-
189
- def sync_keys!
190
- @keys.delete_if {|k| !has_key?(k)}
191
- end
192
- end
@@ -1,3 +0,0 @@
1
- ---
2
- :enabled: true
3
- :language_version: '3.4'
@@ -1,131 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../test_helper'
3
- require File.dirname(__FILE__) + '/test_helper'
4
- require 'sass/engine'
5
-
6
- class CacheTest < MiniTest::Test
7
- @@cache_dir = "tmp/file_cache"
8
-
9
- def setup
10
- FileUtils.mkdir_p @@cache_dir
11
- end
12
-
13
- def teardown
14
- FileUtils.rm_rf @@cache_dir
15
- clean_up_sassc
16
- end
17
-
18
- def test_file_cache_writes_a_file
19
- file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
20
- file_store.store("asdf/foo.scssc", "fakesha1", root_node)
21
- assert File.exist?("#{@@cache_dir}/asdf/foo.scssc")
22
- end
23
-
24
- def test_file_cache_reads_a_file
25
- file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
26
- assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
27
- file_store.store("asdf/foo.scssc", "fakesha1", root_node)
28
- assert File.exist?("#{@@cache_dir}/asdf/foo.scssc")
29
- assert_kind_of Sass::Tree::RootNode, file_store.retrieve("asdf/foo.scssc", "fakesha1")
30
- end
31
-
32
- def test_file_cache_miss_returns_nil
33
- file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
34
- assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
35
- assert_nil file_store.retrieve("asdf/foo.scssc", "fakesha1")
36
- end
37
-
38
- def test_sha_change_invalidates_cache_and_cleans_up
39
- file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
40
- assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
41
- file_store.store("asdf/foo.scssc", "fakesha1", root_node)
42
- assert File.exist?("#{@@cache_dir}/asdf/foo.scssc")
43
- assert_nil file_store.retrieve("asdf/foo.scssc", "differentsha1")
44
- assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
45
- end
46
-
47
- def test_version_change_invalidates_cache_and_cleans_up
48
- file_store = Sass::CacheStores::Filesystem.new(@@cache_dir)
49
- assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
50
- file_store.store("asdf/foo.scssc", "fakesha1", root_node)
51
- assert File.exist?("#{@@cache_dir}/asdf/foo.scssc")
52
- real_version = Sass::VERSION
53
- begin
54
- Sass::VERSION.replace("a different version")
55
- assert_nil file_store.retrieve("asdf/foo.scssc", "fakesha1")
56
- assert !File.exist?("#{@@cache_dir}/asdf/foo.scssc")
57
- ensure
58
- Sass::VERSION.replace(real_version)
59
- end
60
- end
61
-
62
- def test_arbitrary_objects_can_go_into_cache
63
- cache = Sass::CacheStores::Memory.new
64
- an_object = {:foo => :bar}
65
- cache.store("an_object", "", an_object)
66
- assert_equal an_object, cache.retrieve("an_object", "")
67
- end
68
-
69
- def test_cache_node_with_unmarshalable_option
70
- engine_with_unmarshalable_options("foo {a: b + c}").to_tree
71
- end
72
-
73
- # Regression tests
74
-
75
- def test_cache_mixin_def_splat_sass_node_with_unmarshalable_option
76
- engine_with_unmarshalable_options(<<SASS, :syntax => :sass).to_tree
77
- =color($args...)
78
- color: red
79
- SASS
80
- end
81
-
82
- def test_cache_mixin_def_splat_scss_node_with_unmarshalable_option
83
- engine_with_unmarshalable_options(<<SCSS, :syntax => :scss).to_tree
84
- @mixin color($args...) {
85
- color: red;
86
- }
87
- SCSS
88
- end
89
-
90
- def test_cache_function_splat_sass_node_with_unmarshalable_option
91
- engine_with_unmarshalable_options(<<SASS, :syntax => :sass).to_tree
92
- @function color($args...)
93
- @return red
94
- SASS
95
- end
96
-
97
- def test_cache_function_splat_scss_node_with_unmarshalable_option
98
- engine_with_unmarshalable_options(<<SCSS, :syntax => :scss).to_tree
99
- @function color($args...) {
100
- @return red;
101
- }
102
- SCSS
103
- end
104
-
105
- def test_cache_include_splat_sass_node_with_unmarshalable_option
106
- engine_with_unmarshalable_options(<<SASS, :syntax => :sass).to_tree
107
- @include color($args..., $kwargs...)
108
- SASS
109
- end
110
-
111
- def test_cache_include_splat_scss_node_with_unmarshalable_option
112
- engine_with_unmarshalable_options(<<SCSS, :syntax => :scss).to_tree
113
- @include color($args..., $kwargs...);
114
- SCSS
115
- end
116
-
117
- private
118
- def root_node
119
- Sass::Engine.new(<<-SCSS, :syntax => :scss).to_tree
120
- @mixin color($c) { color: $c}
121
- div { @include color(red); }
122
- SCSS
123
- end
124
-
125
- def engine_with_unmarshalable_options(src, options={})
126
- Sass::Engine.new(src, {
127
- :syntax => :scss, :object => Class.new.new, :filename => 'file.scss',
128
- :importer => Sass::Importers::Filesystem.new(absolutize('templates'))
129
- }.merge(options))
130
- end
131
- end
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../test_helper'
3
- require 'sass/callbacks'
4
-
5
- class CallerBack
6
- extend Sass::Callbacks
7
- define_callback :foo
8
- define_callback :bar
9
-
10
- def do_foo
11
- run_foo
12
- end
13
-
14
- def do_bar
15
- run_bar 12
16
- end
17
- end
18
-
19
- module ClassLevelCallerBack
20
- extend Sass::Callbacks
21
- define_callback :foo
22
- extend self
23
-
24
- def do_foo
25
- run_foo
26
- end
27
- end
28
-
29
- class SassCallbacksTest < MiniTest::Test
30
- def test_simple_callback
31
- cb = CallerBack.new
32
- there = false
33
- cb.on_foo {there = true}
34
- cb.do_foo
35
- assert there, "Expected callback to be called."
36
- end
37
-
38
- def test_multiple_callbacks
39
- cb = CallerBack.new
40
- str = ""
41
- cb.on_foo {str += "first"}
42
- cb.on_foo {str += " second"}
43
- cb.do_foo
44
- assert_equal "first second", str
45
- end
46
-
47
- def test_callback_with_arg
48
- cb = CallerBack.new
49
- val = nil
50
- cb.on_bar {|a| val = a}
51
- cb.do_bar
52
- assert_equal 12, val
53
- end
54
-
55
- def test_class_level_callback
56
- there = false
57
- ClassLevelCallerBack.on_foo {there = true}
58
- ClassLevelCallerBack.do_foo
59
- assert there, "Expected callback to be called."
60
- end
61
- end