listen 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +11 -0
- data/README.md +4 -2
- data/lib/listen.rb +1 -0
- data/lib/listen/adapter.rb +2 -0
- data/lib/listen/adapters/bsd.rb +112 -0
- data/lib/listen/directory_record.rb +1 -1
- data/lib/listen/version.rb +1 -1
- metadata +3 -6
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 0.7.0 - December 29, 2012
|
2
|
+
|
3
|
+
### Bug fixes
|
4
|
+
|
5
|
+
- [#73] Rescue Errno::EOPNOTSUPP on sha1_checksum generation. (fixed by [@thibaudgg][])
|
6
|
+
|
7
|
+
### New feature
|
8
|
+
|
9
|
+
- Add support for *BSD with rb-kqueue. ([@mat813][])
|
10
|
+
|
1
11
|
## 0.6.0 - November 21, 2012
|
2
12
|
|
3
13
|
### New feature
|
@@ -180,6 +190,7 @@
|
|
180
190
|
[@daemonza]: https://github.com/daemonza
|
181
191
|
[@fny]: https://github.com/fny
|
182
192
|
[@markiz]: https://github.com/markiz
|
193
|
+
[@mat813]: https://github.com/mat813
|
183
194
|
[@napcs]: https://github.com/napcs
|
184
195
|
[@netzpirat]: https://github.com/netzpirat
|
185
196
|
[@nex3]: https://github.com/nex3
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ 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 and Windows.
|
9
|
+
* OS-specific adapters for Mac OS X 10.6+, Linux, *BSD and Windows.
|
10
10
|
* Automatic fallback to polling if OS-specific adapter doesn't work.
|
11
11
|
* Detects file modification, addition and removal.
|
12
12
|
* Checksum comparison for modifications made under the same second.
|
@@ -242,7 +242,7 @@ block execution. See the "Block API" section for an example.
|
|
242
242
|
## Listen adapters
|
243
243
|
|
244
244
|
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 and Windows. These adapters are fast
|
245
|
+
There are 3 OS-specific adapters to support Mac, Linux, *BSD and Windows. These adapters are fast
|
246
246
|
as they use some system-calls to implement the notifying function.
|
247
247
|
|
248
248
|
There is also a polling adapter which is a cross-platform adapter and it will
|
@@ -287,6 +287,7 @@ For questions please join us in our [Google group](http://groups.google.com/grou
|
|
287
287
|
* [Michael Kessler (netzpirat)][] for having written the [initial specs](https://github.com/guard/listen/commit/1e457b13b1bb8a25d2240428ce5ed488bafbed1f).
|
288
288
|
* [Travis Tilley (ttilley)][] for this awesome work on [fssm][] & [rb-fsevent][].
|
289
289
|
* [Nathan Weizenbaum (nex3)][] for [rb-inotify][], a thorough inotify wrapper.
|
290
|
+
* [Mathieu Arnold (mat813)][] for [rb-kqueue][], a simple kqueue wrapper.
|
290
291
|
* [stereobooster][] for [rb-fchange][], windows support wouldn't exist without him.
|
291
292
|
* [Yehuda Katz (wycats)][] for [vigilo][], that has been a great source of inspiration.
|
292
293
|
|
@@ -305,6 +306,7 @@ For questions please join us in our [Google group](http://groups.google.com/grou
|
|
305
306
|
[Travis Tilley (ttilley)]: https://github.com/ttilley
|
306
307
|
[fssm]: https://github.com/ttilley/fssm
|
307
308
|
[rb-fsevent]: https://github.com/thibaudgg/rb-fsevent
|
309
|
+
[Mathieu Arnold (mat813)]: https://github.com/mat813
|
308
310
|
[Nathan Weizenbaum (nex3)]: https://github.com/nex3
|
309
311
|
[rb-inotify]: https://github.com/nex3/rb-inotify
|
310
312
|
[stereobooster]: https://github.com/stereobooster
|
data/lib/listen.rb
CHANGED
@@ -10,6 +10,7 @@ module Listen
|
|
10
10
|
module Adapters
|
11
11
|
autoload :Darwin, 'listen/adapters/darwin'
|
12
12
|
autoload :Linux, 'listen/adapters/linux'
|
13
|
+
autoload :BSD, 'listen/adapters/bsd'
|
13
14
|
autoload :Windows, 'listen/adapters/windows'
|
14
15
|
autoload :Polling, 'listen/adapters/polling'
|
15
16
|
end
|
data/lib/listen/adapter.rb
CHANGED
@@ -45,6 +45,8 @@ module Listen
|
|
45
45
|
return Adapters::Darwin.new(directories, options, &callback)
|
46
46
|
elsif Adapters::Linux.usable_and_works?(directories, options)
|
47
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)
|
48
50
|
elsif Adapters::Windows.usable_and_works?(directories, options)
|
49
51
|
return Adapters::Windows.new(directories, options, &callback)
|
50
52
|
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module Listen
|
2
|
+
module Adapters
|
3
|
+
|
4
|
+
# Listener implementation for BSD's `kqueue`.
|
5
|
+
#
|
6
|
+
class BSD < Adapter
|
7
|
+
extend DependencyManager
|
8
|
+
|
9
|
+
# Declare the adapter's dependencies
|
10
|
+
dependency 'rb-kqueue', '~> 0.2'
|
11
|
+
|
12
|
+
# Watched kqueue events
|
13
|
+
#
|
14
|
+
# @see http://www.freebsd.org/cgi/man.cgi?query=kqueue
|
15
|
+
# @see https://github.com/nex3/rb-kqueue/blob/master/lib/rb-kqueue/queue.rb
|
16
|
+
#
|
17
|
+
EVENTS = [ :delete, :write, :extend, :attrib, :link, :rename, :revoke ]
|
18
|
+
|
19
|
+
# Initializes the Adapter. See {Listen::Adapter#initialize} for
|
20
|
+
# more info.
|
21
|
+
#
|
22
|
+
def initialize(directories, options = {}, &callback)
|
23
|
+
super
|
24
|
+
@kqueue = init_kqueue
|
25
|
+
end
|
26
|
+
|
27
|
+
# Starts the adapter.
|
28
|
+
#
|
29
|
+
# @param [Boolean] blocking whether or not to block the current thread after starting
|
30
|
+
#
|
31
|
+
def start(blocking = true)
|
32
|
+
@mutex.synchronize do
|
33
|
+
return if @stop == false
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
@kqueue_thread = Thread.new do
|
38
|
+
until @stop
|
39
|
+
@kqueue.poll
|
40
|
+
sleep(@latency)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
@poll_thread = Thread.new { poll_changed_dirs } if @report_changes
|
44
|
+
|
45
|
+
@kqueue_thread.join if blocking
|
46
|
+
end
|
47
|
+
|
48
|
+
# Stops the adapter.
|
49
|
+
#
|
50
|
+
def stop
|
51
|
+
@mutex.synchronize do
|
52
|
+
return if @stop == true
|
53
|
+
super
|
54
|
+
end
|
55
|
+
|
56
|
+
@kqueue.stop
|
57
|
+
Thread.kill(@kqueue_thread) if @kqueue_thread
|
58
|
+
@poll_thread.join if @poll_thread
|
59
|
+
end
|
60
|
+
|
61
|
+
# Checks if the adapter is usable on the current OS.
|
62
|
+
#
|
63
|
+
# @return [Boolean] whether usable or not
|
64
|
+
#
|
65
|
+
def self.usable?
|
66
|
+
return false unless RbConfig::CONFIG['target_os'] =~ /freebsd/i
|
67
|
+
super
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
# Initializes a kqueue Queue and adds a watcher for each files in
|
73
|
+
# the directories passed to the adapter.
|
74
|
+
#
|
75
|
+
# @return [INotify::Notifier] initialized kqueue
|
76
|
+
#
|
77
|
+
def init_kqueue
|
78
|
+
require 'find'
|
79
|
+
|
80
|
+
callback = lambda do |event|
|
81
|
+
path = event.watcher.path
|
82
|
+
@mutex.synchronize do
|
83
|
+
# kqueue watches everything, but Listen only needs the
|
84
|
+
# directory where stuffs happens.
|
85
|
+
@changed_dirs << (File.directory?(path) ? path : File.dirname(path))
|
86
|
+
|
87
|
+
# If it is a directory, and it has a write flag, it means a
|
88
|
+
# file has been added so find out which and deal with it.
|
89
|
+
# No need to check for removed file, kqueue will forget them
|
90
|
+
# when the vfs does..
|
91
|
+
if File.directory?(path) && !(event.flags & [:write]).empty?
|
92
|
+
queue = event.watcher.queue
|
93
|
+
Find.find(path) do |file|
|
94
|
+
unless queue.watchers.detect {|k,v| v.path == file.to_s}
|
95
|
+
queue.watch_file(file, *EVENTS, &callback)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
KQueue::Queue.new.tap do |queue|
|
103
|
+
@directories.each do |directory|
|
104
|
+
Find.find(directory) do |path|
|
105
|
+
queue.watch_file(path, *EVENTS, &callback)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/lib/listen/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: listen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-12-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -38,6 +38,7 @@ extensions: []
|
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
40
|
- lib/listen/adapter.rb
|
41
|
+
- lib/listen/adapters/bsd.rb
|
41
42
|
- lib/listen/adapters/darwin.rb
|
42
43
|
- lib/listen/adapters/linux.rb
|
43
44
|
- lib/listen/adapters/polling.rb
|
@@ -64,9 +65,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
65
|
- - ! '>='
|
65
66
|
- !ruby/object:Gem::Version
|
66
67
|
version: '0'
|
67
|
-
segments:
|
68
|
-
- 0
|
69
|
-
hash: -2035972010079293192
|
70
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
69
|
none: false
|
72
70
|
requirements:
|
@@ -80,4 +78,3 @@ signing_key:
|
|
80
78
|
specification_version: 3
|
81
79
|
summary: Listen to file modifications
|
82
80
|
test_files: []
|
83
|
-
has_rdoc:
|