listen 0.7.3 → 1.0.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +70 -35
- data/README.md +93 -76
- data/lib/listen.rb +34 -19
- data/lib/listen/adapter.rb +179 -81
- data/lib/listen/adapters/bsd.rb +27 -64
- data/lib/listen/adapters/darwin.rb +21 -58
- data/lib/listen/adapters/linux.rb +23 -55
- data/lib/listen/adapters/polling.rb +25 -34
- data/lib/listen/adapters/windows.rb +50 -46
- data/lib/listen/directory_record.rb +88 -58
- data/lib/listen/listener.rb +111 -37
- data/lib/listen/multi_listener.rb +5 -133
- data/lib/listen/turnstile.rb +9 -5
- data/lib/listen/version.rb +1 -1
- metadata +69 -22
- data/lib/listen/dependency_manager.rb +0 -126
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5ddde18cc71f8d339471f213dba615ae73e37065
|
4
|
+
data.tar.gz: c8c634ac2be8bcf0187eb647052b6386e5136931
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4a84e00be4585046590e28f2a8020336c8cb6ad1da212b93354ebee37efea5dc6077586cc3d242a69526e5dbd05eb486240b6645a7120f6fd343c560af08bef3
|
7
|
+
data.tar.gz: 57b2e4b3d73c702d4458a4f6bb62ae36a70bbb69c334fabc01181bcc7173c192a706974691126f175f107c947f1d538cbf85ea3278e6417a729f100f04687094
|
data/CHANGELOG.md
CHANGED
@@ -1,56 +1,78 @@
|
|
1
|
-
## 0.
|
1
|
+
## 1.0.0 - April 20, 2013
|
2
2
|
|
3
3
|
### Bug fix
|
4
4
|
|
5
|
-
- [#
|
6
|
-
|
5
|
+
- [#93][] Remove dependency operator in the "gem install" message. (reported by [@scottdavis][], fixed by [@rymai][])
|
6
|
+
|
7
|
+
### Changes & deprecations
|
8
|
+
|
9
|
+
- [#98][] `Listen.to` does not block the current thread anymore. Use `Listen.to!` if you want the old behavior back. ([@rymai][])
|
10
|
+
- [#98][] `Listen::Listener#start` does not block the current thread anymore. Use `Listen::Listener#start!` if you want the old behavior back. ([@rymai][])
|
11
|
+
- [#98][] `Listen::Listener#start`'s `blocking` parameter is deprecated. ([@rymai][])
|
12
|
+
|
13
|
+
### Improvements
|
14
|
+
|
15
|
+
- [#98][] New method: `Listen.to!` which blocks the current thread. ([@rymai][])
|
16
|
+
- [#98][] New method: `Listen::Listener#start!` to start the listener and block the current thread. ([@martikaljuve][] & [@rymai][])
|
17
|
+
- [#95][] Make `Listen::Listener` capable of listening to multiple directories, deprecates `Listen::MultiListener`. ([@rymai][])
|
18
|
+
- [#85][] Compute the SHA1 sum only for regular files. ([@antifuchs][])
|
19
|
+
- New methods: `Listen::Adapter#pause`, `Listen::Adapter#unpause` and `Listen::Adapter#paused?`. ([@rymai][])
|
20
|
+
- Refactor `Listen::DirectoryRecord` internals. ([@rymai][])
|
21
|
+
- Refactor `Listen::DependencyManager` internals. ([@rymai][])
|
22
|
+
|
23
|
+
## 0.7.3 - February 24, 2013
|
24
|
+
|
25
|
+
### Bug fixes
|
26
|
+
|
27
|
+
- [#88][] Update wdm dependency. ([@mrbinky3000][])
|
28
|
+
- [#78][] Depend on latest rb-inotify. ([@mbj][])
|
7
29
|
|
8
30
|
## 0.7.2 - January 11, 2013
|
9
31
|
|
10
32
|
### Bug fix
|
11
33
|
|
12
|
-
- [#76] Exception on filename which is not in UTF-8. (
|
34
|
+
- [#76][] Exception on filename which is not in UTF-8. ([@piotr-sokolowski][])
|
13
35
|
|
14
36
|
## 0.7.1 - January 6, 2013
|
15
37
|
|
16
38
|
### Bug fix
|
17
39
|
|
18
|
-
- [#75] Default high precision off if the mtime call fails. (
|
40
|
+
- [#75][] Default high precision off if the mtime call fails. ([@zanker][])
|
19
41
|
|
20
42
|
## 0.7.0 - December 29, 2012
|
21
43
|
|
22
|
-
### Bug
|
44
|
+
### Bug fix
|
23
45
|
|
24
|
-
- [#73] Rescue Errno::EOPNOTSUPP on sha1_checksum generation. (
|
46
|
+
- [#73][] Rescue Errno::EOPNOTSUPP on sha1_checksum generation. ([@thibaudgg][])
|
25
47
|
|
26
48
|
### New feature
|
27
49
|
|
28
|
-
- Add support for *BSD with rb-kqueue. ([@mat813][])
|
50
|
+
- [#72][] Add support for *BSD with rb-kqueue. ([@mat813][])
|
29
51
|
|
30
52
|
## 0.6.0 - November 21, 2012
|
31
53
|
|
32
54
|
### New feature
|
33
55
|
|
34
|
-
- Add bang versions for filter and ignore
|
56
|
+
- [#68][] Add bang versions for `Listener#filter` and `Listener#ignore` methods. ([@tarsolya][])
|
35
57
|
|
36
58
|
## 0.5.3 - October 3, 2012
|
37
59
|
|
38
60
|
### Bug fixes
|
39
61
|
|
40
|
-
- [#65] Fix ruby warning in adapter.rb. (
|
41
|
-
- [#64] ENXIO raised when hashing UNIX domain socket file. (
|
62
|
+
- [#65][] Fix ruby warning in adapter.rb. ([@vongruenigen][])
|
63
|
+
- [#64][] ENXIO raised when hashing UNIX domain socket file. ([@sunaku][])
|
42
64
|
|
43
65
|
## 0.5.2 - Septemper 23, 2012
|
44
66
|
|
45
67
|
### Bug fix
|
46
68
|
|
47
|
-
- [#62] Fix double change callback with polling adapter. (
|
69
|
+
- [#62][] Fix double change callback with polling adapter. ([@thibaudgg][])
|
48
70
|
|
49
71
|
## 0.5.1 - Septemper 18, 2012
|
50
72
|
|
51
73
|
### Bug fix
|
52
74
|
|
53
|
-
- [#61] Fix a synchronisation bug that caused constant fallback to polling. (
|
75
|
+
- [#61][] Fix a synchronisation bug that caused constant fallback to polling. ([@Maher4Ever][])
|
54
76
|
|
55
77
|
## 0.5.0 - Septemper 1, 2012
|
56
78
|
|
@@ -62,60 +84,60 @@
|
|
62
84
|
|
63
85
|
### Improvements
|
64
86
|
|
65
|
-
- [#28] Enhance the speed of detecting changes on Windows by using the [WDM][] library. ([@Maher4Ever][])
|
87
|
+
- [#28][] Enhance the speed of detecting changes on Windows by using the [WDM][] library. ([@Maher4Ever][])
|
66
88
|
|
67
89
|
## 0.4.7 - June 27, 2012
|
68
90
|
|
69
91
|
### Bug fixes
|
70
92
|
|
71
|
-
- Increase latency to 0.25, to avoid useless polling fallback. (
|
72
|
-
- Change watched inotify events, to avoid duplication callback. (
|
73
|
-
- [#41]
|
93
|
+
- Increase latency to 0.25, to avoid useless polling fallback. ([@thibaudgg][])
|
94
|
+
- Change watched inotify events, to avoid duplication callback. ([@thibaudgg][])
|
95
|
+
- [#41][] Use lstat instead of stat when calculating mtime. ([@ebroder][])
|
74
96
|
|
75
97
|
## 0.4.6 - June 20, 2012
|
76
98
|
|
77
99
|
### Bug fix
|
78
100
|
|
79
|
-
- [#39]
|
101
|
+
- [#39][] Fix digest race condition. ([@dkubb][])
|
80
102
|
|
81
103
|
## 0.4.5 - June 13, 2012
|
82
104
|
|
83
105
|
### Bug fix
|
84
106
|
|
85
|
-
- [#39]
|
107
|
+
- [#39][] Rescue Errno::ENOENT when path inserted doesn't exist. (reported by [@textgoeshere][], fixed by [@thibaudgg][] and [@rymai][])
|
86
108
|
|
87
109
|
## 0.4.4 - June 8, 2012
|
88
110
|
|
89
111
|
### Bug fixes
|
90
112
|
|
91
|
-
- ~~[#39]
|
113
|
+
- ~~[#39][] Non-existing path insertion bug. (reported by [@textgoeshere][], fixed by [@thibaudgg][])~~
|
92
114
|
- Fix relative path for directories containing special characters. (reported by [@napcs][], fixed by [@netzpirat][])
|
93
115
|
|
94
116
|
## 0.4.3 - June 6, 2012
|
95
117
|
|
96
118
|
### Bug fixes
|
97
119
|
|
98
|
-
- [#24]
|
99
|
-
- [#32]
|
120
|
+
- [#24][] Fail gracefully when the inotify limit is not enough for Listen to function. (reported by [@daemonza][], fixed by [@Maher4Ever][])
|
121
|
+
- [#32][] Fix a crash when trying to calculate the checksum of unreadable files. (reported by [@nex3][], fixed by [@Maher4Ever][])
|
100
122
|
|
101
123
|
### Improvements
|
102
124
|
|
103
|
-
- Add
|
104
|
-
- Add
|
125
|
+
- Add `Listener#relative_paths`. ([@Maher4Ever][])
|
126
|
+
- Add `Adapter#started?`. ([@Maher4Ever][])
|
105
127
|
- Dynamically detect the mtime precision used on a system. ([@Maher4Ever][] with help from [@nex3][])
|
106
128
|
|
107
129
|
## 0.4.2 - May 1, 2012
|
108
130
|
|
109
131
|
### Bug fixes
|
110
132
|
|
111
|
-
- [#21]
|
112
|
-
- [#27]
|
133
|
+
- [#21][] Issues when listening to changes in relative paths. (reported by [@akerbos][], fixed by [@Maher4Ever][])
|
134
|
+
- [#27][] Wrong reports for files modifications. (reported by [@cobychapple][], fixed by [@Maher4Ever][])
|
113
135
|
- Fix segmentation fault when profiling on Windows. ([@Maher4Ever][])
|
114
136
|
- Fix redundant watchers on Windows. ([@Maher4Ever][])
|
115
137
|
|
116
138
|
### Improvements
|
117
139
|
|
118
|
-
- [#17]
|
140
|
+
- [#17][] Use regexp-patterns with the `ignore` method instead of supplying paths. (reported by [@fny][], added by [@Maher4Ever][])
|
119
141
|
- Speed improvement when listening to changes in directories with ignored paths. ([@Maher4Ever][])
|
120
142
|
- Added `.rbx` and `.svn` to ignored directories. ([@Maher4Ever][])
|
121
143
|
|
@@ -123,13 +145,13 @@
|
|
123
145
|
|
124
146
|
### Bug fix
|
125
147
|
|
126
|
-
- [#18]
|
148
|
+
- [#18][] Listener crashes when removing directories with nested paths. (reported by [@daemonza][], fixed by [@Maher4Ever][])
|
127
149
|
|
128
150
|
## 0.4.0 - April 9, 2012
|
129
151
|
|
130
152
|
### New features
|
131
153
|
|
132
|
-
- Add `wait_for_callback
|
154
|
+
- Add `Adapter#wait_for_callback`. ([@Maher4Ever][])
|
133
155
|
- Add `Listen::MultiListener` class to listen to multiple directories at once. ([@Maher4Ever][])
|
134
156
|
- Allow passing multiple directories to the `Listen.to` method. ([@Maher4Ever][])
|
135
157
|
- Add `blocking` option to `Listen#start` which can be used to disable blocking the current thread upon starting. ([@Maher4Ever][])
|
@@ -163,7 +185,7 @@
|
|
163
185
|
|
164
186
|
### Bug fix
|
165
187
|
|
166
|
-
- [#9]
|
188
|
+
- [#9][] Ignore doesn't seem to work. (reported by [@markiz][], fixed by [@thibaudgg][])
|
167
189
|
|
168
190
|
## 0.3.0 - February 21, 2012
|
169
191
|
|
@@ -181,7 +203,7 @@
|
|
181
203
|
- Add rb-inotify support. ([@thibaudgg][] with [@Maher4Ever][] help)
|
182
204
|
- Add rb-fsevent support. ([@thibaudgg][])
|
183
205
|
- Add non-recursive diff with multiple directories support. ([@thibaudgg][])
|
184
|
-
- Ignore
|
206
|
+
- Ignore `.DS_Store` files by default. ([@thibaudgg][])
|
185
207
|
|
186
208
|
## 0.1.0 - January 28, 2012
|
187
209
|
|
@@ -196,23 +218,37 @@
|
|
196
218
|
[#27]: https://github.com/guard/listen/issues/27
|
197
219
|
[#28]: https://github.com/guard/listen/issues/28
|
198
220
|
[#32]: https://github.com/guard/listen/issues/32
|
221
|
+
[#39]: https://github.com/guard/listen/issues/39
|
199
222
|
[#41]: https://github.com/guard/listen/issues/41
|
200
223
|
[#61]: https://github.com/guard/listen/issues/61
|
201
224
|
[#62]: https://github.com/guard/listen/issues/62
|
202
225
|
[#64]: https://github.com/guard/listen/issues/64
|
203
226
|
[#65]: https://github.com/guard/listen/issues/65
|
227
|
+
[#68]: https://github.com/guard/listen/issues/68
|
228
|
+
[#72]: https://github.com/guard/listen/issues/72
|
204
229
|
[#73]: https://github.com/guard/listen/issues/73
|
205
230
|
[#75]: https://github.com/guard/listen/issues/75
|
206
231
|
[#76]: https://github.com/guard/listen/issues/76
|
232
|
+
[#78]: https://github.com/guard/listen/issues/78
|
233
|
+
[#85]: https://github.com/guard/listen/issues/85
|
234
|
+
[#88]: https://github.com/guard/listen/issues/88
|
235
|
+
[#93]: https://github.com/guard/listen/issues/93
|
236
|
+
[#95]: https://github.com/guard/listen/issues/95
|
237
|
+
[#96]: https://github.com/guard/listen/issues/96
|
238
|
+
[#98]: https://github.com/guard/listen/issues/98
|
207
239
|
[@Maher4Ever]: https://github.com/Maher4Ever
|
208
|
-
[@dkubb]: https://github.com/dkubb
|
209
|
-
[@ebroder]: https://github.com/ebroder
|
210
240
|
[@akerbos]: https://github.com/akerbos
|
241
|
+
[@antifuchs]: https://github.com/antifuchs
|
211
242
|
[@cobychapple]: https://github.com/cobychapple
|
212
243
|
[@daemonza]: https://github.com/daemonza
|
244
|
+
[@dkubb]: https://github.com/dkubb
|
245
|
+
[@ebroder]: https://github.com/ebroder
|
213
246
|
[@fny]: https://github.com/fny
|
214
247
|
[@markiz]: https://github.com/markiz
|
248
|
+
[@martikaljuve]: https://github.com/martikaljuve
|
215
249
|
[@mat813]: https://github.com/mat813
|
250
|
+
[@mbj]: https://github.com/mbj
|
251
|
+
[@mrbinky3000]: https://github.com/mrbinky3000
|
216
252
|
[@napcs]: https://github.com/napcs
|
217
253
|
[@netzpirat]: https://github.com/netzpirat
|
218
254
|
[@nex3]: https://github.com/nex3
|
@@ -220,9 +256,8 @@
|
|
220
256
|
[@rymai]: https://github.com/rymai
|
221
257
|
[@scottdavis]: https://github.com/scottdavis
|
222
258
|
[@sunaku]: https://github.com/sunaku
|
259
|
+
[@tarsolya]: https://github.com/tarsolya
|
223
260
|
[@textgoeshere]: https://github.com/textgoeshere
|
224
261
|
[@thibaudgg]: https://github.com/thibaudgg
|
225
|
-
[@tarsolya]: https://github.com/tarsolya
|
226
262
|
[@vongruenigen]: https://github.com/vongruenigen
|
227
263
|
[@zanker]: https://github.com/zanker
|
228
|
-
[WDM]: https://github.com/Maher4Ever/wdm
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Listen [](http://travis-ci.org/guard/listen)
|
1
|
+
# Listen [](http://badge.fury.io/rb/listen) [](http://travis-ci.org/guard/listen) [](https://gemnasium.com/guard/listen) [](https://codeclimate.com/github/guard/listen) [](https://coveralls.io/r/guard/listen)
|
2
2
|
|
3
3
|
The Listen gem listens to file modifications and notifies you about the changes.
|
4
4
|
|
@@ -11,22 +11,50 @@ The Listen gem listens to file modifications and notifies you about the changes.
|
|
11
11
|
* Detects file modification, addition and removal.
|
12
12
|
* Checksum comparison for modifications made under the same second.
|
13
13
|
* Allows supplying regexp-patterns to ignore and filter paths for better results.
|
14
|
-
* Tested on all Ruby environments via [
|
14
|
+
* Tested on all Ruby environments via [Travis CI](https://travis-ci.org/guard/listen).
|
15
15
|
|
16
16
|
## Install
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
### Using Bundler
|
19
|
+
|
20
|
+
The simplest way to install Listen is to use Bundler.
|
21
|
+
|
22
|
+
Add Listen to your Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
group :development do
|
26
|
+
gem 'listen'
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
and install it by running Bundler:
|
31
|
+
|
32
|
+
```bash
|
33
|
+
$ bundle
|
34
|
+
```
|
35
|
+
|
36
|
+
### Install the gem with RubyGems
|
37
|
+
|
38
|
+
```bash
|
39
|
+
$ gem install listen
|
40
|
+
```
|
41
|
+
|
42
|
+
### On Windows
|
43
|
+
|
44
|
+
If your are on Windows and using Ruby MRI >= 1.9.2 you can try to use the [`wdm`](https://github.com/Maher4Ever/wdm) instead of polling.
|
45
|
+
Please add the following to your Gemfile:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
require 'rbconfig'
|
49
|
+
gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
20
50
|
```
|
21
51
|
|
22
52
|
## Usage
|
23
53
|
|
24
54
|
There are **two ways** to use Listen:
|
25
55
|
|
26
|
-
1. Call `Listen.to
|
27
|
-
2. Create a `listener` object and use it in
|
28
|
-
|
29
|
-
Feel free to give your feeback via [Listen issues](https://github.com/guard/listen/issues)
|
56
|
+
1. Block API: Call `Listen.to`/`Listen.to!` with either a single directory or multiple directories, then define the `change` callback in a block.
|
57
|
+
2. "Object" API: Create a `listener` object and use it in a chainable way.
|
30
58
|
|
31
59
|
### Block API
|
32
60
|
|
@@ -52,10 +80,11 @@ listener = listener.latency(0.5)
|
|
52
80
|
listener = listener.force_polling(true)
|
53
81
|
listener = listener.polling_fallback_message(false)
|
54
82
|
listener = listener.change(&callback)
|
55
|
-
listener.start
|
83
|
+
listener.start
|
56
84
|
```
|
57
85
|
|
58
|
-
|
86
|
+
**Note**: All the "Object" API methods except `start`/`start!` return the listener
|
87
|
+
and are thus chainable:
|
59
88
|
|
60
89
|
``` ruby
|
61
90
|
Listen.to('dir/path/to/listen')
|
@@ -65,7 +94,7 @@ Listen.to('dir/path/to/listen')
|
|
65
94
|
.force_polling(true)
|
66
95
|
.polling_fallback_message('custom message')
|
67
96
|
.change(&callback)
|
68
|
-
.start
|
97
|
+
.start
|
69
98
|
```
|
70
99
|
|
71
100
|
### Pause/Unpause
|
@@ -74,35 +103,11 @@ Listener can also easily be paused/unpaused:
|
|
74
103
|
|
75
104
|
``` ruby
|
76
105
|
listener = Listen.to('dir/path/to/listen')
|
77
|
-
listener.start
|
106
|
+
listener.start # non-blocking mode
|
78
107
|
listener.pause # stop listening to changes
|
79
108
|
listener.paused? # => true
|
80
|
-
listener.unpause
|
81
|
-
listener.stop
|
82
|
-
```
|
83
|
-
|
84
|
-
## Listening to changes on multiple directories
|
85
|
-
|
86
|
-
The Listen gem provides the `MultiListener` class to watch multiple directories and
|
87
|
-
handle their changes from a single listener:
|
88
|
-
|
89
|
-
```ruby
|
90
|
-
listener = Listen::MultiListener.new('app/css', 'app/js')
|
91
|
-
listener.latency(0.5)
|
92
|
-
|
93
|
-
# Configure the listener to your needs...
|
94
|
-
|
95
|
-
listener.start # blocks execution!
|
96
|
-
````
|
97
|
-
|
98
|
-
For an easier access, the `Listen.to` method can also be used to create a multi-listener:
|
99
|
-
|
100
|
-
``` ruby
|
101
|
-
listener = Listen.to('app/css', 'app/js')
|
102
|
-
.ignore(%r{^vendor/}) # both js/vendor and css/vendor will be ignored
|
103
|
-
.change(&assets_callback)
|
104
|
-
|
105
|
-
listener.start # blocks execution!
|
109
|
+
listener.unpause # start listening to changes again
|
110
|
+
listener.stop # stop completely the listener
|
106
111
|
```
|
107
112
|
|
108
113
|
## Changes callback
|
@@ -112,7 +117,7 @@ The registered callback gets invoked, when there are changes, with **three** par
|
|
112
117
|
`modified_paths`, `added_paths` and `removed_paths` in that particular order.
|
113
118
|
|
114
119
|
You can register a callback in two ways. The first way is by passing a block when calling
|
115
|
-
the `Listen.to
|
120
|
+
the `Listen.to`/`Listen.to!` method or when initializing a listener object:
|
116
121
|
|
117
122
|
```ruby
|
118
123
|
Listen.to('path/to/app') do |modified, added, removed|
|
@@ -127,7 +132,7 @@ end
|
|
127
132
|
|
128
133
|
```
|
129
134
|
|
130
|
-
The second way to register a callback is
|
135
|
+
The second way to register a callback is by calling the `#change` method on a
|
131
136
|
listener passing it a block:
|
132
137
|
|
133
138
|
```ruby
|
@@ -139,7 +144,7 @@ end
|
|
139
144
|
listener = Listen.to('dir')
|
140
145
|
listener.change(&callback) # convert the callback to a block and register it
|
141
146
|
|
142
|
-
listener.start
|
147
|
+
listener.start
|
143
148
|
```
|
144
149
|
|
145
150
|
### Paths in callbacks
|
@@ -168,7 +173,7 @@ Listen.to('/home/user/app/css', :relative_paths => true) do |modified, added, re
|
|
168
173
|
end
|
169
174
|
```
|
170
175
|
|
171
|
-
Passing the `:relative_paths => true` option won't work when
|
176
|
+
Passing the `:relative_paths => true` option won't work when listening to multiple
|
172
177
|
directories:
|
173
178
|
|
174
179
|
```ruby
|
@@ -181,29 +186,30 @@ end
|
|
181
186
|
|
182
187
|
## Options
|
183
188
|
|
184
|
-
|
189
|
+
All the following options can be set through the `Listen.to`/`Listen.to!` params
|
190
|
+
or via ["Object" API](#object-api) methods:
|
185
191
|
|
186
192
|
```ruby
|
187
|
-
:
|
188
|
-
|
193
|
+
:ignore => %r{app/CMake/}, /\.pid$/ # Ignore a list of paths (root directory or sub-dir)
|
194
|
+
# default: See DEFAULT_IGNORED_DIRECTORIES and DEFAULT_IGNORED_EXTENSIONS in Listen::DirectoryRecord
|
189
195
|
|
190
|
-
:
|
191
|
-
|
196
|
+
:filter => /\.rb$/, /\.coffee$/ # Filter files to listen to via a regexps list.
|
197
|
+
# default: none
|
192
198
|
|
193
|
-
:latency => 0.5
|
194
|
-
|
199
|
+
:latency => 0.5 # Set the delay (**in seconds**) between checking for changes
|
200
|
+
# default: 0.25 sec (1.0 sec for polling)
|
195
201
|
|
196
|
-
:
|
197
|
-
|
202
|
+
:force_polling => true # Force the use of the polling adapter
|
203
|
+
# default: none
|
198
204
|
|
199
|
-
:
|
200
|
-
|
205
|
+
:polling_fallback_message => 'custom message' # Set a custom polling fallback message (or disable it with false)
|
206
|
+
# default: "Listen will be polling for changes. Learn more at https://github.com/guard/listen#polling-fallback."
|
201
207
|
|
202
|
-
:
|
203
|
-
|
208
|
+
:relative_paths => true # Enable the use of relative paths in the callback.
|
209
|
+
# default: false
|
204
210
|
```
|
205
211
|
|
206
|
-
###
|
212
|
+
### Note on the patterns for ignoring and filtering paths
|
207
213
|
|
208
214
|
Just like the unix convention of beginning absolute paths with the
|
209
215
|
directory-separator (forward slash `/` in unix) and with no prefix for relative paths,
|
@@ -217,40 +223,49 @@ and not `%r{/build/}`.
|
|
217
223
|
|
218
224
|
Use `#filter!` and `#ignore!` methods to overwrites default patterns.
|
219
225
|
|
220
|
-
|
226
|
+
## Blocking listening to changes
|
227
|
+
|
228
|
+
Calling `Listen.to` with a block doesn't block the current thread. If you want
|
229
|
+
to block the current thread instead until the listener is stopped (which needs
|
230
|
+
to be done from another thread), you can use `Listen.to!`.
|
231
|
+
|
232
|
+
Similarly, if you're using the "Object" API, you can use `#start!` instead of `#start` to block the
|
233
|
+
current thread until the listener is stopped.
|
221
234
|
|
222
|
-
|
223
|
-
`start` call won't be run until the listener is stopped (which needs to be done from another thread).
|
235
|
+
Here is an example of using a listener in the blocking mode:
|
224
236
|
|
225
|
-
|
226
|
-
|
227
|
-
|
237
|
+
```ruby
|
238
|
+
Listen.to!('dir/path/to/listen') # block execution
|
239
|
+
|
240
|
+
# Code here will not run until the listener is stopped
|
241
|
+
|
242
|
+
```
|
228
243
|
|
229
|
-
Here is an example of using a listener
|
244
|
+
Here is an example of using a listener started with the "Object" API in blocking mode:
|
230
245
|
|
231
246
|
```ruby
|
232
247
|
listener = Listen.to('dir/path/to/listen')
|
233
|
-
listener.start
|
248
|
+
listener.start! # block execution
|
234
249
|
|
235
|
-
# Code here will run
|
250
|
+
# Code here will not run until the listener is stopped
|
236
251
|
|
237
252
|
```
|
238
253
|
|
239
|
-
**
|
240
|
-
|
254
|
+
**Note**: Using the `Listen.to!` helper-method with or without a callback-block
|
255
|
+
will always start the listener right away and block execution of the current thread.
|
241
256
|
|
242
257
|
## Listen adapters
|
243
258
|
|
244
259
|
The Listen gem has a set of adapters to notify it when there are changes.
|
245
|
-
There are
|
246
|
-
as they use some system-calls to implement the notifying function.
|
260
|
+
There are 4 OS-specific adapters to support Mac, Linux, *BSD and Windows.
|
261
|
+
These adapters are fast as they use some system-calls to implement the notifying function.
|
247
262
|
|
248
263
|
There is also a polling adapter which is a cross-platform adapter and it will
|
249
264
|
work on any system. This adapter is unfortunately slower than the rest of the adapters.
|
250
265
|
|
251
266
|
The Listen gem will choose the best and working adapter for your machine automatically. If you
|
252
267
|
want to force the use of the polling adapter, either use the `:force_polling` option
|
253
|
-
while initializing the listener or call the
|
268
|
+
while initializing the listener or call the `#force_polling` method on your listener
|
254
269
|
before starting it.
|
255
270
|
|
256
271
|
## Polling fallback
|
@@ -259,11 +274,12 @@ When a OS-specific adapter doesn't work the Listen gem automatically falls back
|
|
259
274
|
Here are some things you could try to avoid the polling fallback:
|
260
275
|
|
261
276
|
* [Update your Dropbox client](http://www.dropbox.com/downloading) (if used).
|
262
|
-
* Increase latency. (Please [open an issue](https://github.com/guard/listen/issues/new)
|
277
|
+
* Increase latency. (Please [open an issue](https://github.com/guard/listen/issues/new)
|
278
|
+
if you think that default is too low.)
|
263
279
|
* Move or rename the listened folder.
|
264
280
|
* Update/reboot your OS.
|
265
281
|
|
266
|
-
If your application keeps using the polling-adapter and you can't figure out why, feel free to [open an issue](https://github.com/guard/listen/issues/new) (and be sure to give all the details).
|
282
|
+
If your application keeps using the polling-adapter and you can't figure out why, feel free to [open an issue](https://github.com/guard/listen/issues/new) (and be sure to [give all the details](https://github.com/guard/listen/blob/master/CONTRIBUTING.md)).
|
267
283
|
|
268
284
|
## Development [](https://gemnasium.com/guard/listen)
|
269
285
|
|
@@ -273,16 +289,16 @@ If your application keeps using the polling-adapter and you can't figure out why
|
|
273
289
|
Pull requests are very welcome! Please try to follow these simple rules if applicable:
|
274
290
|
|
275
291
|
* Please create a topic branch for every separate change you make.
|
276
|
-
* Make sure your patches are well tested. All specs
|
292
|
+
* Make sure your patches are well tested. All specs must pass on [Travis CI](https://travis-ci.org/guard/listen).
|
277
293
|
* Update the [Yard](http://yardoc.org/) documentation.
|
278
|
-
* Update the README.
|
279
|
-
* Update the CHANGELOG for noteworthy changes
|
294
|
+
* Update the [README](https://github.com/guard/listen/blob/master/README.md).
|
295
|
+
* Update the [CHANGELOG](https://github.com/guard/listen/blob/master/CHANGELOG.md) for noteworthy changes (don't forget to run `bundle exec pimpmychangelog` and watch the magic happen)!
|
280
296
|
* Please **do not change** the version number.
|
281
297
|
|
282
298
|
For questions please join us in our [Google group](http://groups.google.com/group/guard-dev) or on
|
283
299
|
`#guard` (irc.freenode.net).
|
284
300
|
|
285
|
-
##
|
301
|
+
## Acknowledgments
|
286
302
|
|
287
303
|
* [Michael Kessler (netzpirat)][] for having written the [initial specs](https://github.com/guard/listen/commit/1e457b13b1bb8a25d2240428ce5ed488bafbed1f).
|
288
304
|
* [Travis Tilley (ttilley)][] for this awesome work on [fssm][] & [rb-fsevent][].
|
@@ -311,5 +327,6 @@ For questions please join us in our [Google group](http://groups.google.com/grou
|
|
311
327
|
[rb-inotify]: https://github.com/nex3/rb-inotify
|
312
328
|
[stereobooster]: https://github.com/stereobooster
|
313
329
|
[rb-fchange]: https://github.com/stereobooster/rb-fchange
|
330
|
+
[rb-kqueue]: https://github.com/mat813/rb-kqueue
|
314
331
|
[Yehuda Katz (wycats)]: https://github.com/wycats
|
315
332
|
[vigilo]: https://github.com/wycats/vigilo
|