sass 3.3.0.alpha.136 → 3.3.0.alpha.138

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/VERSION +1 -1
  3. data/VERSION_DATE +1 -1
  4. data/lib/sass/plugin/compiler.rb +1 -17
  5. metadata +22 -47
  6. data/vendor/listen/CHANGELOG.md +0 -221
  7. data/vendor/listen/CONTRIBUTING.md +0 -38
  8. data/vendor/listen/Gemfile +0 -30
  9. data/vendor/listen/Guardfile +0 -8
  10. data/vendor/listen/LICENSE +0 -20
  11. data/vendor/listen/README.md +0 -315
  12. data/vendor/listen/Rakefile +0 -47
  13. data/vendor/listen/Vagrantfile +0 -96
  14. data/vendor/listen/lib/listen.rb +0 -40
  15. data/vendor/listen/lib/listen/adapter.rb +0 -214
  16. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -112
  17. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -85
  18. data/vendor/listen/lib/listen/adapters/linux.rb +0 -113
  19. data/vendor/listen/lib/listen/adapters/polling.rb +0 -67
  20. data/vendor/listen/lib/listen/adapters/windows.rb +0 -87
  21. data/vendor/listen/lib/listen/dependency_manager.rb +0 -126
  22. data/vendor/listen/lib/listen/directory_record.rb +0 -371
  23. data/vendor/listen/lib/listen/listener.rb +0 -225
  24. data/vendor/listen/lib/listen/multi_listener.rb +0 -143
  25. data/vendor/listen/lib/listen/turnstile.rb +0 -28
  26. data/vendor/listen/lib/listen/version.rb +0 -3
  27. data/vendor/listen/listen.gemspec +0 -22
  28. data/vendor/listen/spec/listen/adapter_spec.rb +0 -183
  29. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  30. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  31. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  32. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  33. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  34. data/vendor/listen/spec/listen/dependency_manager_spec.rb +0 -107
  35. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1225
  36. data/vendor/listen/spec/listen/listener_spec.rb +0 -169
  37. data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -174
  38. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  39. data/vendor/listen/spec/listen_spec.rb +0 -73
  40. data/vendor/listen/spec/spec_helper.rb +0 -21
  41. data/vendor/listen/spec/support/adapter_helper.rb +0 -629
  42. data/vendor/listen/spec/support/directory_record_helper.rb +0 -55
  43. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  44. data/vendor/listen/spec/support/listeners_helper.rb +0 -156
  45. data/vendor/listen/spec/support/platform_helper.rb +0 -15
@@ -1,225 +0,0 @@
1
- require 'pathname'
2
-
3
- module Listen
4
- class Listener
5
- attr_reader :directory, :directory_record, :adapter
6
-
7
- # The default value for using relative paths in the callback.
8
- DEFAULT_TO_RELATIVE_PATHS = false
9
-
10
- # Initializes the directory listener.
11
- #
12
- # @param [String] directory the directory to listen to
13
- # @param [Hash] options the listen options
14
- # @option options [Regexp] ignore a pattern for ignoring paths
15
- # @option options [Regexp] filter a pattern for filtering paths
16
- # @option options [Float] latency the delay between checking for changes in seconds
17
- # @option options [Boolean] relative_paths whether or not to use relative-paths in the callback
18
- # @option options [Boolean] force_polling whether to force the polling adapter or not
19
- # @option options [String, Boolean] polling_fallback_message to change polling fallback message or remove it
20
- #
21
- # @yield [modified, added, removed] the changed files
22
- # @yieldparam [Array<String>] modified the list of modified files
23
- # @yieldparam [Array<String>] added the list of added files
24
- # @yieldparam [Array<String>] removed the list of removed files
25
- #
26
- def initialize(directory, options = {}, &block)
27
- @block = block
28
- @directory = Pathname.new(directory).realpath.to_s
29
- @directory_record = DirectoryRecord.new(@directory)
30
- @use_relative_paths = DEFAULT_TO_RELATIVE_PATHS
31
-
32
- @use_relative_paths = options.delete(:relative_paths) if options[:relative_paths]
33
- @directory_record.ignore(*options.delete(:ignore)) if options[:ignore]
34
- @directory_record.filter(*options.delete(:filter)) if options[:filter]
35
-
36
- @adapter_options = options
37
- end
38
-
39
- # Starts the listener by initializing the adapter and building
40
- # the directory record concurrently, then it starts the adapter to watch
41
- # for changes.
42
- #
43
- # @param [Boolean] blocking whether or not to block the current thread after starting
44
- #
45
- def start(blocking = true)
46
- t = Thread.new { @directory_record.build }
47
- @adapter = initialize_adapter
48
- t.join
49
- @adapter.start(blocking)
50
- end
51
-
52
- # Stops the listener.
53
- #
54
- def stop
55
- @adapter.stop
56
- end
57
-
58
- # Pauses the listener.
59
- #
60
- # @return [Listen::Listener] the listener
61
- #
62
- def pause
63
- @adapter.paused = true
64
- self
65
- end
66
-
67
- # Unpauses the listener.
68
- #
69
- # @return [Listen::Listener] the listener
70
- #
71
- def unpause
72
- @directory_record.build
73
- @adapter.paused = false
74
- self
75
- end
76
-
77
- # Returns whether the listener is paused or not.
78
- #
79
- # @return [Boolean] adapter paused status
80
- #
81
- def paused?
82
- !!@adapter && @adapter.paused == true
83
- end
84
-
85
- # Adds ignoring patterns to the listener.
86
- #
87
- # @param (see Listen::DirectoryRecord#ignore)
88
- #
89
- # @return [Listen::Listener] the listener
90
- #
91
- def ignore(*regexps)
92
- @directory_record.ignore(*regexps)
93
- self
94
- end
95
-
96
- # Replaces ignoring patterns in the listener.
97
- #
98
- # @param (see Listen::DirectoryRecord#ignore!)
99
- #
100
- # @return [Listen::Listener] the listener
101
- #
102
- def ignore!(*regexps)
103
- @directory_record.ignore!(*regexps)
104
- self
105
- end
106
-
107
- # Adds filtering patterns to the listener.
108
- #
109
- # @param (see Listen::DirectoryRecord#filter)
110
- #
111
- # @return [Listen::Listener] the listener
112
- #
113
- def filter(*regexps)
114
- @directory_record.filter(*regexps)
115
- self
116
- end
117
-
118
- # Replacing filtering patterns in the listener.
119
- #
120
- # @param (see Listen::DirectoryRecord#filter!)
121
- #
122
- # @return [Listen::Listener] the listener
123
- #
124
- def filter!(*regexps)
125
- @directory_record.filter!(*regexps)
126
- self
127
- end
128
-
129
- # Sets the latency for the adapter. This is a helper method
130
- # to simplify changing the latency directly from the listener.
131
- #
132
- # @example Wait 0.5 seconds each time before checking changes
133
- # latency 0.5
134
- #
135
- # @param [Float] seconds the amount of delay, in seconds
136
- #
137
- # @return [Listen::Listener] the listener
138
- #
139
- def latency(seconds)
140
- @adapter_options[:latency] = seconds
141
- self
142
- end
143
-
144
- # Sets whether the use of the polling adapter
145
- # should be forced or not.
146
- #
147
- # @example Forcing the use of the polling adapter
148
- # force_polling true
149
- #
150
- # @param [Boolean] value whether to force the polling adapter or not
151
- #
152
- # @return [Listen::Listener] the listener
153
- #
154
- def force_polling(value)
155
- @adapter_options[:force_polling] = value
156
- self
157
- end
158
-
159
- # Sets whether the paths in the callback should be
160
- # relative or absolute.
161
- #
162
- # @example Enabling relative paths in the callback
163
- # relative_paths true
164
- #
165
- # @param [Boolean] value whether to enable relative paths in the callback or not
166
- #
167
- # @return [Listen::Listener] the listener
168
- #
169
- def relative_paths(value)
170
- @use_relative_paths = value
171
- self
172
- end
173
-
174
- # Defines a custom polling fallback message of disable it.
175
- #
176
- # @example Disabling the polling fallback message
177
- # polling_fallback_message false
178
- #
179
- # @param [String, Boolean] value to change polling fallback message or remove it
180
- #
181
- # @return [Listen::Listener] the listener
182
- #
183
- def polling_fallback_message(value)
184
- @adapter_options[:polling_fallback_message] = value
185
- self
186
- end
187
-
188
- # Sets the callback that gets called on changes.
189
- #
190
- # @example Assign a callback to be called on changes
191
- # callback = lambda { |modified, added, removed| ... }
192
- # change &callback
193
- #
194
- # @param [Proc] block the callback proc
195
- #
196
- # @return [Listen::Listener] the listener
197
- #
198
- def change(&block) # modified, added, removed
199
- @block = block
200
- self
201
- end
202
-
203
- # Runs the callback passing it the changes if there are any.
204
- #
205
- # @param (see Listen::DirectoryRecord#fetch_changes)
206
- #
207
- def on_change(directories, options = {})
208
- changes = @directory_record.fetch_changes(directories, options.merge(
209
- :relative_paths => @use_relative_paths
210
- ))
211
- unless changes.values.all? { |paths| paths.empty? }
212
- @block.call(changes[:modified],changes[:added],changes[:removed])
213
- end
214
- end
215
-
216
- private
217
-
218
- # Initializes an adapter passing it the callback and adapters' options.
219
- #
220
- def initialize_adapter
221
- callback = lambda { |changed_dirs, options| self.on_change(changed_dirs, options) }
222
- Adapter.select_and_initialize(@directory, @adapter_options, &callback)
223
- end
224
- end
225
- end
@@ -1,143 +0,0 @@
1
- module Listen
2
- class MultiListener < Listener
3
- attr_reader :directories, :directories_records, :adapter
4
-
5
- # Initializes the multiple directories listener.
6
- #
7
- # @param [String] directories the directories to listen to
8
- # @param [Hash] options the listen options
9
- # @option options [Regexp] ignore a pattern for ignoring paths
10
- # @option options [Regexp] filter a pattern for filtering paths
11
- # @option options [Float] latency the delay between checking for changes in seconds
12
- # @option options [Boolean] force_polling whether to force the polling adapter or not
13
- # @option options [String, Boolean] polling_fallback_message to change polling fallback message or remove it
14
- #
15
- # @yield [modified, added, removed] the changed files
16
- # @yieldparam [Array<String>] modified the list of modified files
17
- # @yieldparam [Array<String>] added the list of added files
18
- # @yieldparam [Array<String>] removed the list of removed files
19
- #
20
- def initialize(*args, &block)
21
- options = args.last.is_a?(Hash) ? args.pop : {}
22
- directories = args
23
-
24
- @block = block
25
- @directories = directories.map { |d| Pathname.new(d).realpath.to_s }
26
- @directories_records = @directories.map { |d| DirectoryRecord.new(d) }
27
-
28
- ignore(*options.delete(:ignore)) if options[:ignore]
29
- filter(*options.delete(:filter)) if options[:filter]
30
-
31
- @adapter_options = options
32
- end
33
-
34
- # Starts the listener by initializing the adapter and building
35
- # the directory record concurrently, then it starts the adapter to watch
36
- # for changes.
37
- #
38
- # @param [Boolean] blocking whether or not to block the current thread after starting
39
- #
40
- def start(blocking = true)
41
- t = Thread.new { @directories_records.each { |r| r.build } }
42
- @adapter = initialize_adapter
43
- t.join
44
- @adapter.start(blocking)
45
- end
46
-
47
- # Unpauses the listener.
48
- #
49
- # @return [Listen::Listener] the listener
50
- #
51
- def unpause
52
- @directories_records.each { |r| r.build }
53
- @adapter.paused = false
54
- self
55
- end
56
-
57
- # Adds ignored paths to the listener.
58
- #
59
- # @param (see Listen::DirectoryRecord#ignore)
60
- #
61
- # @return [Listen::Listener] the listener
62
- #
63
- def ignore(*paths)
64
- @directories_records.each { |r| r.ignore(*paths) }
65
- self
66
- end
67
-
68
- # Replaces ignored paths in the listener.
69
- #
70
- # @param (see Listen::DirectoryRecord#ignore!)
71
- #
72
- # @return [Listen::Listener] the listener
73
- #
74
- def ignore!(*paths)
75
- @directories_records.each { |r| r.ignore!(*paths) }
76
- self
77
- end
78
-
79
- # Adds file filters to the listener.
80
- #
81
- # @param (see Listen::DirectoryRecord#filter)
82
- #
83
- # @return [Listen::Listener] the listener
84
- #
85
- def filter(*regexps)
86
- @directories_records.each { |r| r.filter(*regexps) }
87
- self
88
- end
89
-
90
- # Replaces file filters in the listener.
91
- #
92
- # @param (see Listen::DirectoryRecord#filter!)
93
- #
94
- # @return [Listen::Listener] the listener
95
- #
96
- def filter!(*regexps)
97
- @directories_records.each { |r| r.filter!(*regexps) }
98
- self
99
- end
100
-
101
- # Runs the callback passing it the changes if there are any.
102
- #
103
- # @param (see Listen::DirectoryRecord#fetch_changes)
104
- #
105
- def on_change(directories_to_search, options = {})
106
- changes = fetch_records_changes(directories_to_search, options)
107
- unless changes.values.all? { |paths| paths.empty? }
108
- @block.call(changes[:modified],changes[:added],changes[:removed])
109
- end
110
- end
111
-
112
- private
113
-
114
- # Initializes an adapter passing it the callback and adapters' options.
115
- #
116
- def initialize_adapter
117
- callback = lambda { |changed_dirs, options| self.on_change(changed_dirs, options) }
118
- Adapter.select_and_initialize(@directories, @adapter_options, &callback)
119
- end
120
-
121
- # Returns the sum of all the changes to the directories records
122
- #
123
- # @param (see Listen::DirectoryRecord#fetch_changes)
124
- #
125
- # @return [Hash] the changes
126
- #
127
- def fetch_records_changes(directories_to_search, options)
128
- @directories_records.inject({}) do |h, r|
129
- # directory records skips paths outside their range, so passing the
130
- # whole `directories` array is not a problem.
131
- record_changes = r.fetch_changes(directories_to_search, options.merge(:relative_paths => DEFAULT_TO_RELATIVE_PATHS))
132
-
133
- if h.empty?
134
- h.merge!(record_changes)
135
- else
136
- h.each { |k, v| h[k] += record_changes[k] }
137
- end
138
-
139
- h
140
- end
141
- end
142
- end
143
- end
@@ -1,28 +0,0 @@
1
- module Listen
2
- # Allows two threads to wait on eachother.
3
- #
4
- # @note Only two threads can be used with this Turnstile
5
- # because of the current implementation.
6
- class Turnstile
7
-
8
- # Initialize the turnstile.
9
- #
10
- def initialize
11
- # Until ruby offers semahpores, only queues can be used
12
- # to implement a turnstile.
13
- @q = Queue.new
14
- end
15
-
16
- # Blocks the current thread until a signal is received.
17
- #
18
- def wait
19
- @q.pop if @q.num_waiting == 0
20
- end
21
-
22
- # Unblocks the waiting thread if there is one.
23
- #
24
- def signal
25
- @q.push :dummy if @q.num_waiting == 1
26
- end
27
- end
28
- end
@@ -1,3 +0,0 @@
1
- module Listen
2
- VERSION = '0.7.2'
3
- end
@@ -1,22 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
3
- require 'listen/version'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'listen'
7
- s.version = Listen::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ['Thibaud Guillaume-Gentil', 'Maher Sallam']
10
- s.email = ['thibaud@thibaud.me', 'maher@sallam.me']
11
- s.homepage = 'https://github.com/guard/listen'
12
- s.summary = 'Listen to file modifications'
13
- s.description = 'The Listen gem listens to file modifications and notifies you about the changes. Works everywhere!'
14
-
15
- s.required_rubygems_version = '>= 1.3.6'
16
- s.rubyforge_project = 'listen'
17
-
18
- s.add_development_dependency 'bundler'
19
-
20
- s.files = Dir.glob('{lib}/**/*') + %w[CHANGELOG.md LICENSE README.md]
21
- s.require_path = 'lib'
22
- end
@@ -1,183 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Listen::Adapter do
4
- subject { described_class.new('dir') }
5
-
6
- describe '#initialize' do
7
- it 'sets the latency to the default one' do
8
- subject.latency.should eq described_class::DEFAULT_LATENCY
9
- end
10
-
11
- it 'accepts a single directory to watch' do
12
- described_class.new('dir').directories = %w{dir}
13
- end
14
-
15
- it 'accepts multiple directories to watch' do
16
- described_class.new(%w{dir1 dir2}).directories.should eq %w{dir1 dir2}
17
- end
18
- end
19
-
20
- describe ".select_and_initialize" do
21
- before do
22
- Listen::Adapters::Darwin.stub(:usable_and_works?) { false }
23
- Listen::Adapters::Linux.stub(:usable_and_works?) { false }
24
- Listen::Adapters::BSD.stub(:usable_and_works?) { false }
25
- Listen::Adapters::Windows.stub(:usable_and_works?) { false }
26
- end
27
-
28
- context "with no specific adapter usable" do
29
- it "returns Listen::Adapters::Polling instance" do
30
- Kernel.stub(:warn)
31
- Listen::Adapters::Polling.should_receive(:new).with('dir', {})
32
- described_class.select_and_initialize('dir')
33
- end
34
-
35
- it 'warns with the default polling fallback message' do
36
- Kernel.should_receive(:warn).with(/#{Listen::Adapter::POLLING_FALLBACK_MESSAGE}/)
37
- described_class.select_and_initialize('dir')
38
- end
39
-
40
- context 'when the dependencies of an adapter are not satisfied' do
41
- before do
42
- Listen::Adapters::Darwin.stub(:usable_and_works?).and_raise(Listen::DependencyManager::Error)
43
- Listen::Adapters::Linux.stub(:usable_and_works?).and_raise(Listen::DependencyManager::Error)
44
- Listen::Adapters::BSD.stub(:usable_and_works?).and_raise(Listen::DependencyManager::Error)
45
- Listen::Adapters::Windows.stub(:usable_and_works?).and_raise(Listen::DependencyManager::Error)
46
- end
47
-
48
- it 'invites the user to satisfy the dependencies of the adapter in the warning' do
49
- Kernel.should_receive(:warn).with(/#{Listen::Adapter::MISSING_DEPENDENCY_MESSAGE}/)
50
- described_class.select_and_initialize('dir')
51
- end
52
- end
53
-
54
- context "with custom polling_fallback_message option" do
55
- it "warns with the custom polling fallback message" do
56
- Kernel.should_receive(:warn).with(/custom/)
57
- described_class.select_and_initialize('dir', :polling_fallback_message => 'custom')
58
- end
59
- end
60
-
61
- context "with polling_fallback_message to false" do
62
- it "doesn't warn with a polling fallback message" do
63
- Kernel.should_not_receive(:warn)
64
- described_class.select_and_initialize('dir', :polling_fallback_message => false)
65
- end
66
- end
67
- end
68
-
69
- context "on Mac OX >= 10.6" do
70
- before { Listen::Adapters::Darwin.stub(:usable_and_works?) { true } }
71
-
72
- it "uses Listen::Adapters::Darwin" do
73
- Listen::Adapters::Darwin.should_receive(:new).with('dir', {})
74
- described_class.select_and_initialize('dir')
75
- end
76
-
77
- context 'when the use of the polling adapter is forced' do
78
- it 'uses Listen::Adapters::Polling' do
79
- Listen::Adapters::Polling.should_receive(:new).with('dir', {})
80
- described_class.select_and_initialize('dir', :force_polling => true)
81
- end
82
- end
83
- end
84
-
85
- context "on Linux" do
86
- before { Listen::Adapters::Linux.stub(:usable_and_works?) { true } }
87
-
88
- it "uses Listen::Adapters::Linux" do
89
- Listen::Adapters::Linux.should_receive(:new).with('dir', {})
90
- described_class.select_and_initialize('dir')
91
- end
92
-
93
- context 'when the use of the polling adapter is forced' do
94
- it 'uses Listen::Adapters::Polling' do
95
- Listen::Adapters::Polling.should_receive(:new).with('dir', {})
96
- described_class.select_and_initialize('dir', :force_polling => true)
97
- end
98
- end
99
- end
100
-
101
- context "on BSD" do
102
- before { Listen::Adapters::BSD.stub(:usable_and_works?) { true } }
103
-
104
- it "uses Listen::Adapters::BSD" do
105
- Listen::Adapters::BSD.should_receive(:new).with('dir', {})
106
- described_class.select_and_initialize('dir')
107
- end
108
-
109
- context 'when the use of the polling adapter is forced' do
110
- it 'uses Listen::Adapters::Polling' do
111
- Listen::Adapters::Polling.should_receive(:new).with('dir', {})
112
- described_class.select_and_initialize('dir', :force_polling => true)
113
- end
114
- end
115
- end
116
-
117
- context "on Windows" do
118
- before { Listen::Adapters::Windows.stub(:usable_and_works?) { true } }
119
-
120
- it "uses Listen::Adapters::Windows" do
121
- Listen::Adapters::Windows.should_receive(:new).with('dir', {})
122
- described_class.select_and_initialize('dir')
123
- end
124
-
125
- context 'when the use of the polling adapter is forced' do
126
- it 'uses Listen::Adapters::Polling' do
127
- Listen::Adapters::Polling.should_receive(:new).with('dir', {})
128
- described_class.select_and_initialize('dir', :force_polling => true)
129
- end
130
- end
131
- end
132
- end
133
-
134
- [Listen::Adapters::Darwin, Listen::Adapters::Linux,
135
- Listen::Adapters::BSD, Listen::Adapters::Windows].each do
136
- |adapter_class|
137
- if adapter_class.usable?
138
- describe '.usable?' do
139
- it 'checks the dependencies' do
140
- adapter_class.should_receive(:load_depenencies)
141
- adapter_class.should_receive(:dependencies_loaded?)
142
- adapter_class.usable?
143
- end
144
- end
145
-
146
- describe '.usable_and_works?' do
147
- it 'checks if the adapter is usable' do
148
- adapter_class.stub(:works?)
149
- adapter_class.should_receive(:usable?)
150
- adapter_class.usable_and_works?('dir')
151
- end
152
-
153
- context 'with one directory' do
154
- it 'tests if that directory actually work' do
155
- fixtures do |path|
156
- adapter_class.should_receive(:works?).with(path, anything).and_return(true)
157
- adapter_class.usable_and_works?(path)
158
- end
159
- end
160
- end
161
-
162
- context 'with multiple directories' do
163
- it 'tests if each directory passed does actually work' do
164
- fixtures(3) do |path1, path2, path3|
165
- adapter_class.should_receive(:works?).exactly(3).times.with do |path, options|
166
- [path1, path2, path3].include? path
167
- end.and_return(true)
168
- adapter_class.usable_and_works?([path1, path2, path3])
169
- end
170
- end
171
- end
172
- end
173
-
174
- describe '.works?' do
175
- it 'does work' do
176
- fixtures do |path|
177
- adapter_class.works?(path).should be_true
178
- end
179
- end
180
- end
181
- end
182
- end
183
- end