sass 3.2.0.alpha.104 → 3.2.0.alpha.236

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/REVISION +1 -1
  2. data/Rakefile +2 -2
  3. data/VERSION +1 -1
  4. data/lib/sass/engine.rb +8 -1
  5. data/lib/sass/exec.rb +2 -2
  6. data/lib/sass/plugin/compiler.rb +51 -43
  7. data/lib/sass/script/color.rb +4 -9
  8. data/lib/sass/script/funcall.rb +11 -2
  9. data/lib/sass/script/functions.rb +16 -30
  10. data/lib/sass/script/lexer.rb +7 -1
  11. data/lib/sass/script/list.rb +2 -2
  12. data/lib/sass/script/literal.rb +8 -0
  13. data/lib/sass/script/null.rb +34 -0
  14. data/lib/sass/script/operation.rb +4 -0
  15. data/lib/sass/script/parser.rb +4 -2
  16. data/lib/sass/scss/parser.rb +1 -5
  17. data/lib/sass/scss/rx.rb +1 -1
  18. data/lib/sass/tree/directive_node.rb +5 -0
  19. data/lib/sass/tree/media_node.rb +3 -0
  20. data/lib/sass/tree/prop_node.rb +7 -3
  21. data/lib/sass/tree/visitors/base.rb +1 -1
  22. data/lib/sass/tree/visitors/check_nesting.rb +21 -18
  23. data/lib/sass/tree/visitors/convert.rb +1 -0
  24. data/lib/sass/tree/visitors/perform.rb +3 -2
  25. data/lib/sass/tree/visitors/to_css.rb +1 -0
  26. data/lib/sass/util.rb +28 -0
  27. data/test/sass/conversion_test.rb +33 -0
  28. data/test/sass/engine_test.rb +118 -3
  29. data/test/sass/functions_test.rb +56 -24
  30. data/test/sass/script_test.rb +60 -4
  31. data/test/sass/scss/scss_test.rb +10 -0
  32. data/vendor/listen/CHANGELOG.md +19 -1
  33. data/vendor/listen/README.md +27 -12
  34. data/vendor/listen/lib/listen/adapter.rb +9 -1
  35. data/vendor/listen/lib/listen/adapters/linux.rb +18 -7
  36. data/vendor/listen/lib/listen/adapters/windows.rb +7 -8
  37. data/vendor/listen/lib/listen/directory_record.rb +108 -48
  38. data/vendor/listen/lib/listen/listener.rb +28 -11
  39. data/vendor/listen/lib/listen/multi_listener.rb +6 -6
  40. data/vendor/listen/lib/listen/version.rb +1 -1
  41. data/vendor/listen/spec/listen/adapters/linux_spec.rb +11 -0
  42. data/vendor/listen/spec/listen/directory_record_spec.rb +268 -41
  43. data/vendor/listen/spec/listen/listener_spec.rb +8 -4
  44. data/vendor/listen/spec/listen/multi_listener_spec.rb +9 -4
  45. data/vendor/listen/spec/support/adapter_helper.rb +178 -0
  46. data/vendor/listen/spec/support/directory_record_helper.rb +24 -4
  47. data/vendor/listen/spec/support/listeners_helper.rb +11 -0
  48. metadata +11 -11
  49. data/lib/sass/plugin/listener.rb +0 -61
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Listen::Listener do
4
4
  let(:adapter) { mock(Listen::Adapter, :start => true).as_null_object }
5
- let(:watched_directory) { Dir.tmpdir }
5
+ let(:watched_directory) { File.dirname(__FILE__) }
6
6
 
7
7
  subject { described_class.new(watched_directory) }
8
8
 
@@ -20,21 +20,25 @@ describe Listen::Listener do
20
20
  subject.directory.should eq watched_directory
21
21
  end
22
22
 
23
+ it 'converts the passed path into an absolute path - #21' do
24
+ described_class.new(File.join(watched_directory, '..')).directory.should eq File.expand_path('..', watched_directory)
25
+ end
26
+
23
27
  it 'sets the option for using relative paths in the callback to the default one' do
24
28
  subject.instance_variable_get(:@use_relative_paths).should eq described_class::DEFAULT_TO_RELATIVE_PATHS
25
29
  end
26
30
  end
27
31
 
28
32
  context 'with custom options' do
29
- subject { described_class.new(watched_directory, :ignore => '.ssh', :filter => [/.*\.rb/,/.*\.md/],
33
+ subject { described_class.new(watched_directory, :ignore => /\.ssh/, :filter => [/.*\.rb/,/.*\.md/],
30
34
  :latency => 0.5, :force_polling => true, :relative_paths => true) }
31
35
 
32
36
  it 'passes the custom ignored paths to the directory record' do
33
- subject.directory_record.ignored_paths.should =~ %w[.bundle .git .DS_Store log tmp vendor .ssh]
37
+ subject.directory_record.ignoring_patterns.should include /\.ssh/
34
38
  end
35
39
 
36
40
  it 'passes the custom filters to the directory record' do
37
- subject.directory_record.filters.should =~ [/.*\.rb/,/.*\.md/]
41
+ subject.directory_record.filtering_patterns.should =~ [/.*\.rb/,/.*\.md/]
38
42
  end
39
43
 
40
44
  it 'sets the cutom option for using relative paths in the callback' do
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Listen::MultiListener do
4
4
  let(:adapter) { mock(Listen::Adapter, :start => true).as_null_object }
5
- let(:watched_directories) { [File.dirname(__FILE__), Dir.tmpdir] }
5
+ let(:watched_directories) { [File.dirname(__FILE__), File.expand_path('../..', __FILE__)] }
6
6
 
7
7
  subject { described_class.new(*watched_directories) }
8
8
 
@@ -19,23 +19,28 @@ describe Listen::MultiListener do
19
19
  it 'sets the directories' do
20
20
  subject.directories.should =~ watched_directories
21
21
  end
22
+
23
+ it 'converts the passed paths into absolute paths - #21' do
24
+ paths = watched_directories.map { |d| File.join(d, '..') }
25
+ described_class.new(*paths).directories.should =~ watched_directories.map{ |d| File.expand_path('..', d) }
26
+ end
22
27
  end
23
28
 
24
29
  context 'with custom options' do
25
30
  subject do
26
- args = watched_directories << {:ignore => '.ssh', :filter => [/.*\.rb/,/.*\.md/], :latency => 0.5, :force_polling => true}
31
+ args = watched_directories << {:ignore => /\.ssh/, :filter => [/.*\.rb/,/.*\.md/], :latency => 0.5, :force_polling => true}
27
32
  described_class.new(*args)
28
33
  end
29
34
 
30
35
  it 'passes the custom ignored paths to each directory record' do
31
36
  subject.directories_records.each do |r|
32
- r.ignored_paths.should =~ %w[.bundle .git .DS_Store log tmp vendor .ssh]
37
+ r.ignoring_patterns.should include /\.ssh/
33
38
  end
34
39
  end
35
40
 
36
41
  it 'passes the custom filters to each directory record' do
37
42
  subject.directories_records.each do |r|
38
- r.filters.should =~ [/.*\.rb/,/.*\.md/]
43
+ r.filtering_patterns.should =~ [/.*\.rb/,/.*\.md/]
39
44
  end
40
45
  end
41
46
 
@@ -43,6 +43,31 @@ shared_examples_for 'a filesystem adapter' do
43
43
  end
44
44
  end
45
45
  end
46
+
47
+ describe '#started?' do
48
+ context 'with a new adapter' do
49
+ it 'returns false' do
50
+ subject.should_not be_started
51
+ end
52
+ end
53
+
54
+ context 'with a stopped adapter' do
55
+ before { subject.start(false); subject.stop }
56
+
57
+ it 'returns false' do
58
+ subject.should_not be_started
59
+ end
60
+ end
61
+
62
+ context 'with a started adapter' do
63
+ before { subject.start(false) }
64
+ after { subject.start }
65
+
66
+ it 'returns true' do
67
+ subject.should be_started
68
+ end
69
+ end
70
+ end
46
71
  end
47
72
 
48
73
  shared_examples_for 'an adapter that call properly listener#on_change' do |*args|
@@ -66,6 +91,24 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
66
91
  end
67
92
  end
68
93
 
94
+ context 'given a symlink' do
95
+ it 'detects the added file' do
96
+ fixtures do |path|
97
+ if options[:recursive]
98
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
99
+ else
100
+ listener.should_receive(:on_change).once.with([path], {})
101
+ end
102
+
103
+ touch 'new_file.rb'
104
+
105
+ watch(listener, path) do
106
+ ln_s 'new_file.rb', 'new_file_symlink.rb'
107
+ end
108
+ end
109
+ end
110
+ end
111
+
69
112
  context 'given a new created directory' do
70
113
  it 'detects the added file' do
71
114
  fixtures do |path|
@@ -104,6 +147,24 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
104
147
  end
105
148
  end
106
149
  end
150
+
151
+ context 'given a directory with subdirectories' do
152
+ it 'detects the added file' do
153
+ fixtures do |path|
154
+ if options[:recursive]
155
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
156
+ else
157
+ listener.should_receive(:on_change).once.with(["#{path}/a_directory/subdirectory"], {})
158
+ end
159
+
160
+ mkdir_p 'a_directory/subdirectory'
161
+
162
+ watch(listener, path) do
163
+ touch 'a_directory/subdirectory/new_file.rb'
164
+ end
165
+ end
166
+ end
167
+ end
107
168
  end
108
169
 
109
170
  context 'when a file is modified' do
@@ -123,6 +184,25 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
123
184
  end
124
185
  end
125
186
 
187
+ context 'given a symlink' do
188
+ it 'detects the modified file' do
189
+ fixtures do |path|
190
+ if options[:recursive]
191
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
192
+ else
193
+ listener.should_receive(:on_change).once.with([path], {})
194
+ end
195
+
196
+ touch 'existing_file.rb'
197
+ ln_s 'existing_file.rb', 'existing_file_symlink.rb'
198
+
199
+ watch(listener, path) do
200
+ touch 'existing_file.rb'
201
+ end
202
+ end
203
+ end
204
+ end
205
+
126
206
  context 'given a hidden file' do
127
207
  it 'detects the modified file' do
128
208
  fixtures do |path|
@@ -179,6 +259,25 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
179
259
  end
180
260
  end
181
261
  end
262
+
263
+ context 'given a directory with subdirectories' do
264
+ it 'detects the modified file' do
265
+ fixtures do |path|
266
+ if options[:recursive]
267
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
268
+ else
269
+ listener.should_receive(:on_change).once.with(["#{path}/a_directory/subdirectory"], {})
270
+ end
271
+
272
+ mkdir_p 'a_directory/subdirectory'
273
+ touch 'a_directory/subdirectory/existing_file.txt'
274
+
275
+ watch(listener, path) do
276
+ touch 'a_directory/subdirectory/new_file.rb'
277
+ end
278
+ end
279
+ end
280
+ end
182
281
  end
183
282
 
184
283
  context 'when a file is moved' do
@@ -198,6 +297,25 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
198
297
  end
199
298
  end
200
299
 
300
+ context 'given a symlink' do
301
+ it 'detects the file move' do
302
+ fixtures do |path|
303
+ if options[:recursive]
304
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
305
+ else
306
+ listener.should_receive(:on_change).once.with([path], {})
307
+ end
308
+
309
+ touch 'move_me.rb'
310
+ ln_s 'move_me.rb', 'move_me_symlink.rb'
311
+
312
+ watch(listener, path) do
313
+ mv 'move_me_symlink.rb', 'new_symlink.rb'
314
+ end
315
+ end
316
+ end
317
+ end
318
+
201
319
  context 'given an existing directory' do
202
320
  it 'detects the file move into the directory' do
203
321
  fixtures do |path|
@@ -257,6 +375,28 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
257
375
  end
258
376
  end
259
377
  end
378
+
379
+ context 'given a directory with subdirectories' do
380
+ it 'detects files movements between subdirectories' do
381
+ fixtures do |path|
382
+ if options[:recursive]
383
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
384
+ else
385
+ listener.should_receive(:on_change).once.with do |array, options|
386
+ array.should =~ ["#{path}/a_directory/subdirectory", "#{path}/b_directory/subdirectory"]
387
+ end
388
+ end
389
+
390
+ mkdir_p 'a_directory/subdirectory'
391
+ mkdir_p 'b_directory/subdirectory'
392
+ touch 'a_directory/subdirectory/move_me.txt'
393
+
394
+ watch(listener, path) do
395
+ mv 'a_directory/subdirectory/move_me.txt', 'b_directory/subdirectory'
396
+ end
397
+ end
398
+ end
399
+ end
260
400
  end
261
401
 
262
402
  context 'when a file is deleted' do
@@ -276,6 +416,25 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
276
416
  end
277
417
  end
278
418
 
419
+ context 'given a symlink' do
420
+ it 'detects the file removal' do
421
+ fixtures do |path|
422
+ if options[:recursive]
423
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
424
+ else
425
+ listener.should_receive(:on_change).once.with([path], {})
426
+ end
427
+
428
+ touch 'unnecessary.rb'
429
+ ln_s 'unnecessary.rb', 'unnecessary_symlink.rb'
430
+
431
+ watch(listener, path) do
432
+ rm 'unnecessary_symlink.rb'
433
+ end
434
+ end
435
+ end
436
+ end
437
+
279
438
  context 'given an existing directory' do
280
439
  it 'detects the file removal' do
281
440
  fixtures do |path|
@@ -294,6 +453,25 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
294
453
  end
295
454
  end
296
455
  end
456
+
457
+ context 'given a directory with subdirectories' do
458
+ it 'detects the file removal' do
459
+ fixtures do |path|
460
+ if options[:recursive]
461
+ listener.should_receive(:on_change).once.with([path], :recursive => true)
462
+ else
463
+ listener.should_receive(:on_change).once.with(["#{path}/a_directory/subdirectory"], {})
464
+ end
465
+
466
+ mkdir_p 'a_directory/subdirectory'
467
+ touch 'a_directory/subdirectory/do_not_use.rb'
468
+
469
+ watch(listener, path) do
470
+ rm 'a_directory/subdirectory/do_not_use.rb'
471
+ end
472
+ end
473
+ end
474
+ end
297
475
  end
298
476
  end
299
477
 
@@ -12,12 +12,14 @@
12
12
  def changes(root_path, options = {})
13
13
  unless @record || options[:use_last_record]
14
14
  @record = Listen::DirectoryRecord.new(root_path)
15
- @record.build
16
15
  @record.filter(options.delete(:filter)) if options[:filter]
17
16
  @record.ignore(options.delete(:ignore)) if options[:ignore]
17
+
18
+ # Build the record after adding the filtering and ignoring patterns
19
+ @record.build
18
20
  end
19
21
 
20
- yield
22
+ yield if block_given?
21
23
 
22
24
  paths = options.delete(:paths) || [root_path]
23
25
  options[:recursive] = true if options[:recursive].nil?
@@ -27,9 +29,27 @@ def changes(root_path, options = {})
27
29
  [changes[:modified], changes[:added], changes[:removed]]
28
30
  end
29
31
 
32
+ # Generates a small time difference before performing a time sensitive
33
+ # task (like comparing mtimes of files).
34
+ #
35
+ # @note Modification time for files only includes the milliseconds on Linux with MRI > 1.9.2,
36
+ # that's why we generate a difference that's greater than 1 second.
37
+ #
38
+ def small_time_difference
39
+ t = Time.now
40
+ diff = t.to_f - t.to_i
41
+
42
+ sleep( 1.5 - (diff < 0.5 ? diff : 0.4) )
43
+ end
44
+
45
+ # Ensures that the test runs at almost the same second at which
46
+ # changes are being checked.
47
+ #
30
48
  def ensure_same_second
31
49
  t = Time.now
32
- if t.to_f - t.to_i > 0.1
33
- sleep 1.5 - (t.to_f - t.to_i)
50
+ diff = t.to_f - t.to_i
51
+
52
+ if diff > 0.1 # We are not at the beginning of a second
53
+ sleep 1.1 - diff # 1.1 is used instead of 1 to account for the processing time (estimated at 0.1 sec)
34
54
  end
35
55
  end
@@ -115,6 +115,17 @@ shared_examples_for 'a listener to changes on a file-system' do
115
115
  end
116
116
  end
117
117
 
118
+ describe '#relative_paths' do
119
+ it 'sets the relative paths option for paths in the callback' do
120
+ subject.relative_paths(true)
121
+ subject.instance_variable_get(:@use_relative_paths).should be_true
122
+ end
123
+
124
+ it 'returns the same listener to allow chaining' do
125
+ subject.relative_paths(true).should equal subject
126
+ end
127
+ end
128
+
118
129
  describe '#polling_fallback_message' do
119
130
  it 'sets custom polling fallback message to @adapter_options' do
120
131
  subject.polling_fallback_message('custom message')
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass
3
3
  version: !ruby/object:Gem::Version
4
- hash: 592303053
4
+ hash: 592302789
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 2
9
9
  - 0
10
10
  - alpha
11
- - 104
12
- version: 3.2.0.alpha.104
11
+ - 236
12
+ version: 3.2.0.alpha.236
13
13
  platform: ruby
14
14
  authors:
15
15
  - Nathan Weizenbaum
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2012-04-27 00:00:00 -04:00
22
+ date: 2012-05-11 00:00:00 -04:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
@@ -91,7 +91,6 @@ files:
91
91
  - lib/sass/plugin/compiler.rb
92
92
  - lib/sass/plugin/configuration.rb
93
93
  - lib/sass/plugin/generic.rb
94
- - lib/sass/plugin/listener.rb
95
94
  - lib/sass/plugin/merb.rb
96
95
  - lib/sass/plugin/rack.rb
97
96
  - lib/sass/plugin/rails.rb
@@ -111,6 +110,7 @@ files:
111
110
  - lib/sass/script/list.rb
112
111
  - lib/sass/script/literal.rb
113
112
  - lib/sass/script/node.rb
113
+ - lib/sass/script/null.rb
114
114
  - lib/sass/script/number.rb
115
115
  - lib/sass/script/operation.rb
116
116
  - lib/sass/script/parser.rb
@@ -136,19 +136,19 @@ files:
136
136
  - lib/sass/tree/charset_node.rb
137
137
  - lib/sass/tree/comment_node.rb
138
138
  - lib/sass/tree/directive_node.rb
139
- - lib/sass/tree/media_node.rb
139
+ - lib/sass/tree/extend_node.rb
140
140
  - lib/sass/tree/debug_node.rb
141
- - lib/sass/tree/mixin_def_node.rb
141
+ - lib/sass/tree/media_node.rb
142
142
  - lib/sass/tree/each_node.rb
143
- - lib/sass/tree/extend_node.rb
143
+ - lib/sass/tree/node.rb
144
144
  - lib/sass/tree/for_node.rb
145
145
  - lib/sass/tree/function_node.rb
146
146
  - lib/sass/tree/if_node.rb
147
147
  - lib/sass/tree/import_node.rb
148
- - lib/sass/tree/node.rb
149
- - lib/sass/tree/rule_node.rb
150
- - lib/sass/tree/mixin_node.rb
148
+ - lib/sass/tree/mixin_def_node.rb
151
149
  - lib/sass/tree/prop_node.rb
150
+ - lib/sass/tree/mixin_node.rb
151
+ - lib/sass/tree/rule_node.rb
152
152
  - lib/sass/tree/return_node.rb
153
153
  - lib/sass/tree/root_node.rb
154
154
  - lib/sass/tree/content_node.rb