sass 3.1.16 → 3.1.17
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.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/sass/exec.rb +2 -2
- data/lib/sass/plugin/compiler.rb +51 -43
- data/lib/sass/script/color.rb +4 -9
- data/lib/sass/script/functions.rb +14 -28
- data/lib/sass/scss/parser.rb +1 -5
- data/lib/sass/tree/node.rb +8 -0
- data/lib/sass/tree/visitors/convert.rb +1 -0
- data/lib/sass/util.rb +28 -0
- data/test/sass/conversion_test.rb +26 -0
- data/test/sass/functions_test.rb +28 -22
- data/test/sass/script_test.rb +4 -4
- data/test/sass/scss/scss_test.rb +10 -0
- data/vendor/listen/CHANGELOG.md +19 -1
- data/vendor/listen/README.md +24 -12
- data/vendor/listen/lib/listen/adapters/windows.rb +7 -8
- data/vendor/listen/lib/listen/directory_record.rb +72 -38
- data/vendor/listen/lib/listen/listener.rb +12 -10
- data/vendor/listen/lib/listen/multi_listener.rb +6 -6
- data/vendor/listen/lib/listen/version.rb +1 -1
- data/vendor/listen/spec/listen/directory_record_spec.rb +241 -35
- data/vendor/listen/spec/listen/listener_spec.rb +8 -4
- data/vendor/listen/spec/listen/multi_listener_spec.rb +9 -4
- data/vendor/listen/spec/support/adapter_helper.rb +78 -0
- data/vendor/listen/spec/support/directory_record_helper.rb +13 -5
- metadata +211 -214
- data/lib/sass/plugin/listener.rb +0 -59
@@ -1,21 +1,34 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Listen::DirectoryRecord do
|
4
|
-
let(:base_directory) {
|
4
|
+
let(:base_directory) { File.dirname(__FILE__) }
|
5
5
|
|
6
6
|
subject { described_class.new(base_directory) }
|
7
7
|
|
8
|
+
describe '.generate_default_ignoring_patterns' do
|
9
|
+
it 'creates regexp patterns from the default ignored directories and extensions' do
|
10
|
+
described_class.generate_default_ignoring_patterns.should include(
|
11
|
+
%r{^(?:\.rbx|\.bundle|\.git|\.svn|log|tmp|vendor)/},
|
12
|
+
%r{(?:\.DS_Store)$}
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'memoizes the generated results' do
|
17
|
+
described_class.generate_default_ignoring_patterns.should equal described_class.generate_default_ignoring_patterns
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
8
21
|
describe '#initialize' do
|
9
22
|
it 'sets the base directory' do
|
10
23
|
subject.directory.should eq base_directory
|
11
24
|
end
|
12
25
|
|
13
|
-
it 'sets the default
|
14
|
-
subject.
|
26
|
+
it 'sets the default ignoring patterns' do
|
27
|
+
subject.ignoring_patterns.should =~ described_class.generate_default_ignoring_patterns
|
15
28
|
end
|
16
29
|
|
17
|
-
it 'sets the default
|
18
|
-
subject.
|
30
|
+
it 'sets the default filtering patterns' do
|
31
|
+
subject.filtering_patterns.should eq []
|
19
32
|
end
|
20
33
|
|
21
34
|
it 'raises an error when the passed path does not exist' do
|
@@ -29,39 +42,76 @@ describe Listen::DirectoryRecord do
|
|
29
42
|
|
30
43
|
describe '#ignore' do
|
31
44
|
it 'adds the passed paths to the list of ignoted paths in the record' do
|
32
|
-
subject.ignore(
|
33
|
-
subject.
|
45
|
+
subject.ignore(%r{^\.old/}, %r{\.pid$})
|
46
|
+
subject.ignoring_patterns.should include(%r{^\.old/}, %r{\.pid$})
|
34
47
|
end
|
35
48
|
end
|
36
49
|
|
37
50
|
describe '#filter' do
|
38
51
|
it 'adds the passed regexps to the list of filters that determine the stored paths' do
|
39
52
|
subject.filter(%r{\.(?:jpe?g|gif|png)}, %r{\.(?:mp3|ogg|a3c)})
|
40
|
-
subject.
|
53
|
+
subject.filtering_patterns.should include(%r{\.(?:jpe?g|gif|png)}, %r{\.(?:mp3|ogg|a3c)})
|
41
54
|
end
|
42
55
|
end
|
43
56
|
|
44
57
|
describe '#ignored?' do
|
58
|
+
before { subject.stub(:relative_to_base) { |path| path } }
|
59
|
+
|
60
|
+
it 'tests paths relative to the base directory' do
|
61
|
+
subject.should_receive(:relative_to_base).with('file.txt')
|
62
|
+
subject.ignored?('file.txt')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'returns true when the passed path is a default ignored path' do
|
66
|
+
subject.ignored?('tmp/some_process.pid').should be_true
|
67
|
+
subject.ignored?('dir/.DS_Store').should be_true
|
68
|
+
subject.ignored?('.git/config').should be_true
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns false when the passed path is not a default ignored path' do
|
72
|
+
subject.ignored?('nested/tmp/some_process.pid').should be_false
|
73
|
+
subject.ignored?('nested/.git').should be_false
|
74
|
+
subject.ignored?('dir/.DS_Store/file').should be_false
|
75
|
+
subject.ignored?('file.git').should be_false
|
76
|
+
end
|
77
|
+
|
45
78
|
it 'returns true when the passed path is ignored' do
|
46
|
-
subject.ignore(
|
47
|
-
subject.ignored?('/
|
79
|
+
subject.ignore(%r{\.pid$})
|
80
|
+
subject.ignored?('dir/some_process.pid').should be_true
|
48
81
|
end
|
49
82
|
|
50
83
|
it 'returns false when the passed path is not ignored' do
|
51
|
-
subject.ignore(
|
52
|
-
subject.ignored?('/
|
84
|
+
subject.ignore(%r{\.pid$})
|
85
|
+
subject.ignored?('dir/some_file.txt').should be_false
|
53
86
|
end
|
54
87
|
end
|
55
88
|
|
56
|
-
describe '#
|
57
|
-
|
58
|
-
|
59
|
-
|
89
|
+
describe '#filtered?' do
|
90
|
+
before { subject.stub(:relative_to_base) { |path| path } }
|
91
|
+
|
92
|
+
context 'when no filtering patterns are set' do
|
93
|
+
it 'returns true for any path' do
|
94
|
+
subject.filtered?('file.txt').should be_true
|
95
|
+
end
|
60
96
|
end
|
61
97
|
|
62
|
-
|
63
|
-
subject.filter(%r{\.(?:jpe?g|gif|png)})
|
64
|
-
|
98
|
+
context 'when filtering patterns are set' do
|
99
|
+
before { subject.filter(%r{\.(?:jpe?g|gif|png)}) }
|
100
|
+
|
101
|
+
it 'tests paths relative to the base directory' do
|
102
|
+
subject.should_receive(:relative_to_base).with('file.txt')
|
103
|
+
subject.filtered?('file.txt')
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'returns true when the passed path is filtered' do
|
107
|
+
subject.filter(%r{\.(?:jpe?g|gif|png)})
|
108
|
+
subject.filtered?('dir/picture.jpeg').should be_true
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'returns false when the passed path is not filtered' do
|
112
|
+
subject.filter(%r{\.(?:jpe?g|gif|png)})
|
113
|
+
subject.filtered?('dir/song.mp3').should be_false
|
114
|
+
end
|
65
115
|
end
|
66
116
|
end
|
67
117
|
|
@@ -89,7 +139,7 @@ describe Listen::DirectoryRecord do
|
|
89
139
|
touch 'ignored_directory/file.txt'
|
90
140
|
|
91
141
|
record = described_class.new(path)
|
92
|
-
record.ignore
|
142
|
+
record.ignore %r{^ignored_directory/}
|
93
143
|
record.build
|
94
144
|
|
95
145
|
record.paths[path]['/a_ignored_directory'].should be_nil
|
@@ -103,7 +153,7 @@ describe Listen::DirectoryRecord do
|
|
103
153
|
touch 'ignored_file.rb'
|
104
154
|
|
105
155
|
record = described_class.new(path)
|
106
|
-
record.ignore
|
156
|
+
record.ignore %r{^ignored_file.rb$}
|
107
157
|
record.build
|
108
158
|
|
109
159
|
record.paths[path]['ignored_file.rb'].should be_nil
|
@@ -134,6 +184,17 @@ describe Listen::DirectoryRecord do
|
|
134
184
|
end
|
135
185
|
end
|
136
186
|
|
187
|
+
describe '#relative_to_base' do
|
188
|
+
it 'removes the path of the base-directory from the passed path' do
|
189
|
+
path = 'dir/to/app/file.rb'
|
190
|
+
subject.relative_to_base(File.join(base_directory, path)).should eq path
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'returns nil when the passed path is not inside the base-directory' do
|
194
|
+
subject.relative_to_base('/tmp/some_random_path').should be_nil
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
137
198
|
describe '#fetch_changes' do
|
138
199
|
context 'with single file changes' do
|
139
200
|
context 'when a file is created' do
|
@@ -211,7 +272,7 @@ describe Listen::DirectoryRecord do
|
|
211
272
|
fixtures do |path|
|
212
273
|
mkdir 'ignored_directory'
|
213
274
|
|
214
|
-
modified, added, removed = changes(path, :ignore =>
|
275
|
+
modified, added, removed = changes(path, :ignore => %r{^ignored_directory/}, :recursive => true) do
|
215
276
|
touch 'ignored_directory/new_file.rb'
|
216
277
|
end
|
217
278
|
|
@@ -225,7 +286,7 @@ describe Listen::DirectoryRecord do
|
|
225
286
|
fixtures do |path|
|
226
287
|
mkdir 'ignored_directory'
|
227
288
|
|
228
|
-
modified, added, removed = changes(path, :paths => ["#{path}/ignored_directory"], :ignore =>
|
289
|
+
modified, added, removed = changes(path, :paths => ["#{path}/ignored_directory"], :ignore => %r{^ignored_directory/}, :recursive => true) do
|
229
290
|
touch 'ignored_directory/new_file.rb'
|
230
291
|
end
|
231
292
|
|
@@ -253,6 +314,39 @@ describe Listen::DirectoryRecord do
|
|
253
314
|
end
|
254
315
|
end
|
255
316
|
end
|
317
|
+
|
318
|
+
context 'given a directory with subdirectories' do
|
319
|
+
it 'detects the added file' do
|
320
|
+
fixtures do |path|
|
321
|
+
mkdir_p 'a_directory/subdirectory'
|
322
|
+
|
323
|
+
modified, added, removed = changes(path, :recursive => true) do
|
324
|
+
touch 'a_directory/subdirectory/new_file.rb'
|
325
|
+
end
|
326
|
+
|
327
|
+
added.should =~ %w(a_directory/subdirectory/new_file.rb)
|
328
|
+
modified.should be_empty
|
329
|
+
removed.should be_empty
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
context 'with an ignored directory' do
|
334
|
+
it "doesn't detect added files in neither the directory nor the subdirectory" do
|
335
|
+
fixtures do |path|
|
336
|
+
mkdir_p 'ignored_directory/subdirectory'
|
337
|
+
|
338
|
+
modified, added, removed = changes(path, :ignore => %r{^ignored_directory/}, :recursive => true) do
|
339
|
+
touch 'ignored_directory/new_file.rb'
|
340
|
+
touch 'ignored_directory/subdirectory/new_file.rb'
|
341
|
+
end
|
342
|
+
|
343
|
+
added.should be_empty
|
344
|
+
modified.should be_empty
|
345
|
+
removed.should be_empty
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
256
350
|
end
|
257
351
|
|
258
352
|
context 'when a file is modified' do
|
@@ -261,7 +355,7 @@ describe Listen::DirectoryRecord do
|
|
261
355
|
touch 'existing_file.txt'
|
262
356
|
|
263
357
|
modified, added, removed = changes(path) do
|
264
|
-
sleep 1.5 # make a
|
358
|
+
sleep 1.5 # make a difference in the mtime of the file
|
265
359
|
touch 'existing_file.txt'
|
266
360
|
end
|
267
361
|
|
@@ -272,13 +366,12 @@ describe Listen::DirectoryRecord do
|
|
272
366
|
end
|
273
367
|
|
274
368
|
context 'during the same second' do
|
275
|
-
before { ensure_same_second }
|
276
|
-
|
277
369
|
it 'always detects the modified file the first time' do
|
278
370
|
fixtures do |path|
|
279
371
|
touch 'existing_file.txt'
|
280
372
|
|
281
373
|
modified, added, removed = changes(path) do
|
374
|
+
small_time_difference
|
282
375
|
touch 'existing_file.txt'
|
283
376
|
end
|
284
377
|
|
@@ -306,7 +399,7 @@ describe Listen::DirectoryRecord do
|
|
306
399
|
end
|
307
400
|
end
|
308
401
|
|
309
|
-
it
|
402
|
+
it 'detects the modified file the second time if the content have changed' do
|
310
403
|
fixtures do |path|
|
311
404
|
touch 'existing_file.txt'
|
312
405
|
|
@@ -315,6 +408,7 @@ describe Listen::DirectoryRecord do
|
|
315
408
|
end
|
316
409
|
|
317
410
|
modified, added, removed = changes(path, :use_last_record => true) do
|
411
|
+
small_time_difference
|
318
412
|
open('existing_file.txt', 'w') { |f| f.write('foo') }
|
319
413
|
end
|
320
414
|
|
@@ -331,6 +425,7 @@ describe Listen::DirectoryRecord do
|
|
331
425
|
touch '.hidden'
|
332
426
|
|
333
427
|
modified, added, removed = changes(path) do
|
428
|
+
small_time_difference
|
334
429
|
touch '.hidden'
|
335
430
|
end
|
336
431
|
|
@@ -345,7 +440,7 @@ describe Listen::DirectoryRecord do
|
|
345
440
|
it 'does not detect the mode change' do
|
346
441
|
fixtures do |path|
|
347
442
|
touch 'run.rb'
|
348
|
-
sleep 1.5 # make a
|
443
|
+
sleep 1.5 # make a difference in the mtime of the file
|
349
444
|
|
350
445
|
modified, added, removed = changes(path) do
|
351
446
|
chmod 0777, 'run.rb'
|
@@ -366,6 +461,7 @@ describe Listen::DirectoryRecord do
|
|
366
461
|
touch 'a_directory/existing_file.txt'
|
367
462
|
|
368
463
|
modified, added, removed = changes(path, :recursive => true) do
|
464
|
+
small_time_difference
|
369
465
|
touch 'a_directory/existing_file.txt'
|
370
466
|
end
|
371
467
|
|
@@ -383,6 +479,7 @@ describe Listen::DirectoryRecord do
|
|
383
479
|
touch 'a_directory/existing_file.txt'
|
384
480
|
|
385
481
|
modified, added, removed = changes(path, :recursive => false) do
|
482
|
+
small_time_difference
|
386
483
|
touch 'a_directory/existing_file.txt'
|
387
484
|
end
|
388
485
|
|
@@ -393,6 +490,43 @@ describe Listen::DirectoryRecord do
|
|
393
490
|
end
|
394
491
|
end
|
395
492
|
end
|
493
|
+
|
494
|
+
context 'given a directory with subdirectories' do
|
495
|
+
it 'detects the modified file' do
|
496
|
+
fixtures do |path|
|
497
|
+
mkdir_p 'a_directory/subdirectory'
|
498
|
+
touch 'a_directory/subdirectory/existing_file.txt'
|
499
|
+
|
500
|
+
modified, added, removed = changes(path, :recursive => true) do
|
501
|
+
small_time_difference
|
502
|
+
touch 'a_directory/subdirectory/existing_file.txt'
|
503
|
+
end
|
504
|
+
|
505
|
+
added.should be_empty
|
506
|
+
modified.should =~ %w(a_directory/subdirectory/existing_file.txt)
|
507
|
+
removed.should be_empty
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
context 'with an ignored subdirectory' do
|
512
|
+
it "doesn't detect the modified files in neither the directory nor the subdirectory" do
|
513
|
+
fixtures do |path|
|
514
|
+
mkdir_p 'ignored_directory/subdirectory'
|
515
|
+
touch 'ignored_directory/existing_file.txt'
|
516
|
+
touch 'ignored_directory/subdirectory/existing_file.txt'
|
517
|
+
|
518
|
+
modified, added, removed = changes(path, :ignore => %r{^ignored_directory/}, :recursive => true) do
|
519
|
+
touch 'ignored_directory/existing_file.txt'
|
520
|
+
touch 'ignored_directory/subdirectory/existing_file.txt'
|
521
|
+
end
|
522
|
+
|
523
|
+
added.should be_empty
|
524
|
+
modified.should be_empty
|
525
|
+
removed.should be_empty
|
526
|
+
end
|
527
|
+
end
|
528
|
+
end
|
529
|
+
end
|
396
530
|
end
|
397
531
|
|
398
532
|
context 'when a file is moved' do
|
@@ -506,7 +640,43 @@ describe Listen::DirectoryRecord do
|
|
506
640
|
end
|
507
641
|
end
|
508
642
|
|
509
|
-
context '
|
643
|
+
context 'given a directory with subdirectories' do
|
644
|
+
it 'detects a file movement between two subdirectories' do
|
645
|
+
fixtures do |path|
|
646
|
+
mkdir_p 'a_directory/subdirectory'
|
647
|
+
mkdir_p 'b_directory/subdirectory'
|
648
|
+
touch 'a_directory/subdirectory/move_me.txt'
|
649
|
+
|
650
|
+
modified, added, removed = changes(path, :recursive => true) do
|
651
|
+
mv 'a_directory/subdirectory/move_me.txt', 'b_directory/subdirectory'
|
652
|
+
end
|
653
|
+
|
654
|
+
added.should =~ %w(b_directory/subdirectory/move_me.txt)
|
655
|
+
modified.should be_empty
|
656
|
+
removed.should =~ %w(a_directory/subdirectory/move_me.txt)
|
657
|
+
end
|
658
|
+
end
|
659
|
+
|
660
|
+
context 'with an ignored subdirectory' do
|
661
|
+
it "doesn't detect the file movement between subdirectories" do
|
662
|
+
fixtures do |path|
|
663
|
+
mkdir_p 'a_ignored_directory/subdirectory'
|
664
|
+
mkdir_p 'b_ignored_directory/subdirectory'
|
665
|
+
touch 'a_ignored_directory/subdirectory/move_me.txt'
|
666
|
+
|
667
|
+
modified, added, removed = changes(path, :ignore => %r{^(?:a|b)_ignored_directory/}, :recursive => true) do
|
668
|
+
mv 'a_ignored_directory/subdirectory/move_me.txt', 'b_ignored_directory/subdirectory'
|
669
|
+
end
|
670
|
+
|
671
|
+
added.should be_empty
|
672
|
+
modified.should be_empty
|
673
|
+
removed.should be_empty
|
674
|
+
end
|
675
|
+
end
|
676
|
+
end
|
677
|
+
end
|
678
|
+
|
679
|
+
context 'with all paths passed as params' do
|
510
680
|
it 'detects the file movement into the directory' do
|
511
681
|
fixtures do |path|
|
512
682
|
mkdir 'a_directory'
|
@@ -635,6 +805,42 @@ describe Listen::DirectoryRecord do
|
|
635
805
|
end
|
636
806
|
end
|
637
807
|
end
|
808
|
+
|
809
|
+
context 'given a directory with subdirectories' do
|
810
|
+
it 'detects the file removal in subdirectories' do
|
811
|
+
fixtures do |path|
|
812
|
+
mkdir_p 'a_directory/subdirectory'
|
813
|
+
touch 'a_directory/subdirectory/do_not_use.rb'
|
814
|
+
|
815
|
+
modified, added, removed = changes(path, :recursive => true) do
|
816
|
+
rm 'a_directory/subdirectory/do_not_use.rb'
|
817
|
+
end
|
818
|
+
|
819
|
+
added.should be_empty
|
820
|
+
modified.should be_empty
|
821
|
+
removed.should =~ %w(a_directory/subdirectory/do_not_use.rb)
|
822
|
+
end
|
823
|
+
end
|
824
|
+
|
825
|
+
context 'with an ignored subdirectory' do
|
826
|
+
it "doesn't detect files removals in neither the directory nor its subdirectories" do
|
827
|
+
fixtures do |path|
|
828
|
+
mkdir_p 'ignored_directory/subdirectory'
|
829
|
+
touch 'ignored_directory/do_not_use.rb'
|
830
|
+
touch 'ignored_directory/subdirectory/do_not_use.rb'
|
831
|
+
|
832
|
+
modified, added, removed = changes(path, :ignore => %r{^ignored_directory/}, :recursive => true) do
|
833
|
+
rm 'ignored_directory/do_not_use.rb'
|
834
|
+
rm 'ignored_directory/subdirectory/do_not_use.rb'
|
835
|
+
end
|
836
|
+
|
837
|
+
added.should be_empty
|
838
|
+
modified.should be_empty
|
839
|
+
removed.should be_empty
|
840
|
+
end
|
841
|
+
end
|
842
|
+
end
|
843
|
+
end
|
638
844
|
end
|
639
845
|
end
|
640
846
|
|
@@ -662,9 +868,9 @@ describe Listen::DirectoryRecord do
|
|
662
868
|
mkdir 'a_directory'
|
663
869
|
touch 'a_directory/a_file.rb'
|
664
870
|
touch 'a_directory/b_file.rb'
|
665
|
-
sleep 1.5 # make files mtime old
|
666
871
|
|
667
872
|
modified, added, removed = changes(path) do
|
873
|
+
small_time_difference
|
668
874
|
touch 'b_file.rb'
|
669
875
|
touch 'a_directory/a_file.rb'
|
670
876
|
end
|
@@ -682,7 +888,6 @@ describe Listen::DirectoryRecord do
|
|
682
888
|
mkdir 'a_directory'
|
683
889
|
touch 'a_directory/a_file.rb'
|
684
890
|
touch 'a_directory/b_file.rb'
|
685
|
-
sleep 1.5 # make files mtime old
|
686
891
|
|
687
892
|
modified, added, removed = changes(path) do
|
688
893
|
rm 'b_file.rb'
|
@@ -751,16 +956,16 @@ describe Listen::DirectoryRecord do
|
|
751
956
|
context 'with nested paths' do
|
752
957
|
it 'detects removals without crashing - #18' do
|
753
958
|
fixtures do |path|
|
754
|
-
mkdir_p 'a_directory/
|
755
|
-
touch
|
959
|
+
mkdir_p 'a_directory/subdirectory'
|
960
|
+
touch 'a_directory/subdirectory/do_not_use.rb'
|
756
961
|
|
757
|
-
modified, added, removed = changes(path
|
962
|
+
modified, added, removed = changes(path) do
|
758
963
|
rm_r 'a_directory'
|
759
964
|
end
|
760
965
|
|
761
966
|
added.should be_empty
|
762
967
|
modified.should be_empty
|
763
|
-
removed.should =~ %w(a_directory/
|
968
|
+
removed.should =~ %w(a_directory/subdirectory/do_not_use.rb)
|
764
969
|
end
|
765
970
|
end
|
766
971
|
end
|
@@ -790,6 +995,7 @@ describe Listen::DirectoryRecord do
|
|
790
995
|
touch 'b_file.rb'
|
791
996
|
|
792
997
|
modified, added, removed = changes(path, :relative_paths => false) do
|
998
|
+
small_time_difference
|
793
999
|
rm 'a_file.rb'
|
794
1000
|
touch 'b_file.rb'
|
795
1001
|
touch 'c_file.rb'
|