listen 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -1
- data/README.md +4 -2
- data/lib/listen/adapter.rb +2 -1
- data/lib/listen/adapters/darwin.rb +2 -0
- data/lib/listen/adapters/linux.rb +3 -0
- data/lib/listen/adapters/polling.rb +2 -0
- data/lib/listen/adapters/windows.rb +2 -0
- data/lib/listen/listener.rb +10 -17
- data/lib/listen/version.rb +1 -1
- metadata +10 -10
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -101,8 +101,9 @@ Listener can also easily be paused/unpaused:
|
|
101
101
|
``` ruby
|
102
102
|
listener = Listen.to('dir/path/to/listen')
|
103
103
|
listener.start # enter the run loop
|
104
|
-
listener.pause # stop
|
105
|
-
listener.
|
104
|
+
listener.pause # stop listening changes
|
105
|
+
listener.paused? => true
|
106
|
+
listener.unpause
|
106
107
|
listener.stop
|
107
108
|
```
|
108
109
|
|
@@ -127,6 +128,7 @@ When the OS-specific adapter doesn't work the Listen gem automatically falls bac
|
|
127
128
|
Here some things to try to avoiding this fallback:
|
128
129
|
|
129
130
|
* [Update your Dropbox client](http://www.dropbox.com/downloading) (if used).
|
131
|
+
* Increase latency. (Please [open an issue](https://github.com/guard/listen/issues/new) if you think that default is too low.)
|
130
132
|
* Move or rename the listened folder.
|
131
133
|
* Update/reboot your OS.
|
132
134
|
|
data/lib/listen/adapter.rb
CHANGED
@@ -2,7 +2,7 @@ require 'rbconfig'
|
|
2
2
|
|
3
3
|
module Listen
|
4
4
|
class Adapter
|
5
|
-
attr_accessor :latency
|
5
|
+
attr_accessor :latency, :paused
|
6
6
|
|
7
7
|
# The default delay between checking for changes.
|
8
8
|
DEFAULT_LATENCY = 0.1
|
@@ -58,6 +58,7 @@ module Listen
|
|
58
58
|
@callback = callback
|
59
59
|
@latency ||= DEFAULT_LATENCY
|
60
60
|
@latency = options[:latency] if options[:latency]
|
61
|
+
@paused = false
|
61
62
|
end
|
62
63
|
|
63
64
|
# Start the adapter.
|
@@ -57,6 +57,8 @@ module Listen
|
|
57
57
|
def init_worker
|
58
58
|
@worker = INotify::Notifier.new
|
59
59
|
@worker.watch(@directory, *EVENTS.map(&:to_sym)) do |event|
|
60
|
+
next if @paused
|
61
|
+
|
60
62
|
unless event.name == "" # Event on root directory
|
61
63
|
@changed_dirs << File.dirname(event.absolute_name)
|
62
64
|
end
|
@@ -68,6 +70,7 @@ module Listen
|
|
68
70
|
def poll_changed_dirs
|
69
71
|
until @stop
|
70
72
|
sleep(@latency)
|
73
|
+
|
71
74
|
next if @changed_dirs.empty?
|
72
75
|
changed_dirs = @changed_dirs.to_a
|
73
76
|
@changed_dirs.clear
|
data/lib/listen/listener.rb
CHANGED
@@ -9,7 +9,7 @@ require 'listen/adapters/windows'
|
|
9
9
|
|
10
10
|
module Listen
|
11
11
|
class Listener
|
12
|
-
attr_accessor :directory, :ignored_paths, :file_filters, :sha1_checksums, :paths, :paused
|
12
|
+
attr_accessor :directory, :ignored_paths, :file_filters, :sha1_checksums, :paths, :adapter, :paused
|
13
13
|
|
14
14
|
# Default paths that gets ignored by the listener
|
15
15
|
DEFAULT_IGNORED_PATHS = %w[.bundle .git .DS_Store log tmp vendor]
|
@@ -55,35 +55,28 @@ module Listen
|
|
55
55
|
# Stop the adapter.
|
56
56
|
#
|
57
57
|
def stop
|
58
|
-
|
59
|
-
@paused = false
|
60
|
-
else
|
61
|
-
@adapter.stop
|
62
|
-
end
|
58
|
+
@adapter.stop
|
63
59
|
end
|
64
60
|
|
65
|
-
#
|
61
|
+
# Pause the adapter
|
66
62
|
#
|
67
63
|
def pause
|
68
|
-
@paused = true
|
69
|
-
@adapter.stop
|
70
|
-
sleep 0.1 while @paused
|
64
|
+
@adapter.paused = true
|
71
65
|
end
|
72
66
|
|
73
|
-
#
|
67
|
+
# Re-initialize @paths and unpause the adapter
|
74
68
|
#
|
75
69
|
def unpause
|
76
|
-
@paused = false
|
77
70
|
init_paths
|
78
|
-
@adapter.
|
71
|
+
@adapter.paused = false
|
79
72
|
end
|
80
|
-
|
81
|
-
# Is
|
73
|
+
|
74
|
+
# Is adapter paused
|
82
75
|
#
|
83
|
-
# @return [Boolean]
|
76
|
+
# @return [Boolean] adapter paused status
|
84
77
|
#
|
85
78
|
def paused?
|
86
|
-
@paused == true
|
79
|
+
!@adapter.nil? && @adapter.paused == true
|
87
80
|
end
|
88
81
|
|
89
82
|
# Add ignored path to the listener.
|
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.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rb-fsevent
|
16
|
-
requirement: &
|
16
|
+
requirement: &70344951028040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.9.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70344951028040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rb-inotify
|
27
|
-
requirement: &
|
27
|
+
requirement: &70344951027580 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.8.8
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70344951027580
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rb-fchange
|
38
|
-
requirement: &
|
38
|
+
requirement: &70344951027120 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.0.5
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70344951027120
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70344951026740 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70344951026740
|
58
58
|
description: The Listen gem listens to file modifications and notifies you about the
|
59
59
|
changes. Works everywhere!
|
60
60
|
email:
|