sass 3.4.25 → 3.5.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/README.md +1 -1
  4. data/Rakefile +13 -157
  5. data/VERSION +1 -1
  6. data/VERSION_DATE +1 -1
  7. data/VERSION_NAME +1 -1
  8. data/lib/sass.rb +3 -10
  9. data/lib/sass/cache_stores/filesystem.rb +1 -1
  10. data/lib/sass/css.rb +2 -3
  11. data/lib/sass/engine.rb +46 -32
  12. data/lib/sass/environment.rb +27 -6
  13. data/lib/sass/error.rb +5 -5
  14. data/lib/sass/exec/base.rb +3 -12
  15. data/lib/sass/features.rb +1 -0
  16. data/lib/sass/importers/filesystem.rb +2 -2
  17. data/lib/sass/plugin.rb +1 -1
  18. data/lib/sass/plugin/compiler.rb +21 -51
  19. data/lib/sass/plugin/configuration.rb +1 -1
  20. data/lib/sass/plugin/rack.rb +3 -3
  21. data/lib/sass/plugin/staleness_checker.rb +3 -3
  22. data/lib/sass/railtie.rb +1 -1
  23. data/lib/sass/script.rb +3 -3
  24. data/lib/sass/script/functions.rb +238 -47
  25. data/lib/sass/script/lexer.rb +8 -6
  26. data/lib/sass/script/parser.rb +76 -75
  27. data/lib/sass/script/tree/funcall.rb +35 -30
  28. data/lib/sass/script/tree/list_literal.rb +23 -8
  29. data/lib/sass/script/tree/map_literal.rb +2 -2
  30. data/lib/sass/script/tree/node.rb +2 -10
  31. data/lib/sass/script/tree/operation.rb +16 -50
  32. data/lib/sass/script/value.rb +2 -0
  33. data/lib/sass/script/value/arg_list.rb +1 -1
  34. data/lib/sass/script/value/base.rb +20 -3
  35. data/lib/sass/script/value/callable.rb +25 -0
  36. data/lib/sass/script/value/color.rb +10 -10
  37. data/lib/sass/script/value/function.rb +19 -0
  38. data/lib/sass/script/value/helpers.rb +16 -7
  39. data/lib/sass/script/value/list.rb +33 -12
  40. data/lib/sass/script/value/map.rb +2 -2
  41. data/lib/sass/script/value/number.rb +3 -3
  42. data/lib/sass/script/value/string.rb +12 -5
  43. data/lib/sass/scss/parser.rb +101 -45
  44. data/lib/sass/scss/rx.rb +5 -11
  45. data/lib/sass/scss/static_parser.rb +0 -7
  46. data/lib/sass/selector.rb +4 -0
  47. data/lib/sass/selector/abstract_sequence.rb +5 -5
  48. data/lib/sass/selector/comma_sequence.rb +3 -15
  49. data/lib/sass/selector/pseudo.rb +4 -0
  50. data/lib/sass/selector/sequence.rb +30 -3
  51. data/lib/sass/selector/simple.rb +13 -7
  52. data/lib/sass/selector/simple_sequence.rb +1 -1
  53. data/lib/sass/shared.rb +3 -5
  54. data/lib/sass/source/map.rb +4 -4
  55. data/lib/sass/source/position.rb +4 -4
  56. data/lib/sass/stack.rb +21 -1
  57. data/lib/sass/tree/charset_node.rb +1 -1
  58. data/lib/sass/tree/comment_node.rb +1 -1
  59. data/lib/sass/tree/node.rb +3 -3
  60. data/lib/sass/tree/prop_node.rb +46 -54
  61. data/lib/sass/tree/rule_node.rb +7 -15
  62. data/lib/sass/tree/visitors/check_nesting.rb +1 -1
  63. data/lib/sass/tree/visitors/convert.rb +2 -3
  64. data/lib/sass/tree/visitors/cssize.rb +1 -10
  65. data/lib/sass/tree/visitors/deep_copy.rb +2 -2
  66. data/lib/sass/tree/visitors/perform.rb +23 -12
  67. data/lib/sass/tree/visitors/set_options.rb +1 -1
  68. data/lib/sass/tree/visitors/to_css.rb +46 -12
  69. data/lib/sass/util.rb +16 -321
  70. data/lib/sass/util/multibyte_string_scanner.rb +127 -131
  71. data/lib/sass/util/normalized_map.rb +1 -8
  72. data/lib/sass/version.rb +2 -2
  73. data/test/sass-spec.yml +1 -1
  74. data/test/sass/compiler_test.rb +4 -14
  75. data/test/sass/conversion_test.rb +113 -162
  76. data/test/sass/css2sass_test.rb +17 -19
  77. data/test/sass/css_variable_test.rb +176 -70
  78. data/test/sass/encoding_test.rb +2 -32
  79. data/test/sass/engine_test.rb +114 -65
  80. data/test/sass/extend_test.rb +37 -51
  81. data/test/sass/functions_test.rb +57 -15
  82. data/test/sass/importer_test.rb +2 -2
  83. data/test/sass/more_templates/more1.sass +10 -10
  84. data/test/sass/more_templates/more_import.sass +2 -2
  85. data/test/sass/plugin_test.rb +9 -12
  86. data/test/sass/script_conversion_test.rb +9 -0
  87. data/test/sass/script_test.rb +38 -48
  88. data/test/sass/scss/css_test.rb +5 -19
  89. data/test/sass/scss/scss_test.rb +58 -39
  90. data/test/sass/source_map_test.rb +26 -28
  91. data/test/sass/templates/_partial.sass +1 -1
  92. data/test/sass/templates/basic.sass +10 -10
  93. data/test/sass/templates/bork1.sass +1 -1
  94. data/test/sass/templates/bork5.sass +1 -1
  95. data/test/sass/templates/compact.sass +10 -10
  96. data/test/sass/templates/complex.sass +187 -187
  97. data/test/sass/templates/compressed.sass +10 -10
  98. data/test/sass/templates/expanded.sass +10 -10
  99. data/test/sass/templates/import.sass +2 -2
  100. data/test/sass/templates/importee.sass +3 -3
  101. data/test/sass/templates/mixins.sass +22 -22
  102. data/test/sass/templates/multiline.sass +4 -4
  103. data/test/sass/templates/nested.sass +13 -13
  104. data/test/sass/templates/parent_ref.sass +12 -12
  105. data/test/sass/templates/script.sass +70 -70
  106. data/test/sass/templates/subdir/nested_subdir/_nested_partial.sass +1 -1
  107. data/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +2 -2
  108. data/test/sass/templates/subdir/subdir.sass +3 -3
  109. data/test/sass/templates/units.sass +10 -10
  110. data/test/sass/util/multibyte_string_scanner_test.rb +139 -149
  111. data/test/sass/util_test.rb +0 -36
  112. data/test/test_helper.rb +39 -0
  113. metadata +30 -57
  114. data/extra/sass-spec-ref.sh +0 -32
  115. data/lib/sass/deprecation.rb +0 -55
  116. data/lib/sass/script/css_variable_warning.rb +0 -52
  117. data/lib/sass/util/cross_platform_random.rb +0 -19
  118. data/lib/sass/util/ordered_hash.rb +0 -192
  119. data/test/sass/results/import_charset_1_8.css +0 -5
  120. data/test/sass/templates/import_charset_1_8.sass +0 -6
  121. data/vendor/listen/CHANGELOG.md +0 -1
  122. data/vendor/listen/CONTRIBUTING.md +0 -38
  123. data/vendor/listen/Gemfile +0 -20
  124. data/vendor/listen/Guardfile +0 -8
  125. data/vendor/listen/LICENSE +0 -20
  126. data/vendor/listen/README.md +0 -349
  127. data/vendor/listen/Rakefile +0 -5
  128. data/vendor/listen/Vagrantfile +0 -96
  129. data/vendor/listen/lib/listen.rb +0 -54
  130. data/vendor/listen/lib/listen/adapter.rb +0 -327
  131. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  132. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  133. data/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  134. data/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  135. data/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  136. data/vendor/listen/lib/listen/directory_record.rb +0 -406
  137. data/vendor/listen/lib/listen/listener.rb +0 -323
  138. data/vendor/listen/lib/listen/turnstile.rb +0 -32
  139. data/vendor/listen/lib/listen/version.rb +0 -3
  140. data/vendor/listen/listen.gemspec +0 -28
  141. data/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  142. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  143. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  144. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  145. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  146. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  147. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  148. data/vendor/listen/spec/listen/listener_spec.rb +0 -258
  149. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  150. data/vendor/listen/spec/listen_spec.rb +0 -67
  151. data/vendor/listen/spec/spec_helper.rb +0 -25
  152. data/vendor/listen/spec/support/adapter_helper.rb +0 -666
  153. data/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  154. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  155. data/vendor/listen/spec/support/listeners_helper.rb +0 -179
  156. data/vendor/listen/spec/support/platform_helper.rb +0 -15
@@ -1,54 +0,0 @@
1
- require 'listen/turnstile'
2
- require 'listen/listener'
3
- require 'listen/directory_record'
4
- require 'listen/adapter'
5
-
6
- module Listen
7
-
8
- module Adapters
9
- Adapter::ADAPTERS.each do |adapter|
10
- require "listen/adapters/#{adapter.downcase}"
11
- end
12
- end
13
-
14
- # Listens to file system modifications on a either single directory or multiple directories.
15
- # When calling this method, the current thread is not blocked.
16
- #
17
- # @param (see Listen::Listener#new)
18
- #
19
- # @yield [modified, added, removed] the changed files
20
- # @yieldparam [Array<String>] modified the list of modified files
21
- # @yieldparam [Array<String>] added the list of added files
22
- # @yieldparam [Array<String>] removed the list of removed files
23
- #
24
- # @return [Listen::Listener] the file listener if no block given
25
- #
26
- def self.to(*args, &block)
27
- listener = _init_listener(*args, &block)
28
-
29
- block ? listener.start : listener
30
- end
31
-
32
- # Listens to file system modifications on a either single directory or multiple directories.
33
- # When calling this method, the current thread is blocked.
34
- #
35
- # @param (see Listen::Listener#new)
36
- #
37
- # @yield [modified, added, removed] the changed files
38
- # @yieldparam [Array<String>] modified the list of modified files
39
- # @yieldparam [Array<String>] added the list of added files
40
- # @yieldparam [Array<String>] removed the list of removed files
41
- #
42
- # @since 1.0.0
43
- #
44
- def self.to!(*args, &block)
45
- _init_listener(*args, &block).start!
46
- end
47
-
48
- # @private
49
- #
50
- def self._init_listener(*args, &block)
51
- Listener.new(*args, &block)
52
- end
53
-
54
- end
@@ -1,327 +0,0 @@
1
- require 'rbconfig'
2
- require 'thread'
3
- require 'set'
4
- require 'fileutils'
5
-
6
- module Listen
7
- class Adapter
8
- attr_accessor :directories, :callback, :stopped, :paused,
9
- :mutex, :changed_directories, :turnstile, :latency,
10
- :worker, :worker_thread, :poller_thread
11
-
12
- # The list of existing optimized adapters.
13
- OPTIMIZED_ADAPTERS = %w[Darwin Linux BSD Windows]
14
-
15
- # The list of existing fallback adapters.
16
- FALLBACK_ADAPTERS = %w[Polling]
17
-
18
- # The list of all existing adapters.
19
- ADAPTERS = OPTIMIZED_ADAPTERS + FALLBACK_ADAPTERS
20
-
21
- # The default delay between checking for changes.
22
- DEFAULT_LATENCY = 0.25
23
-
24
- # The default warning message when falling back to polling adapter.
25
- POLLING_FALLBACK_MESSAGE = <<-EOS.gsub(/^\s*/, '')
26
- Listen will be polling for changes. Learn more at https://github.com/guard/listen#polling-fallback.
27
- EOS
28
-
29
- # Selects the appropriate adapter implementation for the
30
- # current OS and initializes it.
31
- #
32
- # @param [String, Array<String>] directories the directories to watch
33
- # @param [Hash] options the adapter options
34
- # @option options [Boolean] force_polling to force polling or not
35
- # @option options [String, Boolean] polling_fallback_message to change polling fallback message or remove it
36
- # @option options [Float] latency the delay between checking for changes in seconds
37
- #
38
- # @yield [changed_directories, options] callback the callback called when a change happens
39
- # @yieldparam [Array<String>] changed_directories the changed directories
40
- # @yieldparam [Hash] options callback options (like recursive: true)
41
- #
42
- # @return [Listen::Adapter] the chosen adapter
43
- #
44
- def self.select_and_initialize(directories, options = {}, &callback)
45
- forced_adapter_class = options.delete(:force_adapter)
46
- force_polling = options.delete(:force_polling)
47
-
48
- if forced_adapter_class
49
- forced_adapter_class.load_dependent_adapter
50
- return forced_adapter_class.new(directories, options, &callback)
51
- end
52
-
53
- return Adapters::Polling.new(directories, options, &callback) if force_polling
54
-
55
- OPTIMIZED_ADAPTERS.each do |adapter|
56
- namespaced_adapter = Adapters.const_get(adapter)
57
- if namespaced_adapter.send(:usable_and_works?, directories, options)
58
- return namespaced_adapter.new(directories, options, &callback)
59
- end
60
- end
61
-
62
- self.warn_polling_fallback(options)
63
- Adapters::Polling.new(directories, options, &callback)
64
- end
65
-
66
- # Initializes the adapter.
67
- #
68
- # @param [String, Array<String>] directories the directories to watch
69
- # @param [Hash] options the adapter options
70
- # @option options [Float] latency the delay between checking for changes in seconds
71
- #
72
- # @yield [changed_directories, options] callback Callback called when a change happens
73
- # @yieldparam [Array<String>] changed_directories the changed directories
74
- # @yieldparam [Hash] options callback options (like recursive: true)
75
- #
76
- # @return [Listen::Adapter] the adapter
77
- #
78
- def initialize(directories, options = {}, &callback)
79
- @directories = Array(directories)
80
- @callback = callback
81
- @stopped = true
82
- @paused = false
83
- @mutex = Mutex.new
84
- @changed_directories = Set.new
85
- @turnstile = Turnstile.new
86
- @latency = options.fetch(:latency, default_latency)
87
- @worker = initialize_worker
88
- end
89
-
90
- # Starts the adapter and don't block the current thread.
91
- #
92
- # @param [Boolean] blocking whether or not to block the current thread after starting
93
- #
94
- def start
95
- mutex.synchronize do
96
- return unless stopped
97
- @stopped = false
98
- end
99
-
100
- start_worker
101
- start_poller
102
- end
103
-
104
- # Starts the adapter and block the current thread.
105
- #
106
- # @since 1.0.0
107
- #
108
- def start!
109
- start
110
- blocking_thread.join
111
- end
112
-
113
- # Stops the adapter.
114
- #
115
- def stop
116
- mutex.synchronize do
117
- return if stopped
118
- @stopped = true
119
- turnstile.signal # ensure no thread is blocked
120
- end
121
-
122
- worker.stop if worker
123
- Thread.kill(worker_thread) if worker_thread
124
- if poller_thread
125
- poller_thread.kill
126
- poller_thread.join
127
- end
128
- end
129
-
130
- # Pauses the adapter.
131
- #
132
- def pause
133
- @paused = true
134
- end
135
-
136
- # Unpauses the adapter.
137
- #
138
- def unpause
139
- @paused = false
140
- end
141
-
142
- # Returns whether the adapter is started or not.
143
- #
144
- # @return [Boolean] whether the adapter is started or not
145
- #
146
- def started?
147
- !stopped
148
- end
149
-
150
- # Returns whether the adapter is paused or not.
151
- #
152
- # @return [Boolean] whether the adapter is paused or not
153
- #
154
- def paused?
155
- paused
156
- end
157
-
158
- # Blocks the main thread until the poll thread
159
- # runs the callback.
160
- #
161
- def wait_for_callback
162
- turnstile.wait unless paused
163
- end
164
-
165
- # Blocks the main thread until N changes are
166
- # detected.
167
- #
168
- def wait_for_changes(threshold = 0)
169
- changes = 0
170
-
171
- loop do
172
- mutex.synchronize { changes = changed_directories.size }
173
-
174
- return if paused || stopped
175
- return if changes >= threshold
176
-
177
- sleep(latency)
178
- end
179
- end
180
-
181
- # Checks if the adapter is usable and works on the current OS.
182
- #
183
- # @param [String, Array<String>] directories the directories to watch
184
- # @param [Hash] options the adapter options
185
- # @option options [Float] latency the delay between checking for changes in seconds
186
- #
187
- # @return [Boolean] whether the adapter is usable and work or not
188
- #
189
- def self.usable_and_works?(directories, options = {})
190
- usable? && Array(directories).all? { |d| works?(d, options) }
191
- end
192
-
193
- # Checks if the adapter is usable on target OS.
194
- #
195
- # @return [Boolean] whether usable or not
196
- #
197
- def self.usable?
198
- load_dependent_adapter if RbConfig::CONFIG['target_os'] =~ target_os_regex
199
- end
200
-
201
- # Load the adapter gem
202
- #
203
- # @return [Boolean] whether loaded or not
204
- #
205
- def self.load_dependent_adapter
206
- return true if @loaded
207
- require adapter_gem
208
- return @loaded = true
209
- rescue LoadError
210
- false
211
- end
212
-
213
- # Runs a tests to determine if the adapter can actually pick up
214
- # changes in a given directory and returns the result.
215
- #
216
- # @note This test takes some time depending on the adapter latency.
217
- #
218
- # @param [String, Pathname] directory the directory to watch
219
- # @param [Hash] options the adapter options
220
- # @option options [Float] latency the delay between checking for changes in seconds
221
- #
222
- # @return [Boolean] whether the adapter works or not
223
- #
224
- def self.works?(directory, options = {})
225
- work = false
226
- test_file = "#{directory}/.listen_test"
227
- callback = lambda { |*| work = true }
228
- adapter = self.new(directory, options, &callback)
229
- adapter.start
230
-
231
- FileUtils.touch(test_file)
232
-
233
- t = Thread.new { sleep(adapter.latency * 5); adapter.stop }
234
-
235
- adapter.wait_for_callback
236
- work
237
- ensure
238
- Thread.kill(t) if t
239
- FileUtils.rm(test_file, :force => true)
240
- adapter.stop if adapter && adapter.started?
241
- end
242
-
243
- # Runs the callback and passes it the changes if there are any.
244
- #
245
- def report_changes
246
- changed_dirs = nil
247
-
248
- mutex.synchronize do
249
- return if @changed_directories.empty?
250
- changed_dirs = @changed_directories.to_a
251
- @changed_directories.clear
252
- end
253
-
254
- callback.call(changed_dirs, {})
255
- turnstile.signal
256
- end
257
-
258
- private
259
-
260
- # The default delay between checking for changes.
261
- #
262
- # @note This method can be overriden on a per-adapter basis.
263
- #
264
- def default_latency
265
- DEFAULT_LATENCY
266
- end
267
-
268
- # The thread on which the main thread should wait
269
- # when the adapter has been started in blocking mode.
270
- #
271
- # @note This method can be overriden on a per-adapter basis.
272
- #
273
- def blocking_thread
274
- worker_thread
275
- end
276
-
277
- # Initialize the adpater' specific worker.
278
- #
279
- # @note Each adapter must override this method
280
- # to initialize its own @worker.
281
- #
282
- def initialize_worker
283
- nil
284
- end
285
-
286
- # Should start the worker in a new thread.
287
- #
288
- # @note Each adapter must override this method
289
- # to start its worker on a new @worker_thread thread.
290
- #
291
- def start_worker
292
- raise NotImplementedError, "#{self.class} cannot respond to: #{__method__}"
293
- end
294
-
295
- # This method starts a new thread which poll for changes detected by
296
- # the adapter and report them back to the user.
297
- #
298
- def start_poller
299
- @poller_thread = Thread.new { poll_changed_directories }
300
- end
301
-
302
- # Warn of polling fallback unless the :polling_fallback_message
303
- # has been set to false.
304
- #
305
- # @param [String] warning an existing warning message
306
- # @param [Hash] options the adapter options
307
- # @option options [Boolean] polling_fallback_message to change polling fallback message or remove it
308
- #
309
- def self.warn_polling_fallback(options)
310
- return if options[:polling_fallback_message] == false
311
-
312
- warning = options[:polling_fallback_message] || POLLING_FALLBACK_MESSAGE
313
- Kernel.warn "[Listen warning]:\n#{warning.gsub(/^(.*)/, ' \1')}"
314
- end
315
-
316
- # Polls changed directories and reports them back when there are changes.
317
- #
318
- # @note This method can be overriden on a per-adapter basis.
319
- #
320
- def poll_changed_directories
321
- until stopped
322
- sleep(latency)
323
- report_changes
324
- end
325
- end
326
- end
327
- end
@@ -1,75 +0,0 @@
1
- module Listen
2
- module Adapters
3
-
4
- # Listener implementation for BSD's `kqueue`.
5
- #
6
- class BSD < Adapter
7
- # Watched kqueue events
8
- #
9
- # @see http://www.freebsd.org/cgi/man.cgi?query=kqueue
10
- # @see https://github.com/nex3/rb-kqueue/blob/master/lib/rb-kqueue/queue.rb
11
- #
12
- EVENTS = [:delete, :write, :extend, :attrib, :link, :rename, :revoke]
13
-
14
- def self.target_os_regex; /freebsd/i; end
15
- def self.adapter_gem; 'rb-kqueue'; end
16
-
17
- private
18
-
19
- # Initializes a kqueue Queue and adds a watcher for each files in
20
- # the directories passed to the adapter.
21
- #
22
- # @return [INotify::Notifier] initialized kqueue
23
- #
24
- # @see Listen::Adapter#initialize_worker
25
- #
26
- def initialize_worker
27
- require 'find'
28
-
29
- callback = lambda do |event|
30
- path = event.watcher.path
31
- mutex.synchronize do
32
- # kqueue watches everything, but Listen only needs the
33
- # directory where stuffs happens.
34
- @changed_directories << (File.directory?(path) ? path : File.dirname(path))
35
-
36
- # If it is a directory, and it has a write flag, it means a
37
- # file has been added so find out which and deal with it.
38
- # No need to check for removed files, kqueue will forget them
39
- # when the vfs does.
40
- if File.directory?(path) && event.flags.include?(:write)
41
- queue = event.watcher.queue
42
- Find.find(path) do |file|
43
- unless queue.watchers.detect { |k,v| v.path == file.to_s }
44
- queue.watch_file(file, *EVENTS, &callback)
45
- end
46
- end
47
- end
48
- end
49
- end
50
-
51
- KQueue::Queue.new.tap do |queue|
52
- directories.each do |directory|
53
- Find.find(directory) do |path|
54
- queue.watch_file(path, *EVENTS, &callback)
55
- end
56
- end
57
- end
58
- end
59
-
60
- # Starts the worker in a new thread.
61
- #
62
- # @see Listen::Adapter#start_worker
63
- #
64
- def start_worker
65
- @worker_thread = Thread.new do
66
- until stopped
67
- worker.poll
68
- sleep(latency)
69
- end
70
- end
71
- end
72
- end
73
-
74
- end
75
- end