sass 3.2.0.alpha.101 → 3.2.0.alpha.102

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 (45) hide show
  1. data/REVISION +1 -1
  2. data/Rakefile +2 -2
  3. data/VERSION +1 -1
  4. data/lib/sass/plugin/compiler.rb +25 -32
  5. data/lib/sass/plugin/listener.rb +59 -0
  6. data/lib/sass/script/lexer.rb +1 -1
  7. data/lib/sass/script/list.rb +1 -0
  8. data/test/sass/conversion_test.rb +10 -0
  9. data/test/sass/scss/css_test.rb +9 -0
  10. data/vendor/listen/CHANGELOG.md +72 -0
  11. data/vendor/listen/Gemfile +35 -0
  12. data/vendor/listen/Guardfile +8 -0
  13. data/vendor/listen/LICENSE +20 -0
  14. data/vendor/listen/README.md +297 -0
  15. data/vendor/listen/Rakefile +47 -0
  16. data/vendor/listen/Vagrantfile +96 -0
  17. data/vendor/listen/lib/listen.rb +38 -0
  18. data/vendor/listen/lib/listen/adapter.rb +159 -0
  19. data/vendor/listen/lib/listen/adapters/darwin.rb +84 -0
  20. data/vendor/listen/lib/listen/adapters/linux.rb +99 -0
  21. data/vendor/listen/lib/listen/adapters/polling.rb +66 -0
  22. data/vendor/listen/lib/listen/adapters/windows.rb +82 -0
  23. data/vendor/listen/lib/listen/directory_record.rb +257 -0
  24. data/vendor/listen/lib/listen/listener.rb +186 -0
  25. data/vendor/listen/lib/listen/multi_listener.rb +121 -0
  26. data/vendor/listen/lib/listen/turnstile.rb +28 -0
  27. data/vendor/listen/lib/listen/version.rb +3 -0
  28. data/vendor/listen/listen.gemspec +26 -0
  29. data/vendor/listen/spec/listen/adapter_spec.rb +142 -0
  30. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +31 -0
  31. data/vendor/listen/spec/listen/adapters/linux_spec.rb +30 -0
  32. data/vendor/listen/spec/listen/adapters/polling_spec.rb +68 -0
  33. data/vendor/listen/spec/listen/adapters/windows_spec.rb +24 -0
  34. data/vendor/listen/spec/listen/directory_record_spec.rb +807 -0
  35. data/vendor/listen/spec/listen/listener_spec.rb +151 -0
  36. data/vendor/listen/spec/listen/multi_listener_spec.rb +151 -0
  37. data/vendor/listen/spec/listen/turnstile_spec.rb +56 -0
  38. data/vendor/listen/spec/listen_spec.rb +73 -0
  39. data/vendor/listen/spec/spec_helper.rb +16 -0
  40. data/vendor/listen/spec/support/adapter_helper.rb +538 -0
  41. data/vendor/listen/spec/support/directory_record_helper.rb +35 -0
  42. data/vendor/listen/spec/support/fixtures_helper.rb +29 -0
  43. data/vendor/listen/spec/support/listeners_helper.rb +133 -0
  44. data/vendor/listen/spec/support/platform_helper.rb +11 -0
  45. metadata +41 -5
@@ -0,0 +1,538 @@
1
+ # Adapter watch
2
+ #
3
+ # @param [Listen::Listener] listener the adapter listener
4
+ # @param [String] path the path to watch
5
+ #
6
+ def watch(listener, *paths)
7
+ callback = lambda { |changed_dirs, options| @called = true; listener.on_change(changed_dirs, options) }
8
+ @adapter = Listen::Adapter.select_and_initialize(paths, { :latency => test_latency }, &callback)
9
+ @adapter.start(false)
10
+
11
+ yield
12
+
13
+ t = Thread.new { sleep(test_latency * 5); @adapter.stop }
14
+ @adapter.wait_for_callback
15
+ ensure
16
+ Thread.kill(t) if t
17
+ @adapter.stop
18
+ end
19
+
20
+ shared_examples_for 'a filesystem adapter' do
21
+ subject { described_class.new(File.dirname(__FILE__), &Proc.new {}) }
22
+
23
+ describe '#start' do
24
+ after { subject.stop }
25
+
26
+ context 'with the blocking param set to true' do
27
+ it 'blocks the current thread after starting the workers' do
28
+ @called = false
29
+ t = Thread.new { subject.start(true); @called = true }
30
+ sleep(test_latency * 3)
31
+ Thread.kill(t) if t
32
+ @called.should be_false
33
+ end
34
+ end
35
+
36
+ context 'with the blocking param set to false' do
37
+ it 'does not block the current thread after starting the workers' do
38
+ @called = false
39
+ t = Thread.new { subject.start(false); @called = true }
40
+ sleep(test_latency * 3)
41
+ Thread.kill(t) if t
42
+ @called.should be_true
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ shared_examples_for 'an adapter that call properly listener#on_change' do |*args|
49
+ options = (args.first && args.first.is_a?(Hash)) ? args.first : {}
50
+ let(:listener) { mock(Listen::Listener) }
51
+ before { described_class.stub(:works?) { true } }
52
+
53
+ context 'single file operations' do
54
+ context 'when a file is created' do
55
+ it 'detects the added file' do
56
+ fixtures do |path|
57
+ if options[:recursive]
58
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
59
+ else
60
+ listener.should_receive(:on_change).once.with([path], {})
61
+ end
62
+
63
+ watch(listener, path) do
64
+ touch 'new_file.rb'
65
+ end
66
+ end
67
+ end
68
+
69
+ context 'given a new created directory' do
70
+ it 'detects the added file' do
71
+ fixtures do |path|
72
+ if options[:recursive]
73
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
74
+ else
75
+ listener.should_receive(:on_change).once.with do |array, options|
76
+ array.should =~ [path, "#{path}/a_directory"]
77
+ end
78
+ end
79
+
80
+ watch(listener, path) do
81
+ mkdir 'a_directory'
82
+ # Needed for INotify, because of :recursive rb-inotify custom flag?
83
+ sleep 0.05 if @adapter.is_a?(Listen::Adapters::Linux)
84
+ touch 'a_directory/new_file.rb'
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+ context 'given an existing directory' do
91
+ it 'detects the added file' do
92
+ fixtures do |path|
93
+ if options[:recursive]
94
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
95
+ else
96
+ listener.should_receive(:on_change).once.with(["#{path}/a_directory"], {})
97
+ end
98
+
99
+ mkdir 'a_directory'
100
+
101
+ watch(listener, path) do
102
+ touch 'a_directory/new_file.rb'
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ context 'when a file is modified' do
110
+ it 'detects the modified file' do
111
+ fixtures do |path|
112
+ if options[:recursive]
113
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
114
+ else
115
+ listener.should_receive(:on_change).once.with([path], {})
116
+ end
117
+
118
+ touch 'existing_file.txt'
119
+
120
+ watch(listener, path) do
121
+ touch 'existing_file.txt'
122
+ end
123
+ end
124
+ end
125
+
126
+ context 'given a hidden file' do
127
+ it 'detects the modified file' do
128
+ fixtures do |path|
129
+ if options[:recursive]
130
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
131
+ else
132
+ listener.should_receive(:on_change).once.with([path], {})
133
+ end
134
+
135
+ touch '.hidden'
136
+
137
+ watch(listener, path) do
138
+ touch '.hidden'
139
+ end
140
+ end
141
+ end
142
+ end
143
+
144
+ unless options[:adapter] == :windows
145
+ context 'given a file mode change' do
146
+ it 'does not detect the mode change' do
147
+ fixtures do |path|
148
+ if options[:recursive]
149
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
150
+ else
151
+ listener.should_receive(:on_change).once.with([path], {})
152
+ end
153
+
154
+ touch 'run.rb'
155
+
156
+ watch(listener, path) do
157
+ chmod 0777, 'run.rb'
158
+ end
159
+ end
160
+ end
161
+ end
162
+ end
163
+
164
+ context 'given an existing directory' do
165
+ it 'detects the modified file' do
166
+ fixtures do |path|
167
+ if options[:recursive]
168
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
169
+ else
170
+ listener.should_receive(:on_change).once.with(["#{path}/a_directory"], {})
171
+ end
172
+
173
+ mkdir 'a_directory'
174
+ touch 'a_directory/existing_file.txt'
175
+
176
+ watch(listener, path) do
177
+ touch 'a_directory/existing_file.txt'
178
+ end
179
+ end
180
+ end
181
+ end
182
+ end
183
+
184
+ context 'when a file is moved' do
185
+ it 'detects the file move' do
186
+ fixtures do |path|
187
+ if options[:recursive]
188
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
189
+ else
190
+ listener.should_receive(:on_change).once.with([path], {})
191
+ end
192
+
193
+ touch 'move_me.txt'
194
+
195
+ watch(listener, path) do
196
+ mv 'move_me.txt', 'new_name.txt'
197
+ end
198
+ end
199
+ end
200
+
201
+ context 'given an existing directory' do
202
+ it 'detects the file move into the directory' do
203
+ fixtures do |path|
204
+ if options[:recursive]
205
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
206
+ else
207
+ listener.should_receive(:on_change).once.with do |array, options|
208
+ array.should =~ [path, "#{path}/a_directory"]
209
+ end
210
+ end
211
+
212
+ mkdir 'a_directory'
213
+ touch 'move_me.txt'
214
+
215
+ watch(listener, path) do
216
+ mv 'move_me.txt', 'a_directory/move_me.txt'
217
+ end
218
+ end
219
+ end
220
+
221
+ it 'detects a file move out of the directory' do
222
+ fixtures do |path|
223
+ if options[:recursive]
224
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
225
+ else
226
+ listener.should_receive(:on_change).once.with do |array, options|
227
+ array.should =~ [path, "#{path}/a_directory"]
228
+ end
229
+ end
230
+
231
+ mkdir 'a_directory'
232
+ touch 'a_directory/move_me.txt'
233
+
234
+ watch(listener, path) do
235
+ mv 'a_directory/move_me.txt', 'i_am_here.txt'
236
+ end
237
+ end
238
+ end
239
+
240
+ it 'detects a file move between two directories' do
241
+ fixtures do |path|
242
+ if options[:recursive]
243
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
244
+ else
245
+ listener.should_receive(:on_change).once.with do |array, options|
246
+ array.should =~ ["#{path}/from_directory", "#{path}/to_directory"]
247
+ end
248
+ end
249
+
250
+ mkdir 'from_directory'
251
+ touch 'from_directory/move_me.txt'
252
+ mkdir 'to_directory'
253
+
254
+ watch(listener, path) do
255
+ mv 'from_directory/move_me.txt', 'to_directory/move_me.txt'
256
+ end
257
+ end
258
+ end
259
+ end
260
+ end
261
+
262
+ context 'when a file is deleted' do
263
+ it 'detects the file removal' do
264
+ fixtures do |path|
265
+ if options[:recursive]
266
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
267
+ else
268
+ listener.should_receive(:on_change).once.with([path], {})
269
+ end
270
+
271
+ touch 'unnecessary.txt'
272
+
273
+ watch(listener, path) do
274
+ rm 'unnecessary.txt'
275
+ end
276
+ end
277
+ end
278
+
279
+ context 'given an existing directory' do
280
+ it 'detects the file removal' do
281
+ fixtures do |path|
282
+ if options[:recursive]
283
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
284
+ else
285
+ listener.should_receive(:on_change).once.with(["#{path}/a_directory"], {})
286
+ end
287
+
288
+ mkdir 'a_directory'
289
+ touch 'a_directory/do_not_use.rb'
290
+
291
+ watch(listener, path) do
292
+ rm 'a_directory/do_not_use.rb'
293
+ end
294
+ end
295
+ end
296
+ end
297
+ end
298
+ end
299
+
300
+ context 'multiple file operations' do
301
+ it 'detects the added files' do
302
+ fixtures do |path|
303
+ if options[:recursive]
304
+ listener.should_receive(:on_change).at_least(:once).with([path], :recursive => true)
305
+ else
306
+ listener.should_receive(:on_change).once.with do |array, options|
307
+ array.should =~ [path, "#{path}/a_directory"]
308
+ end
309
+ end
310
+
311
+ watch(listener, path) do
312
+ touch 'a_file.rb'
313
+ touch 'b_file.rb'
314
+ mkdir 'a_directory'
315
+ # Needed for INotify, because of :recursive rb-inotify custom flag?
316
+ # Also needed for the osx adapter
317
+ sleep 0.05
318
+ touch 'a_directory/a_file.rb'
319
+ touch 'a_directory/b_file.rb'
320
+ end
321
+ end
322
+ end
323
+
324
+ it 'detects the modified files' do
325
+ fixtures do |path|
326
+ if options[:recursive]
327
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
328
+ else
329
+ listener.should_receive(:on_change).once.with do |array, options|
330
+ array.should =~ [path, "#{path}/a_directory"]
331
+ end
332
+ end
333
+
334
+ touch 'a_file.rb'
335
+ touch 'b_file.rb'
336
+ mkdir 'a_directory'
337
+ touch 'a_directory/a_file.rb'
338
+ touch 'a_directory/b_file.rb'
339
+
340
+ watch(listener, path) do
341
+ touch 'b_file.rb'
342
+ touch 'a_directory/a_file.rb'
343
+ end
344
+ end
345
+ end
346
+
347
+ it 'detects the removed files' do
348
+ fixtures do |path|
349
+ if options[:recursive]
350
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
351
+ else
352
+ listener.should_receive(:on_change).once.with do |array, options|
353
+ array.should =~ [path, "#{path}/a_directory"]
354
+ end
355
+ end
356
+
357
+ touch 'a_file.rb'
358
+ touch 'b_file.rb'
359
+ mkdir 'a_directory'
360
+ touch 'a_directory/a_file.rb'
361
+ touch 'a_directory/b_file.rb'
362
+
363
+ watch(listener, path) do
364
+ rm 'b_file.rb'
365
+ rm 'a_directory/a_file.rb'
366
+ end
367
+ end
368
+ end
369
+ end
370
+
371
+ context 'single directory operations' do
372
+ it 'detects a moved directory' do
373
+ fixtures do |path|
374
+ if options[:recursive]
375
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
376
+ else
377
+ listener.should_receive(:on_change).once.with([path], {})
378
+ end
379
+
380
+ mkdir 'a_directory'
381
+ touch 'a_directory/a_file.rb'
382
+ touch 'a_directory/b_file.rb'
383
+
384
+ watch(listener, path) do
385
+ mv 'a_directory', 'renamed'
386
+ end
387
+ end
388
+ end
389
+
390
+ it 'detects a removed directory' do
391
+ fixtures do |path|
392
+ if options[:recursive]
393
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
394
+ else
395
+ listener.should_receive(:on_change).once.with do |array, options|
396
+ array.should =~ [path, "#{path}/a_directory"]
397
+ end
398
+ end
399
+
400
+ mkdir 'a_directory'
401
+ touch 'a_directory/a_file.rb'
402
+ touch 'a_directory/b_file.rb'
403
+
404
+ watch(listener, path) do
405
+ rm_rf 'a_directory'
406
+ end
407
+ end
408
+ end
409
+ end
410
+
411
+ context "paused adapter" do
412
+ context 'when a file is created' do
413
+ it "doesn't detects the added file" do
414
+ fixtures do |path|
415
+ watch(listener, path) do
416
+ @adapter.paused = true
417
+ touch 'new_file.rb'
418
+ end
419
+ @called.should be_nil
420
+ end
421
+ end
422
+ end
423
+ end
424
+
425
+ context "when multiple directories are listened to" do
426
+ context 'when files are added to one of multiple directories' do
427
+ it 'detects added files' do
428
+ fixtures(2) do |path1, path2|
429
+ if options[:recursive]
430
+ listener.should_receive(:on_change).once.with([path2], :recursive => true)
431
+ else
432
+ listener.should_receive(:on_change).once.with([path2], {})
433
+ end
434
+
435
+ watch(listener, path1, path2) do
436
+ touch "#{path2}/new_file.rb"
437
+ end
438
+ end
439
+ end
440
+ end
441
+
442
+ context 'when files are added to multiple directories' do
443
+ it 'detects added files' do
444
+ fixtures(2) do |path1, path2|
445
+ if options[:recursive]
446
+ listener.should_receive(:on_change).once.with do |directories, options|
447
+ directories.should =~ [path1, path2] && options.should == {:recursive => true}
448
+ end
449
+ else
450
+ listener.should_receive(:on_change).once.with do |directories, options|
451
+ directories.should =~ [path1, path2] && options.should == {}
452
+ end
453
+ end
454
+
455
+ watch(listener, path1, path2) do
456
+ touch "#{path1}/new_file.rb"
457
+ touch "#{path2}/new_file.rb"
458
+ end
459
+ end
460
+ end
461
+ end
462
+
463
+ context 'given a new and an existing directory on multiple directories' do
464
+ it 'detects the added file' do
465
+ fixtures(2) do |path1, path2|
466
+ if options[:recursive]
467
+ listener.should_receive(:on_change).once.with do |directories, options|
468
+ directories.should =~ [path1, path2] && options.should == {:recursive => true}
469
+ end
470
+ else
471
+ listener.should_receive(:on_change).once.with do |directories, options|
472
+ directories.should =~ [path2, "#{path2}/b_directory", "#{path1}/a_directory"] && options.should == {}
473
+ end
474
+ end
475
+
476
+ mkdir "#{path1}/a_directory"
477
+
478
+ watch(listener, path1, path2) do
479
+ mkdir "#{path2}/b_directory"
480
+ sleep 0.05
481
+ touch "#{path1}/a_directory/new_file.rb"
482
+ touch "#{path2}/b_directory/new_file.rb"
483
+ end
484
+ end
485
+ end
486
+ end
487
+
488
+ context 'when a file is moved between the multiple watched directories' do
489
+ it 'detects the movements of the file' do
490
+ fixtures(3) do |path1, path2, path3|
491
+ if options[:recursive]
492
+ listener.should_receive(:on_change).once.with do |directories, options|
493
+ directories.should =~ [path1, path2, path3] && options.should == {:recursive => true}
494
+ end
495
+ else
496
+ listener.should_receive(:on_change).once.with do |directories, options|
497
+ directories.should =~ ["#{path1}/from_directory", path2, "#{path3}/to_directory"] && options.should == {}
498
+ end
499
+ end
500
+
501
+ mkdir "#{path1}/from_directory"
502
+ touch "#{path1}/from_directory/move_me.txt"
503
+ mkdir "#{path3}/to_directory"
504
+
505
+ watch(listener, path1, path2, path3) do
506
+ mv "#{path1}/from_directory/move_me.txt", "#{path2}/move_me.txt"
507
+ mv "#{path2}/move_me.txt", "#{path3}/to_directory/move_me.txt"
508
+ end
509
+ end
510
+ end
511
+ end
512
+
513
+ context 'when files are deleted from the multiple watched directories' do
514
+ it 'detects the files removal' do
515
+ fixtures(2) do |path1, path2|
516
+ if options[:recursive]
517
+ listener.should_receive(:on_change).once.with do |directories, options|
518
+ directories.should =~ [path1, path2] && options.should == {:recursive => true}
519
+ end
520
+ else
521
+ listener.should_receive(:on_change).once.with do |directories, options|
522
+ directories.should =~ [path1, path2] && options.should == {}
523
+ end
524
+ end
525
+
526
+ touch "#{path1}/unnecessary.txt"
527
+ touch "#{path2}/unnecessary.txt"
528
+
529
+ watch(listener, path1, path2) do
530
+ rm "#{path1}/unnecessary.txt"
531
+ rm "#{path2}/unnecessary.txt"
532
+ end
533
+ end
534
+ end
535
+ end
536
+ end
537
+
538
+ end