sass 3.1.21 → 3.2.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -4
- data/REVISION +1 -1
- data/Rakefile +6 -15
- data/VERSION +1 -1
- data/VERSION_NAME +1 -1
- data/lib/sass.rb +0 -1
- data/lib/sass/cache_stores/base.rb +1 -3
- data/lib/sass/cache_stores/filesystem.rb +0 -3
- data/lib/sass/css.rb +49 -145
- data/lib/sass/engine.rb +23 -47
- data/lib/sass/environment.rb +5 -30
- data/lib/sass/exec.rb +7 -30
- data/lib/sass/importers/base.rb +1 -2
- data/lib/sass/importers/filesystem.rb +13 -18
- data/lib/sass/less.rb +1 -1
- data/lib/sass/plugin.rb +8 -4
- data/lib/sass/plugin/compiler.rb +67 -93
- data/lib/sass/plugin/configuration.rb +2 -0
- data/lib/sass/plugin/staleness_checker.rb +4 -14
- data/lib/sass/repl.rb +3 -2
- data/lib/sass/script.rb +1 -0
- data/lib/sass/script/color.rb +9 -4
- data/lib/sass/script/funcall.rb +3 -16
- data/lib/sass/script/functions.rb +55 -98
- data/lib/sass/script/interpolation.rb +0 -9
- data/lib/sass/script/lexer.rb +4 -2
- data/lib/sass/script/list.rb +0 -8
- data/lib/sass/script/literal.rb +20 -5
- data/lib/sass/script/node.rb +0 -8
- data/lib/sass/script/number.rb +11 -35
- data/lib/sass/script/operation.rb +0 -16
- data/lib/sass/script/parser.rb +5 -12
- data/lib/sass/script/string_interpolation.rb +0 -9
- data/lib/sass/script/unary_operation.rb +0 -7
- data/lib/sass/script/variable.rb +1 -5
- data/lib/sass/scss/parser.rb +54 -191
- data/lib/sass/scss/rx.rb +3 -15
- data/lib/sass/scss/static_parser.rb +3 -3
- data/lib/sass/selector.rb +3 -15
- data/lib/sass/selector/abstract_sequence.rb +2 -11
- data/lib/sass/selector/comma_sequence.rb +3 -8
- data/lib/sass/selector/sequence.rb +11 -74
- data/lib/sass/selector/simple.rb +1 -7
- data/lib/sass/selector/simple_sequence.rb +8 -28
- data/lib/sass/shared.rb +5 -3
- data/lib/sass/tree/comment_node.rb +12 -25
- data/lib/sass/tree/debug_node.rb +1 -1
- data/lib/sass/tree/directive_node.rb +0 -5
- data/lib/sass/tree/each_node.rb +1 -1
- data/lib/sass/tree/extend_node.rb +1 -1
- data/lib/sass/tree/for_node.rb +2 -2
- data/lib/sass/tree/function_node.rb +1 -1
- data/lib/sass/tree/if_node.rb +14 -1
- data/lib/sass/tree/media_node.rb +4 -4
- data/lib/sass/tree/mixin_def_node.rb +1 -1
- data/lib/sass/tree/mixin_node.rb +2 -2
- data/lib/sass/tree/node.rb +26 -10
- data/lib/sass/tree/return_node.rb +1 -1
- data/lib/sass/tree/root_node.rb +1 -1
- data/lib/sass/tree/rule_node.rb +11 -9
- data/lib/sass/tree/variable_node.rb +1 -1
- data/lib/sass/tree/visitors/base.rb +1 -1
- data/lib/sass/tree/visitors/check_nesting.rb +36 -29
- data/lib/sass/tree/visitors/convert.rb +9 -16
- data/lib/sass/tree/visitors/cssize.rb +9 -40
- data/lib/sass/tree/visitors/perform.rb +23 -79
- data/lib/sass/tree/visitors/to_css.rb +21 -23
- data/lib/sass/tree/warn_node.rb +1 -1
- data/lib/sass/tree/while_node.rb +1 -1
- data/lib/sass/util.rb +9 -147
- data/lib/sass/version.rb +0 -14
- data/test/sass/cache_test.rb +0 -15
- data/test/sass/conversion_test.rb +8 -50
- data/test/sass/css2sass_test.rb +0 -33
- data/test/sass/engine_test.rb +32 -283
- data/test/sass/extend_test.rb +0 -315
- data/test/sass/functions_test.rb +23 -60
- data/test/sass/importer_test.rb +0 -110
- data/test/sass/more_results/more_import.css +2 -2
- data/test/sass/plugin_test.rb +13 -40
- data/test/sass/results/import.css +2 -2
- data/test/sass/results/import_charset.css +0 -1
- data/test/sass/results/import_charset_1_8.css +0 -1
- data/test/sass/results/import_charset_ibm866.css +0 -1
- data/test/sass/results/scss_import.css +2 -2
- data/test/sass/results/units.css +1 -1
- data/test/sass/script_conversion_test.rb +0 -2
- data/test/sass/script_test.rb +4 -28
- data/test/sass/scss/css_test.rb +1 -79
- data/test/sass/scss/scss_test.rb +16 -96
- data/test/sass/templates/import_charset.sass +0 -2
- data/test/sass/templates/import_charset_1_8.sass +0 -2
- data/test/sass/templates/import_charset_ibm866.sass +0 -2
- data/test/sass/test_helper.rb +1 -1
- data/test/sass/util_test.rb +0 -28
- data/test/test_helper.rb +0 -2
- data/vendor/{listen → fssm}/LICENSE +1 -1
- data/vendor/fssm/README.markdown +55 -0
- data/vendor/fssm/Rakefile +59 -0
- data/vendor/fssm/VERSION.yml +5 -0
- data/vendor/fssm/example.rb +9 -0
- data/vendor/fssm/fssm.gemspec +77 -0
- data/vendor/fssm/lib/fssm.rb +33 -0
- data/vendor/fssm/lib/fssm/backends/fsevents.rb +36 -0
- data/vendor/fssm/lib/fssm/backends/inotify.rb +26 -0
- data/vendor/fssm/lib/fssm/backends/polling.rb +25 -0
- data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +131 -0
- data/vendor/fssm/lib/fssm/monitor.rb +26 -0
- data/vendor/fssm/lib/fssm/path.rb +91 -0
- data/vendor/fssm/lib/fssm/pathname.rb +502 -0
- data/vendor/fssm/lib/fssm/state/directory.rb +57 -0
- data/vendor/fssm/lib/fssm/state/file.rb +24 -0
- data/vendor/fssm/lib/fssm/support.rb +63 -0
- data/vendor/fssm/lib/fssm/tree.rb +176 -0
- data/vendor/fssm/profile/prof-cache.rb +40 -0
- data/vendor/fssm/profile/prof-fssm-pathname.html +1231 -0
- data/vendor/fssm/profile/prof-pathname.rb +68 -0
- data/vendor/fssm/profile/prof-plain-pathname.html +988 -0
- data/vendor/fssm/profile/prof.html +2379 -0
- data/vendor/fssm/spec/path_spec.rb +75 -0
- data/vendor/fssm/spec/root/duck/quack.txt +0 -0
- data/vendor/fssm/spec/root/file.css +0 -0
- data/vendor/fssm/spec/root/file.rb +0 -0
- data/vendor/fssm/spec/root/file.yml +0 -0
- data/vendor/fssm/spec/root/moo/cow.txt +0 -0
- data/vendor/fssm/spec/spec_helper.rb +14 -0
- metadata +246 -281
- data/VERSION_DATE +0 -1
- data/lib/sass/logger.rb +0 -15
- data/lib/sass/logger/base.rb +0 -32
- data/lib/sass/logger/log_level.rb +0 -49
- data/lib/sass/tree/visitors/deep_copy.rb +0 -87
- data/lib/sass/tree/visitors/extend.rb +0 -42
- data/lib/sass/tree/visitors/set_options.rb +0 -97
- data/lib/sass/util/multibyte_string_scanner.rb +0 -134
- data/test/Gemfile +0 -4
- data/test/Gemfile.lock +0 -19
- data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
- data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
- data/test/sass/logger_test.rb +0 -58
- data/test/sass/templates/_double_import_loop2.sass +0 -1
- data/test/sass/templates/bork5.sass +0 -3
- data/test/sass/templates/double_import_loop1.sass +0 -1
- data/test/sass/templates/nested_bork5.sass +0 -2
- data/test/sass/templates/single_import_loop.sass +0 -1
- data/test/sass/util/multibyte_string_scanner_test.rb +0 -147
- data/vendor/listen/CHANGELOG.md +0 -147
- data/vendor/listen/Gemfile +0 -23
- data/vendor/listen/Guardfile +0 -8
- data/vendor/listen/README.md +0 -312
- data/vendor/listen/Rakefile +0 -47
- data/vendor/listen/Vagrantfile +0 -96
- data/vendor/listen/lib/listen.rb +0 -38
- data/vendor/listen/lib/listen/adapter.rb +0 -167
- data/vendor/listen/lib/listen/adapters/darwin.rb +0 -84
- data/vendor/listen/lib/listen/adapters/linux.rb +0 -110
- data/vendor/listen/lib/listen/adapters/polling.rb +0 -66
- data/vendor/listen/lib/listen/adapters/windows.rb +0 -81
- data/vendor/listen/lib/listen/directory_record.rb +0 -318
- data/vendor/listen/lib/listen/listener.rb +0 -203
- data/vendor/listen/lib/listen/multi_listener.rb +0 -121
- data/vendor/listen/lib/listen/turnstile.rb +0 -28
- data/vendor/listen/lib/listen/version.rb +0 -3
- data/vendor/listen/listen.gemspec +0 -26
- data/vendor/listen/spec/listen/adapter_spec.rb +0 -142
- data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -31
- data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -41
- data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
- data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -24
- data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1138
- data/vendor/listen/spec/listen/listener_spec.rb +0 -155
- data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -156
- data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
- data/vendor/listen/spec/listen_spec.rb +0 -73
- data/vendor/listen/spec/spec_helper.rb +0 -18
- data/vendor/listen/spec/support/adapter_helper.rb +0 -716
- data/vendor/listen/spec/support/directory_record_helper.rb +0 -55
- data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
- data/vendor/listen/spec/support/listeners_helper.rb +0 -144
- data/vendor/listen/spec/support/platform_helper.rb +0 -11
@@ -1,716 +0,0 @@
|
|
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
|
-
|
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
|
71
|
-
end
|
72
|
-
|
73
|
-
shared_examples_for 'an adapter that call properly listener#on_change' do |*args|
|
74
|
-
options = (args.first && args.first.is_a?(Hash)) ? args.first : {}
|
75
|
-
let(:listener) { mock(Listen::Listener) }
|
76
|
-
before { described_class.stub(:works?) { true } }
|
77
|
-
|
78
|
-
context 'single file operations' do
|
79
|
-
context 'when a file is created' do
|
80
|
-
it 'detects the added file' do
|
81
|
-
fixtures do |path|
|
82
|
-
if options[:recursive]
|
83
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
84
|
-
else
|
85
|
-
listener.should_receive(:on_change).once.with([path], {})
|
86
|
-
end
|
87
|
-
|
88
|
-
watch(listener, path) do
|
89
|
-
touch 'new_file.rb'
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
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
|
-
|
112
|
-
context 'given a new created directory' do
|
113
|
-
it 'detects the added file' do
|
114
|
-
fixtures do |path|
|
115
|
-
if options[:recursive]
|
116
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
117
|
-
else
|
118
|
-
listener.should_receive(:on_change).once.with do |array, options|
|
119
|
-
array.should =~ [path, "#{path}/a_directory"]
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
watch(listener, path) do
|
124
|
-
mkdir 'a_directory'
|
125
|
-
# Needed for INotify, because of :recursive rb-inotify custom flag?
|
126
|
-
sleep 0.05 if @adapter.is_a?(Listen::Adapters::Linux)
|
127
|
-
touch 'a_directory/new_file.rb'
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context 'given an existing directory' do
|
134
|
-
it 'detects the added file' do
|
135
|
-
fixtures do |path|
|
136
|
-
if options[:recursive]
|
137
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
138
|
-
else
|
139
|
-
listener.should_receive(:on_change).once.with(["#{path}/a_directory"], {})
|
140
|
-
end
|
141
|
-
|
142
|
-
mkdir 'a_directory'
|
143
|
-
|
144
|
-
watch(listener, path) do
|
145
|
-
touch 'a_directory/new_file.rb'
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
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
|
168
|
-
end
|
169
|
-
|
170
|
-
context 'when a file is modified' do
|
171
|
-
it 'detects the modified file' do
|
172
|
-
fixtures do |path|
|
173
|
-
if options[:recursive]
|
174
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
175
|
-
else
|
176
|
-
listener.should_receive(:on_change).once.with([path], {})
|
177
|
-
end
|
178
|
-
|
179
|
-
touch 'existing_file.txt'
|
180
|
-
|
181
|
-
watch(listener, path) do
|
182
|
-
touch 'existing_file.txt'
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
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
|
-
|
206
|
-
context 'given a hidden file' do
|
207
|
-
it 'detects the modified file' do
|
208
|
-
fixtures do |path|
|
209
|
-
if options[:recursive]
|
210
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
211
|
-
else
|
212
|
-
listener.should_receive(:on_change).once.with([path], {})
|
213
|
-
end
|
214
|
-
|
215
|
-
touch '.hidden'
|
216
|
-
|
217
|
-
watch(listener, path) do
|
218
|
-
touch '.hidden'
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
unless options[:adapter] == :windows
|
225
|
-
context 'given a file mode change' do
|
226
|
-
it 'does not detect the mode change' do
|
227
|
-
fixtures do |path|
|
228
|
-
if options[:recursive]
|
229
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
230
|
-
else
|
231
|
-
listener.should_receive(:on_change).once.with([path], {})
|
232
|
-
end
|
233
|
-
|
234
|
-
touch 'run.rb'
|
235
|
-
|
236
|
-
watch(listener, path) do
|
237
|
-
chmod 0777, 'run.rb'
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
context 'given an existing directory' do
|
245
|
-
it 'detects the modified file' do
|
246
|
-
fixtures do |path|
|
247
|
-
if options[:recursive]
|
248
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
249
|
-
else
|
250
|
-
listener.should_receive(:on_change).once.with(["#{path}/a_directory"], {})
|
251
|
-
end
|
252
|
-
|
253
|
-
mkdir 'a_directory'
|
254
|
-
touch 'a_directory/existing_file.txt'
|
255
|
-
|
256
|
-
watch(listener, path) do
|
257
|
-
touch 'a_directory/existing_file.txt'
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
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
|
281
|
-
end
|
282
|
-
|
283
|
-
context 'when a file is moved' do
|
284
|
-
it 'detects the file move' do
|
285
|
-
fixtures do |path|
|
286
|
-
if options[:recursive]
|
287
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
288
|
-
else
|
289
|
-
listener.should_receive(:on_change).once.with([path], {})
|
290
|
-
end
|
291
|
-
|
292
|
-
touch 'move_me.txt'
|
293
|
-
|
294
|
-
watch(listener, path) do
|
295
|
-
mv 'move_me.txt', 'new_name.txt'
|
296
|
-
end
|
297
|
-
end
|
298
|
-
end
|
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
|
-
|
319
|
-
context 'given an existing directory' do
|
320
|
-
it 'detects the file move into the directory' do
|
321
|
-
fixtures do |path|
|
322
|
-
if options[:recursive]
|
323
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
324
|
-
else
|
325
|
-
listener.should_receive(:on_change).once.with do |array, options|
|
326
|
-
array.should =~ [path, "#{path}/a_directory"]
|
327
|
-
end
|
328
|
-
end
|
329
|
-
|
330
|
-
mkdir 'a_directory'
|
331
|
-
touch 'move_me.txt'
|
332
|
-
|
333
|
-
watch(listener, path) do
|
334
|
-
mv 'move_me.txt', 'a_directory/move_me.txt'
|
335
|
-
end
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
it 'detects a file move out of the directory' do
|
340
|
-
fixtures do |path|
|
341
|
-
if options[:recursive]
|
342
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
343
|
-
else
|
344
|
-
listener.should_receive(:on_change).once.with do |array, options|
|
345
|
-
array.should =~ [path, "#{path}/a_directory"]
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
mkdir 'a_directory'
|
350
|
-
touch 'a_directory/move_me.txt'
|
351
|
-
|
352
|
-
watch(listener, path) do
|
353
|
-
mv 'a_directory/move_me.txt', 'i_am_here.txt'
|
354
|
-
end
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
|
-
it 'detects a file move between two directories' do
|
359
|
-
fixtures do |path|
|
360
|
-
if options[:recursive]
|
361
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
362
|
-
else
|
363
|
-
listener.should_receive(:on_change).once.with do |array, options|
|
364
|
-
array.should =~ ["#{path}/from_directory", "#{path}/to_directory"]
|
365
|
-
end
|
366
|
-
end
|
367
|
-
|
368
|
-
mkdir 'from_directory'
|
369
|
-
touch 'from_directory/move_me.txt'
|
370
|
-
mkdir 'to_directory'
|
371
|
-
|
372
|
-
watch(listener, path) do
|
373
|
-
mv 'from_directory/move_me.txt', 'to_directory/move_me.txt'
|
374
|
-
end
|
375
|
-
end
|
376
|
-
end
|
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
|
400
|
-
end
|
401
|
-
|
402
|
-
context 'when a file is deleted' do
|
403
|
-
it 'detects the file removal' do
|
404
|
-
fixtures do |path|
|
405
|
-
if options[:recursive]
|
406
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
407
|
-
else
|
408
|
-
listener.should_receive(:on_change).once.with([path], {})
|
409
|
-
end
|
410
|
-
|
411
|
-
touch 'unnecessary.txt'
|
412
|
-
|
413
|
-
watch(listener, path) do
|
414
|
-
rm 'unnecessary.txt'
|
415
|
-
end
|
416
|
-
end
|
417
|
-
end
|
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
|
-
|
438
|
-
context 'given an existing directory' do
|
439
|
-
it 'detects the file removal' do
|
440
|
-
fixtures do |path|
|
441
|
-
if options[:recursive]
|
442
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
443
|
-
else
|
444
|
-
listener.should_receive(:on_change).once.with(["#{path}/a_directory"], {})
|
445
|
-
end
|
446
|
-
|
447
|
-
mkdir 'a_directory'
|
448
|
-
touch 'a_directory/do_not_use.rb'
|
449
|
-
|
450
|
-
watch(listener, path) do
|
451
|
-
rm 'a_directory/do_not_use.rb'
|
452
|
-
end
|
453
|
-
end
|
454
|
-
end
|
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
|
475
|
-
end
|
476
|
-
end
|
477
|
-
|
478
|
-
context 'multiple file operations' do
|
479
|
-
it 'detects the added files' do
|
480
|
-
fixtures do |path|
|
481
|
-
if options[:recursive]
|
482
|
-
listener.should_receive(:on_change).at_least(:once).with([path], :recursive => true)
|
483
|
-
else
|
484
|
-
listener.should_receive(:on_change).once.with do |array, options|
|
485
|
-
array.should =~ [path, "#{path}/a_directory"]
|
486
|
-
end
|
487
|
-
end
|
488
|
-
|
489
|
-
watch(listener, path) do
|
490
|
-
touch 'a_file.rb'
|
491
|
-
touch 'b_file.rb'
|
492
|
-
mkdir 'a_directory'
|
493
|
-
# Needed for INotify, because of :recursive rb-inotify custom flag?
|
494
|
-
# Also needed for the osx adapter
|
495
|
-
sleep 0.05
|
496
|
-
touch 'a_directory/a_file.rb'
|
497
|
-
touch 'a_directory/b_file.rb'
|
498
|
-
end
|
499
|
-
end
|
500
|
-
end
|
501
|
-
|
502
|
-
it 'detects the modified files' do
|
503
|
-
fixtures do |path|
|
504
|
-
if options[:recursive]
|
505
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
506
|
-
else
|
507
|
-
listener.should_receive(:on_change).once.with do |array, options|
|
508
|
-
array.should =~ [path, "#{path}/a_directory"]
|
509
|
-
end
|
510
|
-
end
|
511
|
-
|
512
|
-
touch 'a_file.rb'
|
513
|
-
touch 'b_file.rb'
|
514
|
-
mkdir 'a_directory'
|
515
|
-
touch 'a_directory/a_file.rb'
|
516
|
-
touch 'a_directory/b_file.rb'
|
517
|
-
|
518
|
-
watch(listener, path) do
|
519
|
-
touch 'b_file.rb'
|
520
|
-
touch 'a_directory/a_file.rb'
|
521
|
-
end
|
522
|
-
end
|
523
|
-
end
|
524
|
-
|
525
|
-
it 'detects the removed files' do
|
526
|
-
fixtures do |path|
|
527
|
-
if options[:recursive]
|
528
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
529
|
-
else
|
530
|
-
listener.should_receive(:on_change).once.with do |array, options|
|
531
|
-
array.should =~ [path, "#{path}/a_directory"]
|
532
|
-
end
|
533
|
-
end
|
534
|
-
|
535
|
-
touch 'a_file.rb'
|
536
|
-
touch 'b_file.rb'
|
537
|
-
mkdir 'a_directory'
|
538
|
-
touch 'a_directory/a_file.rb'
|
539
|
-
touch 'a_directory/b_file.rb'
|
540
|
-
|
541
|
-
watch(listener, path) do
|
542
|
-
rm 'b_file.rb'
|
543
|
-
rm 'a_directory/a_file.rb'
|
544
|
-
end
|
545
|
-
end
|
546
|
-
end
|
547
|
-
end
|
548
|
-
|
549
|
-
context 'single directory operations' do
|
550
|
-
it 'detects a moved directory' do
|
551
|
-
fixtures do |path|
|
552
|
-
if options[:recursive]
|
553
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
554
|
-
else
|
555
|
-
listener.should_receive(:on_change).once.with([path], {})
|
556
|
-
end
|
557
|
-
|
558
|
-
mkdir 'a_directory'
|
559
|
-
touch 'a_directory/a_file.rb'
|
560
|
-
touch 'a_directory/b_file.rb'
|
561
|
-
|
562
|
-
watch(listener, path) do
|
563
|
-
mv 'a_directory', 'renamed'
|
564
|
-
end
|
565
|
-
end
|
566
|
-
end
|
567
|
-
|
568
|
-
it 'detects a removed directory' do
|
569
|
-
fixtures do |path|
|
570
|
-
if options[:recursive]
|
571
|
-
listener.should_receive(:on_change).once.with([path], :recursive => true)
|
572
|
-
else
|
573
|
-
listener.should_receive(:on_change).once.with do |array, options|
|
574
|
-
array.should =~ [path, "#{path}/a_directory"]
|
575
|
-
end
|
576
|
-
end
|
577
|
-
|
578
|
-
mkdir 'a_directory'
|
579
|
-
touch 'a_directory/a_file.rb'
|
580
|
-
touch 'a_directory/b_file.rb'
|
581
|
-
|
582
|
-
watch(listener, path) do
|
583
|
-
rm_rf 'a_directory'
|
584
|
-
end
|
585
|
-
end
|
586
|
-
end
|
587
|
-
end
|
588
|
-
|
589
|
-
context "paused adapter" do
|
590
|
-
context 'when a file is created' do
|
591
|
-
it "doesn't detects the added file" do
|
592
|
-
fixtures do |path|
|
593
|
-
watch(listener, path) do
|
594
|
-
@adapter.paused = true
|
595
|
-
touch 'new_file.rb'
|
596
|
-
end
|
597
|
-
@called.should be_nil
|
598
|
-
end
|
599
|
-
end
|
600
|
-
end
|
601
|
-
end
|
602
|
-
|
603
|
-
context "when multiple directories are listened to" do
|
604
|
-
context 'when files are added to one of multiple directories' do
|
605
|
-
it 'detects added files' do
|
606
|
-
fixtures(2) do |path1, path2|
|
607
|
-
if options[:recursive]
|
608
|
-
listener.should_receive(:on_change).once.with([path2], :recursive => true)
|
609
|
-
else
|
610
|
-
listener.should_receive(:on_change).once.with([path2], {})
|
611
|
-
end
|
612
|
-
|
613
|
-
watch(listener, path1, path2) do
|
614
|
-
touch "#{path2}/new_file.rb"
|
615
|
-
end
|
616
|
-
end
|
617
|
-
end
|
618
|
-
end
|
619
|
-
|
620
|
-
context 'when files are added to multiple directories' do
|
621
|
-
it 'detects added files' do
|
622
|
-
fixtures(2) do |path1, path2|
|
623
|
-
if options[:recursive]
|
624
|
-
listener.should_receive(:on_change).once.with do |directories, options|
|
625
|
-
directories.should =~ [path1, path2] && options.should == {:recursive => true}
|
626
|
-
end
|
627
|
-
else
|
628
|
-
listener.should_receive(:on_change).once.with do |directories, options|
|
629
|
-
directories.should =~ [path1, path2] && options.should == {}
|
630
|
-
end
|
631
|
-
end
|
632
|
-
|
633
|
-
watch(listener, path1, path2) do
|
634
|
-
touch "#{path1}/new_file.rb"
|
635
|
-
touch "#{path2}/new_file.rb"
|
636
|
-
end
|
637
|
-
end
|
638
|
-
end
|
639
|
-
end
|
640
|
-
|
641
|
-
context 'given a new and an existing directory on multiple directories' do
|
642
|
-
it 'detects the added file' do
|
643
|
-
fixtures(2) do |path1, path2|
|
644
|
-
if options[:recursive]
|
645
|
-
listener.should_receive(:on_change).once.with do |directories, options|
|
646
|
-
directories.should =~ [path1, path2] && options.should == {:recursive => true}
|
647
|
-
end
|
648
|
-
else
|
649
|
-
listener.should_receive(:on_change).once.with do |directories, options|
|
650
|
-
directories.should =~ [path2, "#{path2}/b_directory", "#{path1}/a_directory"] && options.should == {}
|
651
|
-
end
|
652
|
-
end
|
653
|
-
|
654
|
-
mkdir "#{path1}/a_directory"
|
655
|
-
|
656
|
-
watch(listener, path1, path2) do
|
657
|
-
mkdir "#{path2}/b_directory"
|
658
|
-
sleep 0.05
|
659
|
-
touch "#{path1}/a_directory/new_file.rb"
|
660
|
-
touch "#{path2}/b_directory/new_file.rb"
|
661
|
-
end
|
662
|
-
end
|
663
|
-
end
|
664
|
-
end
|
665
|
-
|
666
|
-
context 'when a file is moved between the multiple watched directories' do
|
667
|
-
it 'detects the movements of the file' do
|
668
|
-
fixtures(3) do |path1, path2, path3|
|
669
|
-
if options[:recursive]
|
670
|
-
listener.should_receive(:on_change).once.with do |directories, options|
|
671
|
-
directories.should =~ [path1, path2, path3] && options.should == {:recursive => true}
|
672
|
-
end
|
673
|
-
else
|
674
|
-
listener.should_receive(:on_change).once.with do |directories, options|
|
675
|
-
directories.should =~ ["#{path1}/from_directory", path2, "#{path3}/to_directory"] && options.should == {}
|
676
|
-
end
|
677
|
-
end
|
678
|
-
|
679
|
-
mkdir "#{path1}/from_directory"
|
680
|
-
touch "#{path1}/from_directory/move_me.txt"
|
681
|
-
mkdir "#{path3}/to_directory"
|
682
|
-
|
683
|
-
watch(listener, path1, path2, path3) do
|
684
|
-
mv "#{path1}/from_directory/move_me.txt", "#{path2}/move_me.txt"
|
685
|
-
mv "#{path2}/move_me.txt", "#{path3}/to_directory/move_me.txt"
|
686
|
-
end
|
687
|
-
end
|
688
|
-
end
|
689
|
-
end
|
690
|
-
|
691
|
-
context 'when files are deleted from the multiple watched directories' do
|
692
|
-
it 'detects the files removal' do
|
693
|
-
fixtures(2) do |path1, path2|
|
694
|
-
if options[:recursive]
|
695
|
-
listener.should_receive(:on_change).once.with do |directories, options|
|
696
|
-
directories.should =~ [path1, path2] && options.should == {:recursive => true}
|
697
|
-
end
|
698
|
-
else
|
699
|
-
listener.should_receive(:on_change).once.with do |directories, options|
|
700
|
-
directories.should =~ [path1, path2] && options.should == {}
|
701
|
-
end
|
702
|
-
end
|
703
|
-
|
704
|
-
touch "#{path1}/unnecessary.txt"
|
705
|
-
touch "#{path2}/unnecessary.txt"
|
706
|
-
|
707
|
-
watch(listener, path1, path2) do
|
708
|
-
rm "#{path1}/unnecessary.txt"
|
709
|
-
rm "#{path2}/unnecessary.txt"
|
710
|
-
end
|
711
|
-
end
|
712
|
-
end
|
713
|
-
end
|
714
|
-
end
|
715
|
-
|
716
|
-
end
|