sass 3.2.19 → 3.3.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/CONTRIBUTING +1 -1
  2. data/MIT-LICENSE +2 -2
  3. data/README.md +13 -14
  4. data/REVISION +1 -1
  5. data/Rakefile +4 -6
  6. data/VERSION +1 -1
  7. data/VERSION_DATE +1 -1
  8. data/VERSION_NAME +1 -1
  9. data/bin/sass +1 -6
  10. data/bin/sass-convert +1 -6
  11. data/bin/scss +1 -6
  12. data/lib/sass/cache_stores/base.rb +0 -2
  13. data/lib/sass/cache_stores/chain.rb +1 -1
  14. data/lib/sass/cache_stores/filesystem.rb +3 -6
  15. data/lib/sass/callbacks.rb +1 -1
  16. data/lib/sass/css.rb +1 -1
  17. data/lib/sass/engine.rb +4 -11
  18. data/lib/sass/error.rb +2 -2
  19. data/lib/sass/exec.rb +10 -40
  20. data/lib/sass/importers/filesystem.rb +15 -52
  21. data/lib/sass/logger/log_level.rb +3 -3
  22. data/lib/sass/media.rb +4 -1
  23. data/lib/sass/plugin.rb +1 -2
  24. data/lib/sass/plugin/compiler.rb +18 -40
  25. data/lib/sass/plugin/staleness_checker.rb +5 -21
  26. data/lib/sass/railtie.rb +0 -1
  27. data/lib/sass/script/funcall.rb +8 -62
  28. data/lib/sass/script/functions.rb +457 -557
  29. data/lib/sass/script/lexer.rb +30 -25
  30. data/lib/sass/script/list.rb +1 -2
  31. data/lib/sass/script/literal.rb +18 -0
  32. data/lib/sass/script/null.rb +1 -4
  33. data/lib/sass/script/operation.rb +1 -0
  34. data/lib/sass/script/parser.rb +35 -42
  35. data/lib/sass/script/string.rb +1 -1
  36. data/lib/sass/script/unary_operation.rb +3 -8
  37. data/lib/sass/scss/parser.rb +14 -33
  38. data/lib/sass/scss/rx.rb +10 -3
  39. data/lib/sass/selector.rb +16 -19
  40. data/lib/sass/selector/sequence.rb +7 -16
  41. data/lib/sass/selector/simple.rb +1 -1
  42. data/lib/sass/selector/simple_sequence.rb +15 -25
  43. data/lib/sass/tree/comment_node.rb +2 -2
  44. data/lib/sass/tree/import_node.rb +2 -9
  45. data/lib/sass/tree/visitors/check_nesting.rb +2 -3
  46. data/lib/sass/tree/visitors/convert.rb +4 -9
  47. data/lib/sass/tree/visitors/cssize.rb +15 -36
  48. data/lib/sass/tree/visitors/perform.rb +20 -23
  49. data/lib/sass/tree/visitors/set_options.rb +0 -8
  50. data/lib/sass/tree/visitors/to_css.rb +1 -0
  51. data/lib/sass/util.rb +2 -120
  52. data/lib/sass/util/multibyte_string_scanner.rb +8 -29
  53. data/test/sass/conversion_test.rb +8 -33
  54. data/test/sass/css2sass_test.rb +0 -19
  55. data/test/sass/engine_test.rb +17 -129
  56. data/test/sass/extend_test.rb +24 -169
  57. data/test/sass/functions_test.rb +73 -93
  58. data/test/sass/plugin_test.rb +11 -72
  59. data/test/sass/script_conversion_test.rb +0 -14
  60. data/test/sass/script_test.rb +1 -40
  61. data/test/sass/scss/css_test.rb +3 -44
  62. data/test/sass/scss/scss_test.rb +3 -134
  63. data/test/sass/util_test.rb +0 -93
  64. data/vendor/listen/CHANGELOG.md +2 -83
  65. data/vendor/listen/Gemfile +1 -8
  66. data/vendor/listen/Guardfile +1 -1
  67. data/vendor/listen/LICENSE +1 -1
  68. data/vendor/listen/README.md +5 -8
  69. data/vendor/listen/lib/listen.rb +5 -7
  70. data/vendor/listen/lib/listen/adapter.rb +29 -76
  71. data/vendor/listen/lib/listen/adapters/darwin.rb +10 -11
  72. data/vendor/listen/lib/listen/adapters/linux.rb +30 -33
  73. data/vendor/listen/lib/listen/adapters/polling.rb +1 -2
  74. data/vendor/listen/lib/listen/adapters/windows.rb +21 -27
  75. data/vendor/listen/lib/listen/directory_record.rb +10 -63
  76. data/vendor/listen/lib/listen/listener.rb +0 -22
  77. data/vendor/listen/lib/listen/multi_listener.rb +0 -22
  78. data/vendor/listen/lib/listen/version.rb +1 -1
  79. data/vendor/listen/listen.gemspec +4 -0
  80. data/vendor/listen/spec/listen/adapter_spec.rb +4 -45
  81. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -6
  82. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -6
  83. data/vendor/listen/spec/listen/adapters/windows_spec.rb +1 -7
  84. data/vendor/listen/spec/listen/directory_record_spec.rb +4 -91
  85. data/vendor/listen/spec/listen/listener_spec.rb +0 -14
  86. data/vendor/listen/spec/listen/multi_listener_spec.rb +1 -19
  87. data/vendor/listen/spec/spec_helper.rb +3 -6
  88. data/vendor/listen/spec/support/adapter_helper.rb +212 -125
  89. data/vendor/listen/spec/support/listeners_helper.rb +1 -13
  90. data/vendor/listen/spec/support/platform_helper.rb +0 -4
  91. metadata +113 -105
  92. checksums.yaml +0 -7
  93. data/lib/sass/util/test.rb +0 -10
  94. data/test/sass/exec_test.rb +0 -86
  95. data/test/sass/results/cached_import_option.css +0 -3
  96. data/test/sass/templates/_cached_import_option_partial.scss +0 -1
  97. data/test/sass/templates/_same_name_different_partiality.scss +0 -1
  98. data/test/sass/templates/bork5.sass +0 -3
  99. data/test/sass/templates/cached_import_option.scss +0 -3
  100. data/test/sass/templates/same_name_different_ext.sass +0 -2
  101. data/test/sass/templates/same_name_different_ext.scss +0 -1
  102. data/test/sass/templates/same_name_different_partiality.scss +0 -1
  103. data/test/sass/templates/subdir/import_up1.scss +0 -1
  104. data/test/sass/templates/subdir/import_up2.scss +0 -1
  105. data/vendor/listen/CONTRIBUTING.md +0 -38
  106. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -112
  107. data/vendor/listen/lib/listen/dependency_manager.rb +0 -126
  108. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  109. data/vendor/listen/spec/listen/dependency_manager_spec.rb +0 -107
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../test_helper'
3
3
  require 'pathname'
4
- require 'tmpdir'
5
4
 
6
5
  class UtilTest < Test::Unit::TestCase
7
6
  include Sass::Util
@@ -244,14 +243,6 @@ class UtilTest < Test::Unit::TestCase
244
243
  test[['foo ', 1, "\n bar\n", [2, 3, 4], "\n baz"]]
245
244
  end
246
245
 
247
- def nested_caller_info_fn
248
- caller_info
249
- end
250
-
251
- def double_nested_caller_info_fn
252
- nested_caller_info_fn
253
- end
254
-
255
246
  def test_caller_info
256
247
  assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle'"))
257
248
  assert_equal(["/tmp/foo.rb", 12, nil], caller_info("/tmp/foo.rb:12"))
@@ -259,22 +250,6 @@ class UtilTest < Test::Unit::TestCase
259
250
  assert_equal(["", 12, "boop"], caller_info(":12: in `boop'"))
260
251
  assert_equal(["/tmp/foo.rb", -12, "fizzle"], caller_info("/tmp/foo.rb:-12: in `fizzle'"))
261
252
  assert_equal(["/tmp/foo.rb", 12, "fizzle"], caller_info("/tmp/foo.rb:12: in `fizzle {}'"))
262
-
263
- info = nested_caller_info_fn
264
- assert_equal(__FILE__, info[0])
265
- assert_equal("test_caller_info", info[2])
266
-
267
- info = proc {nested_caller_info_fn}.call
268
- assert_equal(__FILE__, info[0])
269
- assert_match(/^(block in )?test_caller_info$/, info[2])
270
-
271
- info = double_nested_caller_info_fn
272
- assert_equal(__FILE__, info[0])
273
- assert_equal("double_nested_caller_info_fn", info[2])
274
-
275
- info = proc {double_nested_caller_info_fn}.call
276
- assert_equal(__FILE__, info[0])
277
- assert_equal("double_nested_caller_info_fn", info[2])
278
253
  end
279
254
 
280
255
  def test_version_gt
@@ -311,72 +286,4 @@ class UtilTest < Test::Unit::TestCase
311
286
  "UtilTest::FooBar must implement #foo") {FooBar.new.foo}
312
287
  end
313
288
 
314
- def test_atomic_writes
315
- # when using normal writes, this test fails about 90% of the time.
316
- filename = File.join(Dir.tmpdir, "test_atomic")
317
- 5.times do
318
- writes_to_perform = %w(1 2 3 4 5 6 7 8 9).map {|i| "#{i}\n" * 100_000}
319
- threads = writes_to_perform.map do |to_write|
320
- Thread.new do
321
- # To see this test fail with a normal write,
322
- # change to the standard file open mechanism:
323
- # open(filename, "w") do |f|
324
- atomic_create_and_write_file(filename) do |f|
325
- f.write(to_write)
326
- end
327
- end
328
- end
329
- loop do
330
- contents = File.exist?(filename) ? File.read(filename) : nil
331
- next if contents.nil? || contents.size == 0
332
- unless writes_to_perform.include?(contents)
333
- if contents.size != writes_to_perform.first.size
334
- fail "Incomplete write detected: was #{contents.size} characters, " +
335
- "should have been #{writes_to_perform.first.size}"
336
- else
337
- fail "Corrupted read/write detected"
338
- end
339
- end
340
- break if threads.all? {|t| !t.alive?}
341
- end
342
- threads.each {|t| t.join}
343
- end
344
- end
345
-
346
- def test_atomic_write_permissions
347
- atomic_filename = File.join(Dir.tmpdir, "test_atomic_perms.atomic")
348
- normal_filename = File.join(Dir.tmpdir, "test_atomic_perms.normal")
349
- atomic_create_and_write_file(atomic_filename) {|f| f.write("whatever\n") }
350
- open(normal_filename, "wb") {|f| f.write("whatever\n") }
351
- assert_equal File.stat(normal_filename).mode.to_s(8), File.stat(atomic_filename).mode.to_s(8)
352
- ensure
353
- File.unlink(atomic_filename) rescue nil
354
- File.unlink(normal_filename) rescue nil
355
- end
356
-
357
- def test_atomic_writes_respect_umask
358
- atomic_filename = File.join(Dir.tmpdir, "test_atomic_perms.atomic")
359
- atomic_create_and_write_file(atomic_filename) do |f|
360
- f.write("whatever\n")
361
- end
362
- assert_equal 0, File.stat(atomic_filename).mode & File.umask
363
- ensure
364
- File.unlink(atomic_filename)
365
- end
366
-
367
- class FakeError < RuntimeError; end
368
-
369
- def test_atomic_writes_handles_exceptions
370
- filename = File.join(Dir.tmpdir, "test_atomic_exception")
371
- FileUtils.rm_f(filename)
372
- tmp_filename = nil
373
- assert_raises FakeError do
374
- atomic_create_and_write_file(filename) do |f|
375
- tmp_filename = f.path
376
- raise FakeError.new "Borken"
377
- end
378
- end
379
- assert !File.exist?(filename)
380
- assert !File.exist?(tmp_filename)
381
- end
382
289
  end
@@ -1,69 +1,3 @@
1
- ## 0.7.3 - February 24, 2013
2
-
3
- ### Bug fix
4
-
5
- - [#88] Update wdm dependency. (fixed by [@mrbinky3000][])
6
- - [#78] Depend on latest rb-inotify. (fixed by [@mbj][])
7
-
8
- ## 0.7.2 - January 11, 2013
9
-
10
- ### Bug fix
11
-
12
- - [#76] Exception on filename which is not in UTF-8. (fixed by [@piotr-sokolowski][])
13
-
14
- ## 0.7.1 - January 6, 2013
15
-
16
- ### Bug fix
17
-
18
- - [#75] Default high precision off if the mtime call fails. (fixed by [@zanker][])
19
-
20
- ## 0.7.0 - December 29, 2012
21
-
22
- ### Bug fixes
23
-
24
- - [#73] Rescue Errno::EOPNOTSUPP on sha1_checksum generation. (fixed by [@thibaudgg][])
25
-
26
- ### New feature
27
-
28
- - Add support for *BSD with rb-kqueue. ([@mat813][])
29
-
30
- ## 0.6.0 - November 21, 2012
31
-
32
- ### New feature
33
-
34
- - Add bang versions for filter and ignore listener methods. ([@tarsolya][])
35
-
36
- ## 0.5.3 - October 3, 2012
37
-
38
- ### Bug fixes
39
-
40
- - [#65] Fix ruby warning in adapter.rb. (fixed by [@vongruenigen][])
41
- - [#64] ENXIO raised when hashing UNIX domain socket file. (fixed by [@sunaku][])
42
-
43
- ## 0.5.2 - Septemper 23, 2012
44
-
45
- ### Bug fix
46
-
47
- - [#62] Fix double change callback with polling adapter. (fixed by [@thibaudgg][])
48
-
49
- ## 0.5.1 - Septemper 18, 2012
50
-
51
- ### Bug fix
52
-
53
- - [#61] Fix a synchronisation bug that caused constant fallback to polling. (fixed by [@Maher4Ever][])
54
-
55
- ## 0.5.0 - Septemper 1, 2012
56
-
57
- ### New features
58
-
59
- - Add a dependency manager to handle platform-specific gems. So there is no need anymore to install
60
- extra gems which will never be used on the user system. ([@Maher4Ever][])
61
- - Add a manual reporting mode to the adapters. ([@Maher4Ever][])
62
-
63
- ### Improvements
64
-
65
- - [#28] Enhance the speed of detecting changes on Windows by using the [WDM][] library. ([@Maher4Ever][])
66
-
67
1
  ## 0.4.7 - June 27, 2012
68
2
 
69
3
  ### Bug fixes
@@ -194,16 +128,8 @@
194
128
  [#21]: https://github.com/guard/listen/issues/21
195
129
  [#24]: https://github.com/guard/listen/issues/24
196
130
  [#27]: https://github.com/guard/listen/issues/27
197
- [#28]: https://github.com/guard/listen/issues/28
198
131
  [#32]: https://github.com/guard/listen/issues/32
199
- [#41]: https://github.com/guard/listen/issues/41
200
- [#61]: https://github.com/guard/listen/issues/61
201
- [#62]: https://github.com/guard/listen/issues/62
202
- [#64]: https://github.com/guard/listen/issues/64
203
- [#65]: https://github.com/guard/listen/issues/65
204
- [#73]: https://github.com/guard/listen/issues/73
205
- [#75]: https://github.com/guard/listen/issues/75
206
- [#76]: https://github.com/guard/listen/issues/76
132
+ [#39]: https://github.com/guard/listen/issues/39
207
133
  [@Maher4Ever]: https://github.com/Maher4Ever
208
134
  [@dkubb]: https://github.com/dkubb
209
135
  [@ebroder]: https://github.com/ebroder
@@ -212,17 +138,10 @@
212
138
  [@daemonza]: https://github.com/daemonza
213
139
  [@fny]: https://github.com/fny
214
140
  [@markiz]: https://github.com/markiz
215
- [@mat813]: https://github.com/mat813
216
141
  [@napcs]: https://github.com/napcs
217
142
  [@netzpirat]: https://github.com/netzpirat
218
143
  [@nex3]: https://github.com/nex3
219
- [@piotr-sokolowski]: https://github.com/piotr-sokolowski
220
144
  [@rymai]: https://github.com/rymai
221
145
  [@scottdavis]: https://github.com/scottdavis
222
- [@sunaku]: https://github.com/sunaku
223
146
  [@textgoeshere]: https://github.com/textgoeshere
224
- [@thibaudgg]: https://github.com/thibaudgg
225
- [@tarsolya]: https://github.com/tarsolya
226
- [@vongruenigen]: https://github.com/vongruenigen
227
- [@zanker]: https://github.com/zanker
228
- [WDM]: https://github.com/Maher4Ever/wdm
147
+ [@thibaudgg]: https://github.com/thibaudgg
@@ -1,16 +1,9 @@
1
- require 'rbconfig'
2
-
3
1
  source :rubygems
4
2
 
5
3
  gemspec
6
4
 
7
5
  gem 'rake'
8
6
 
9
- gem 'rb-kqueue', '~> 0.2' if RbConfig::CONFIG['target_os'] =~ /freebsd/i
10
- gem 'rb-fsevent', '~> 0.9.1' if RbConfig::CONFIG['target_os'] =~ /darwin(1.+)?$/i
11
- gem 'rb-inotify', '~> 0.9.0' if RbConfig::CONFIG['target_os'] =~ /linux/i
12
- gem 'wdm', '~> 0.0.3' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
13
-
14
7
  group :development do
15
8
  platform :ruby do
16
9
  gem 'coolline'
@@ -27,4 +20,4 @@ end
27
20
 
28
21
  group :test do
29
22
  gem 'rspec'
30
- end
23
+ end
@@ -1,4 +1,4 @@
1
- guard :rspec, :all_on_start => false, :all_after_pass => false do
1
+ guard :rspec, :all_on_start => false, :all_after_pass => false, :cli => '--fail-fast --format doc' do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
4
  watch('spec/support/adapter_helper.rb') { "spec/listen/adapters" }
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Thibaud Guillaume-Gentil
1
+ Copyright (c) 2012 Thibaud Guillaume-Gentil
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -6,10 +6,10 @@ The Listen gem listens to file modifications and notifies you about the changes.
6
6
 
7
7
  * Works everywhere!
8
8
  * Supports watching multiple directories from a single listener.
9
- * OS-specific adapters for Mac OS X 10.6+, Linux, *BSD and Windows.
9
+ * OS-specific adapters for Mac OS X 10.6+, Linux and Windows.
10
10
  * Automatic fallback to polling if OS-specific adapter doesn't work.
11
- * Detects file modification, addition and removal.
12
- * Checksum comparison for modifications made under the same second.
11
+ * Detects files modification, addidation and removal.
12
+ * Checksum comparaison for modifications made under the same second.
13
13
  * Allows supplying regexp-patterns to ignore and filter paths for better results.
14
14
  * Tested on all Ruby environments via [travis-ci](http://travis-ci.org/guard/listen).
15
15
 
@@ -215,8 +215,6 @@ with a directory-separator, otherwise they won't work as expected.
215
215
  As an example: to ignore the `build` directory in a C-project, use `%r{build/}`
216
216
  and not `%r{/build/}`.
217
217
 
218
- Use `#filter!` and `#ignore!` methods to overwrites default patterns.
219
-
220
218
  ### Non-blocking listening to changes
221
219
 
222
220
  Starting a listener blocks the current thread by default. That means any code after the
@@ -242,7 +240,7 @@ block execution. See the "Block API" section for an example.
242
240
  ## Listen adapters
243
241
 
244
242
  The Listen gem has a set of adapters to notify it when there are changes.
245
- There are 3 OS-specific adapters to support Mac, Linux, *BSD and Windows. These adapters are fast
243
+ There are 3 OS-specific adapters to support Mac, Linux and Windows. These adapters are fast
246
244
  as they use some system-calls to implement the notifying function.
247
245
 
248
246
  There is also a polling adapter which is a cross-platform adapter and it will
@@ -253,6 +251,7 @@ want to force the use of the polling adapter, either use the `:force_polling` op
253
251
  while initializing the listener or call the `force_polling` method on your listener
254
252
  before starting it.
255
253
 
254
+ <a name="fallback"/>
256
255
  ## Polling fallback
257
256
 
258
257
  When a OS-specific adapter doesn't work the Listen gem automatically falls back to the polling adapter.
@@ -287,7 +286,6 @@ For questions please join us in our [Google group](http://groups.google.com/grou
287
286
  * [Michael Kessler (netzpirat)][] for having written the [initial specs](https://github.com/guard/listen/commit/1e457b13b1bb8a25d2240428ce5ed488bafbed1f).
288
287
  * [Travis Tilley (ttilley)][] for this awesome work on [fssm][] & [rb-fsevent][].
289
288
  * [Nathan Weizenbaum (nex3)][] for [rb-inotify][], a thorough inotify wrapper.
290
- * [Mathieu Arnold (mat813)][] for [rb-kqueue][], a simple kqueue wrapper.
291
289
  * [stereobooster][] for [rb-fchange][], windows support wouldn't exist without him.
292
290
  * [Yehuda Katz (wycats)][] for [vigilo][], that has been a great source of inspiration.
293
291
 
@@ -306,7 +304,6 @@ For questions please join us in our [Google group](http://groups.google.com/grou
306
304
  [Travis Tilley (ttilley)]: https://github.com/ttilley
307
305
  [fssm]: https://github.com/ttilley/fssm
308
306
  [rb-fsevent]: https://github.com/thibaudgg/rb-fsevent
309
- [Mathieu Arnold (mat813)]: https://github.com/mat813
310
307
  [Nathan Weizenbaum (nex3)]: https://github.com/nex3
311
308
  [rb-inotify]: https://github.com/nex3/rb-inotify
312
309
  [stereobooster]: https://github.com/stereobooster
@@ -1,16 +1,14 @@
1
1
  module Listen
2
2
 
3
- autoload :Turnstile, 'listen/turnstile'
4
- autoload :Listener, 'listen/listener'
5
- autoload :MultiListener, 'listen/multi_listener'
6
- autoload :DirectoryRecord, 'listen/directory_record'
7
- autoload :DependencyManager, 'listen/dependency_manager'
8
- autoload :Adapter, 'listen/adapter'
3
+ autoload :Turnstile, 'listen/turnstile'
4
+ autoload :Listener, 'listen/listener'
5
+ autoload :MultiListener, 'listen/multi_listener'
6
+ autoload :DirectoryRecord, 'listen/directory_record'
7
+ autoload :Adapter, 'listen/adapter'
9
8
 
10
9
  module Adapters
11
10
  autoload :Darwin, 'listen/adapters/darwin'
12
11
  autoload :Linux, 'listen/adapters/linux'
13
- autoload :BSD, 'listen/adapters/bsd'
14
12
  autoload :Windows, 'listen/adapters/windows'
15
13
  autoload :Polling, 'listen/adapters/polling'
16
14
  end
@@ -10,15 +10,8 @@ module Listen
10
10
  # The default delay between checking for changes.
11
11
  DEFAULT_LATENCY = 0.25
12
12
 
13
- # The default warning message when there is a missing dependency.
14
- MISSING_DEPENDENCY_MESSAGE = <<-EOS.gsub(/^\s*/, '')
15
- For a better performance, it's recommended that you satisfy the missing dependency.
16
- EOS
17
-
18
13
  # The default warning message when falling back to polling adapter.
19
- POLLING_FALLBACK_MESSAGE = <<-EOS.gsub(/^\s*/, '')
20
- Listen will be polling changes. Learn more at https://github.com/guard/listen#polling-fallback.
21
- EOS
14
+ POLLING_FALLBACK_MESSAGE = "WARNING: Listen has fallen back to polling, learn more at https://github.com/guard/listen#fallback."
22
15
 
23
16
  # Selects the appropriate adapter implementation for the
24
17
  # current OS and initializes it.
@@ -38,28 +31,18 @@ module Listen
38
31
  def self.select_and_initialize(directories, options = {}, &callback)
39
32
  return Adapters::Polling.new(directories, options, &callback) if options.delete(:force_polling)
40
33
 
41
- warning = ''
42
-
43
- begin
44
- if Adapters::Darwin.usable_and_works?(directories, options)
45
- return Adapters::Darwin.new(directories, options, &callback)
46
- elsif Adapters::Linux.usable_and_works?(directories, options)
47
- return Adapters::Linux.new(directories, options, &callback)
48
- elsif Adapters::BSD.usable_and_works?(directories, options)
49
- return Adapters::BSD.new(directories, options, &callback)
50
- elsif Adapters::Windows.usable_and_works?(directories, options)
51
- return Adapters::Windows.new(directories, options, &callback)
34
+ if Adapters::Darwin.usable_and_works?(directories, options)
35
+ Adapters::Darwin.new(directories, options, &callback)
36
+ elsif Adapters::Linux.usable_and_works?(directories, options)
37
+ Adapters::Linux.new(directories, options, &callback)
38
+ elsif Adapters::Windows.usable_and_works?(directories, options)
39
+ Adapters::Windows.new(directories, options, &callback)
40
+ else
41
+ unless options[:polling_fallback_message] == false
42
+ Kernel.warn(options[:polling_fallback_message] || POLLING_FALLBACK_MESSAGE)
52
43
  end
53
- rescue DependencyManager::Error => e
54
- warning += e.message + "\n" + MISSING_DEPENDENCY_MESSAGE
55
- end
56
-
57
- unless options[:polling_fallback_message] == false
58
- warning += options[:polling_fallback_message] || POLLING_FALLBACK_MESSAGE
59
- Kernel.warn "[Listen warning]:\n" + warning.gsub(/^(.*)/, ' \1')
44
+ Adapters::Polling.new(directories, options, &callback)
60
45
  end
61
-
62
- Adapters::Polling.new(directories, options, &callback)
63
46
  end
64
47
 
65
48
  # Initializes the adapter.
@@ -67,7 +50,6 @@ module Listen
67
50
  # @param [String, Array<String>] directories the directories to watch
68
51
  # @param [Hash] options the adapter options
69
52
  # @option options [Float] latency the delay between checking for changes in seconds
70
- # @option options [Boolean] report_changes whether or not to automatically report changes (run the callback)
71
53
  #
72
54
  # @yield [changed_dirs, options] callback Callback called when a change happens
73
55
  # @yieldparam [Array<String>] changed_dirs the changed directories
@@ -78,13 +60,12 @@ module Listen
78
60
  def initialize(directories, options = {}, &callback)
79
61
  @directories = Array(directories)
80
62
  @callback = callback
63
+ @latency ||= DEFAULT_LATENCY
64
+ @latency = options[:latency] if options[:latency]
81
65
  @paused = false
82
66
  @mutex = Mutex.new
83
67
  @changed_dirs = Set.new
84
68
  @turnstile = Turnstile.new
85
- @latency ||= DEFAULT_LATENCY
86
- @latency = options[:latency] if options[:latency]
87
- @report_changes = options[:report_changes].nil? ? true : options[:report_changes]
88
69
  end
89
70
 
90
71
  # Starts the adapter.
@@ -111,37 +92,12 @@ module Listen
111
92
  end
112
93
 
113
94
  # Blocks the main thread until the poll thread
114
- # runs the callback.
95
+ # calls the callback.
115
96
  #
116
97
  def wait_for_callback
117
98
  @turnstile.wait unless @paused
118
99
  end
119
100
 
120
- # Blocks the main thread until N changes are
121
- # detected.
122
- #
123
- def wait_for_changes(goal = 0)
124
- changes = 0
125
-
126
- loop do
127
- @mutex.synchronize { changes = @changed_dirs.size }
128
-
129
- return if @paused || @stop
130
- return if changes >= goal
131
-
132
- sleep(@latency)
133
- end
134
- end
135
-
136
- # Checks if the adapter is usable on the current OS.
137
- #
138
- # @return [Boolean] whether usable or not
139
- #
140
- def self.usable?
141
- load_depenencies
142
- dependencies_loaded?
143
- end
144
-
145
101
  # Checks if the adapter is usable and works on the current OS.
146
102
  #
147
103
  # @param [String, Array<String>] directories the directories to watch
@@ -168,7 +124,7 @@ module Listen
168
124
  def self.works?(directory, options = {})
169
125
  work = false
170
126
  test_file = "#{directory}/.listen_test"
171
- callback = lambda { |*| work = true }
127
+ callback = lambda { |changed_dirs, options| work = true }
172
128
  adapter = self.new(directory, options, &callback)
173
129
  adapter.start(false)
174
130
 
@@ -184,30 +140,27 @@ module Listen
184
140
  adapter.stop if adapter && adapter.started?
185
141
  end
186
142
 
187
- # Runs the callback and passes it the changes if there are any.
188
- #
189
- def report_changes
190
- changed_dirs = nil
191
-
192
- @mutex.synchronize do
193
- return if @changed_dirs.empty?
194
- changed_dirs = @changed_dirs.to_a
195
- @changed_dirs.clear
196
- end
197
-
198
- @callback.call(changed_dirs, {})
199
- @turnstile.signal
200
- end
201
-
202
143
  private
203
144
 
204
145
  # Polls changed directories and reports them back
205
146
  # when there are changes.
206
147
  #
207
- def poll_changed_dirs
148
+ # @option [Boolean] recursive whether or not to pass the recursive option to the callback
149
+ #
150
+ def poll_changed_dirs(recursive = false)
208
151
  until @stop
209
152
  sleep(@latency)
210
- report_changes
153
+ next if @changed_dirs.empty?
154
+
155
+ changed_dirs = []
156
+
157
+ @mutex.synchronize do
158
+ changed_dirs = @changed_dirs.to_a
159
+ @changed_dirs.clear
160
+ end
161
+
162
+ @callback.call(changed_dirs, recursive ? {:recursive => recursive} : {})
163
+ @turnstile.signal
211
164
  end
212
165
  end
213
166
  end