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

Sign up to get free protection for your applications and to get access to all the features.
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,151 @@
1
+ require 'spec_helper'
2
+
3
+ describe Listen::Listener do
4
+ let(:adapter) { mock(Listen::Adapter, :start => true).as_null_object }
5
+ let(:watched_directory) { Dir.tmpdir }
6
+
7
+ subject { described_class.new(watched_directory) }
8
+
9
+ before do
10
+ Listen::Adapter.stub(:select_and_initialize) { adapter }
11
+ # Don't build a record of the files inside the base directory.
12
+ subject.directory_record.stub(:build)
13
+ end
14
+
15
+ it_should_behave_like 'a listener to changes on a file-system'
16
+
17
+ describe '#initialize' do
18
+ context 'with no options' do
19
+ it 'sets the directory' do
20
+ subject.directory.should eq watched_directory
21
+ end
22
+
23
+ it 'sets the option for using relative paths in the callback to the default one' do
24
+ subject.instance_variable_get(:@use_relative_paths).should eq described_class::DEFAULT_TO_RELATIVE_PATHS
25
+ end
26
+ end
27
+
28
+ context 'with custom options' do
29
+ subject { described_class.new(watched_directory, :ignore => '.ssh', :filter => [/.*\.rb/,/.*\.md/],
30
+ :latency => 0.5, :force_polling => true, :relative_paths => true) }
31
+
32
+ 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]
34
+ end
35
+
36
+ it 'passes the custom filters to the directory record' do
37
+ subject.directory_record.filters.should =~ [/.*\.rb/,/.*\.md/]
38
+ end
39
+
40
+ it 'sets the cutom option for using relative paths in the callback' do
41
+ subject.instance_variable_get(:@use_relative_paths).should be_true
42
+ end
43
+
44
+ it 'sets adapter_options' do
45
+ subject.instance_variable_get(:@adapter_options).should eq(:latency => 0.5, :force_polling => true)
46
+ end
47
+ end
48
+ end
49
+
50
+ describe '#start' do
51
+ it 'selects and initializes an adapter' do
52
+ Listen::Adapter.should_receive(:select_and_initialize).with(watched_directory, {}) { adapter }
53
+ subject.start
54
+ end
55
+
56
+ it 'builds the directory record' do
57
+ subject.directory_record.should_receive(:build)
58
+ subject.start
59
+ end
60
+ end
61
+
62
+ context 'with a started listener' do
63
+ before do
64
+ subject.stub(:initialize_adapter) { adapter }
65
+ subject.start
66
+ end
67
+
68
+ describe '#unpause' do
69
+ it 'rebuilds the directory record' do
70
+ subject.directory_record.should_receive(:build)
71
+ subject.unpause
72
+ end
73
+ end
74
+ end
75
+
76
+ describe '#ignore'do
77
+ it 'delegates the work to the directory record' do
78
+ subject.directory_record.should_receive(:ignore).with 'some_directory'
79
+ subject.ignore 'some_directory'
80
+ end
81
+ end
82
+
83
+ describe '#filter' do
84
+ it 'delegates the work to the directory record' do
85
+ subject.directory_record.should_receive(:filter).with /\.txt$/
86
+ subject.filter /\.txt$/
87
+ end
88
+ end
89
+
90
+
91
+ describe '#on_change' do
92
+ let(:directories) { %w{dir1 dir2 dir3} }
93
+ let(:changes) { {:modified => [], :added => [], :removed => []} }
94
+ let(:callback) { Proc.new { @called = true } }
95
+
96
+ before do
97
+ @called = false
98
+ subject.directory_record.stub(:fetch_changes => changes)
99
+ end
100
+
101
+ it 'fetches the changes of the directory record' do
102
+ subject.directory_record.should_receive(:fetch_changes).with(
103
+ directories, hash_including(:relative_paths => described_class::DEFAULT_TO_RELATIVE_PATHS)
104
+ )
105
+ subject.on_change(directories)
106
+ end
107
+
108
+ context 'with relative paths option set to true' do
109
+ subject { described_class.new(watched_directory, :relative_paths => true) }
110
+
111
+ it 'fetches the changes of the directory record' do
112
+ subject.directory_record.should_receive(:fetch_changes).with(directories, hash_including(:relative_paths => true))
113
+ subject.on_change(directories)
114
+ end
115
+ end
116
+
117
+ context 'with no changes to report' do
118
+ if RUBY_VERSION[/^1.8/]
119
+ it 'does not run the callback' do
120
+ subject.change(&callback)
121
+ subject.on_change(directories)
122
+ @called.should be_false
123
+ end
124
+ else
125
+ it 'does not run the callback' do
126
+ callback.should_not_receive(:call)
127
+ subject.change(&callback)
128
+ subject.on_change(directories)
129
+ end
130
+ end
131
+ end
132
+
133
+ context 'with changes to report' do
134
+ let(:changes) { {:modified => %w{path1}, :added => [], :removed => %w{path2}} }
135
+
136
+ if RUBY_VERSION[/^1.8/]
137
+ it 'runs the callback passing it the changes' do
138
+ subject.change(&callback)
139
+ subject.on_change(directories)
140
+ @called.should be_true
141
+ end
142
+ else
143
+ it 'runs the callback passing it the changes' do
144
+ callback.should_receive(:call).with(changes[:modified], changes[:added], changes[:removed])
145
+ subject.change(&callback)
146
+ subject.on_change(directories)
147
+ end
148
+ end
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,151 @@
1
+ require 'spec_helper'
2
+
3
+ describe Listen::MultiListener do
4
+ let(:adapter) { mock(Listen::Adapter, :start => true).as_null_object }
5
+ let(:watched_directories) { [File.dirname(__FILE__), Dir.tmpdir] }
6
+
7
+ subject { described_class.new(*watched_directories) }
8
+
9
+ before do
10
+ Listen::Adapter.stub(:select_and_initialize) { adapter }
11
+ # Don't build a record of the files inside the base directory.
12
+ Listen::DirectoryRecord.any_instance.stub(:build)
13
+ end
14
+
15
+ it_should_behave_like 'a listener to changes on a file-system'
16
+
17
+ describe '#initialize' do
18
+ context 'with no options' do
19
+ it 'sets the directories' do
20
+ subject.directories.should =~ watched_directories
21
+ end
22
+ end
23
+
24
+ context 'with custom options' do
25
+ subject do
26
+ args = watched_directories << {:ignore => '.ssh', :filter => [/.*\.rb/,/.*\.md/], :latency => 0.5, :force_polling => true}
27
+ described_class.new(*args)
28
+ end
29
+
30
+ it 'passes the custom ignored paths to each directory record' do
31
+ subject.directories_records.each do |r|
32
+ r.ignored_paths.should =~ %w[.bundle .git .DS_Store log tmp vendor .ssh]
33
+ end
34
+ end
35
+
36
+ it 'passes the custom filters to each directory record' do
37
+ subject.directories_records.each do |r|
38
+ r.filters.should =~ [/.*\.rb/,/.*\.md/]
39
+ end
40
+ end
41
+
42
+ it 'sets adapter_options' do
43
+ subject.instance_variable_get(:@adapter_options).should eq(:latency => 0.5, :force_polling => true)
44
+ end
45
+ end
46
+ end
47
+
48
+ describe '#start' do
49
+ it 'selects and initializes an adapter' do
50
+ Listen::Adapter.should_receive(:select_and_initialize).with(watched_directories, {}) { adapter }
51
+ subject.start
52
+ end
53
+
54
+ it 'builds all directories records' do
55
+ subject.directories_records.each do |r|
56
+ r.should_receive(:build)
57
+ end
58
+ subject.start
59
+ end
60
+ end
61
+
62
+ context 'with a started listener' do
63
+ before do
64
+ subject.stub(:initialize_adapter) { adapter }
65
+ subject.start
66
+ end
67
+
68
+ describe '#unpause' do
69
+ it 'rebuilds all directories records' do
70
+ subject.directories_records.each do |r|
71
+ r.should_receive(:build)
72
+ end
73
+ subject.unpause
74
+ end
75
+ end
76
+ end
77
+
78
+ describe '#ignore'do
79
+ it 'delegates the work to each directory record' do
80
+ subject.directories_records.each do |r|
81
+ r.should_receive(:ignore).with 'some_directory'
82
+ end
83
+ subject.ignore 'some_directory'
84
+ end
85
+ end
86
+
87
+ describe '#filter' do
88
+ it 'delegates the work to each directory record' do
89
+ subject.directories_records.each do |r|
90
+ r.should_receive(:filter).with /\.txt$/
91
+ end
92
+ subject.filter /\.txt$/
93
+ end
94
+ end
95
+
96
+ describe '#on_change' do
97
+ let(:directories) { %w{dir1 dir2 dir3} }
98
+ let(:changes) { {:modified => [], :added => [], :removed => []} }
99
+ let(:callback) { Proc.new { @called = true } }
100
+
101
+ before do
102
+ @called = false
103
+ subject.stub(:fetch_records_changes => changes)
104
+ end
105
+
106
+ it 'fetches the changes of all directories records' do
107
+ subject.unstub(:fetch_records_changes)
108
+
109
+ subject.directories_records.each do |record|
110
+ record.should_receive(:fetch_changes).with(
111
+ directories, hash_including(:relative_paths => described_class::DEFAULT_TO_RELATIVE_PATHS)
112
+ ).and_return(changes)
113
+ end
114
+ subject.on_change(directories)
115
+ end
116
+
117
+ context 'with no changes to report' do
118
+ if RUBY_VERSION[/^1.8/]
119
+ it 'does not run the callback' do
120
+ subject.change(&callback)
121
+ subject.on_change(directories)
122
+ @called.should be_false
123
+ end
124
+ else
125
+ it 'does not run the callback' do
126
+ callback.should_not_receive(:call)
127
+ subject.change(&callback)
128
+ subject.on_change(directories)
129
+ end
130
+ end
131
+ end
132
+
133
+ context 'with changes to report' do
134
+ let(:changes) { {:modified => %w{path1}, :added => [], :removed => %w{path2}} }
135
+
136
+ if RUBY_VERSION[/^1.8/]
137
+ it 'runs the callback passing it the changes' do
138
+ subject.change(&callback)
139
+ subject.on_change(directories)
140
+ @called.should be_true
141
+ end
142
+ else
143
+ it 'runs the callback passing it the changes' do
144
+ callback.should_receive(:call).with(changes[:modified], changes[:added], changes[:removed])
145
+ subject.change(&callback)
146
+ subject.on_change(directories)
147
+ end
148
+ end
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ def run_in_two_threads(proc1, proc2)
4
+ t1 = Thread.new &proc1
5
+ sleep test_latency # t1 must run before t2
6
+ t2 = Thread.new { proc2.call; Thread.kill t1 }
7
+ t2.join(test_latency * 2)
8
+ ensure
9
+ Thread.kill t1 if t1
10
+ Thread.kill t2 if t2
11
+ end
12
+
13
+ describe Listen::Turnstile do
14
+ before { @called = false }
15
+
16
+ describe '#wait' do
17
+ context 'without a signal' do
18
+ it 'blocks one thread indefinitely' do
19
+ run_in_two_threads lambda {
20
+ subject.wait
21
+ @called = true
22
+ }, lambda {
23
+ sleep test_latency
24
+ }
25
+ @called.should be_false
26
+ end
27
+ end
28
+
29
+ context 'with a signal' do
30
+ it 'blocks one thread until it recieves a signal from another thread' do
31
+ run_in_two_threads lambda {
32
+ subject.wait
33
+ @called = true
34
+ }, lambda {
35
+ subject.signal
36
+ sleep test_latency
37
+ }
38
+ @called.should be_true
39
+ end
40
+ end
41
+ end
42
+
43
+ describe '#signal' do
44
+ context 'without a wait-call before' do
45
+ it 'does nothing' do
46
+ run_in_two_threads lambda {
47
+ subject.signal
48
+ @called = true
49
+ }, lambda {
50
+ sleep test_latency
51
+ }
52
+ @called.should be_true
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe Listen do
4
+ describe '#to' do
5
+ context 'with one path to listen to' do
6
+ let(:listener) { mock(Listen::Listener) }
7
+ let(:listener_class) { Listen::Listener }
8
+
9
+ before { listener_class.stub(:new => listener) }
10
+
11
+ context 'without options' do
12
+ it 'creates an instance of Listner' do
13
+ listener_class.should_receive(:new).with('/path')
14
+ described_class.to('/path')
15
+ end
16
+ end
17
+
18
+ context 'with options' do
19
+ it 'creates an instance of Listner with the passed params' do
20
+ listener_class.should_receive(:new).with('/path', :filter => '**/*')
21
+ described_class.to('/path', :filter => '**/*')
22
+ end
23
+ end
24
+
25
+ context 'without a block' do
26
+ it 'returns the listener' do
27
+ described_class.to('/path', :filter => '**/*').should eq listener
28
+ end
29
+ end
30
+
31
+ context 'with a block' do
32
+ it 'starts the listner after creating it' do
33
+ listener.should_receive(:start)
34
+ described_class.to('/path', :filter => '**/*') { |modified, added, removed| }
35
+ end
36
+ end
37
+ end
38
+
39
+ context 'with multiple paths to listen to' do
40
+ let(:multi_listener) { mock(Listen::MultiListener) }
41
+ let(:multi_listener_class) { Listen::MultiListener }
42
+
43
+ before { multi_listener_class.stub(:new => multi_listener) }
44
+
45
+ context 'without options' do
46
+ it 'creates an instance of MultiListner' do
47
+ multi_listener_class.should_receive(:new).with('path1', 'path2')
48
+ described_class.to('path1', 'path2')
49
+ end
50
+ end
51
+
52
+ context 'with options' do
53
+ it 'creates an instance of MultiListner with the passed params' do
54
+ multi_listener_class.should_receive(:new).with('path1', 'path2', :filter => '**/*')
55
+ described_class.to('path1', 'path2', :filter => '**/*')
56
+ end
57
+ end
58
+
59
+ context 'without a block' do
60
+ it 'returns a MultiListener instance created with the passed params' do
61
+ described_class.to('path1', 'path2', :filter => '**/*').should eq multi_listener
62
+ end
63
+ end
64
+
65
+ context 'with a block' do
66
+ it 'starts a MultiListener instance after creating it with the passed params' do
67
+ multi_listener.should_receive(:start)
68
+ described_class.to('path1', 'path2', :filter => '**/*') { |modified, added, removed| }
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,16 @@
1
+ require 'listen'
2
+
3
+ ENV["TEST_LATENCY"] ||= "0.1"
4
+
5
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
6
+
7
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
8
+ RSpec.configure do |config|
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ config.run_all_when_everything_filtered = true
11
+ config.filter_run :focus
12
+ end
13
+
14
+ def test_latency
15
+ ENV["TEST_LATENCY"].to_f
16
+ end