listen 2.6.2 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/bin/listen +6 -1
- data/lib/listen.rb +2 -8
- data/lib/listen/listener.rb +5 -7
- data/lib/listen/version.rb +1 -1
- data/spec/lib/listen/listener_spec.rb +3 -10
- data/spec/lib/listen/tcp/listener_spec.rb +1 -5
- data/spec/lib/listen_spec.rb +2 -2
- data/spec/spec_helper.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac6fd4b57871600c33db9f04c53928b0aa538ab0
|
4
|
+
data.tar.gz: dc7c7574fc2d091abfc188e8de6407f3cdb1b39c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cff1bc85b3d9c2e0d65be6b943d4ef5adf5359657db919572f4bfcc256a9cc2b6cd9570eb3f983c284ba6f5381362ca5c681d92fc3666180041102393dc4c04
|
7
|
+
data.tar.gz: eeee4abe91aee56f1df5d9c069512822e313f39fbd7ac7312fdf83be1c966dc1acc52792992727e3a6055a193abd81ec035f31abb44cd66d42e3e86e44cffabf
|
data/README.md
CHANGED
@@ -30,7 +30,7 @@ Pull request or help is very welcome for these.
|
|
30
30
|
The simplest way to install Listen is to use [Bundler](http://bundler.io).
|
31
31
|
|
32
32
|
```ruby
|
33
|
-
|
33
|
+
gem 'listen', '~> 2.0'
|
34
34
|
```
|
35
35
|
|
36
36
|
## Usage
|
@@ -61,6 +61,8 @@ listener.unpause # start listening to changes again
|
|
61
61
|
listener.stop # stop completely the listener
|
62
62
|
```
|
63
63
|
|
64
|
+
Note: You should keep track of all started listeners and stop them properly on finish.
|
65
|
+
|
64
66
|
### Ignore / ignore!
|
65
67
|
|
66
68
|
Listen ignores some directories and extensions by default (See DEFAULT_IGNORED_DIRECTORIES and DEFAULT_IGNORED_EXTENSIONS in Listen::Silencer), you can add ignoring patterns with the `ignore` option/method or overwrite default with `ignore!` option/method.
|
@@ -73,7 +75,7 @@ listener.ignore /\.rb/ # ignore rb extension in addition of pkg.
|
|
73
75
|
sleep
|
74
76
|
```
|
75
77
|
|
76
|
-
|
78
|
+
Note: Ignoring regexp patterns are evaluated against relative paths.
|
77
79
|
|
78
80
|
### Only
|
79
81
|
|
@@ -86,7 +88,7 @@ listener.only /_spec\.rb$/ # overwrite all existing only patterns.
|
|
86
88
|
sleep
|
87
89
|
```
|
88
90
|
|
89
|
-
|
91
|
+
Note: Only regexp patterns are evaluated only against relative **file** paths.
|
90
92
|
|
91
93
|
## Changes callback
|
92
94
|
|
data/bin/listen
CHANGED
data/lib/listen.rb
CHANGED
@@ -30,10 +30,10 @@ module Listen
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
# Stop all listeners
|
33
|
+
# Stop all listeners & Celluloid
|
34
|
+
# Use it for testing purpose or when you are sure that Celluloid could be ended.
|
34
35
|
#
|
35
36
|
def stop
|
36
|
-
@stopping = true
|
37
37
|
Celluloid.shutdown
|
38
38
|
end
|
39
39
|
|
@@ -58,10 +58,4 @@ module Listen
|
|
58
58
|
Celluloid.boot unless Celluloid.running?
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
62
|
-
unless defined?(JRUBY_VERSION)
|
63
|
-
if Signal.list.keys.include?('INT')
|
64
|
-
Signal.trap('INT') { Listen.stop }
|
65
|
-
end
|
66
|
-
end
|
67
61
|
end
|
data/lib/listen/listener.rb
CHANGED
@@ -6,7 +6,7 @@ require 'listen/silencer'
|
|
6
6
|
|
7
7
|
module Listen
|
8
8
|
class Listener
|
9
|
-
attr_accessor :options, :directories, :paused, :changes, :block, :
|
9
|
+
attr_accessor :options, :directories, :paused, :changes, :block, :stopping
|
10
10
|
attr_accessor :registry, :supervisor
|
11
11
|
|
12
12
|
RELATIVE_PATHS_WITH_MULTIPLE_DIRECTORIES_WARNING_MESSAGE = "The relative_paths option doesn't work when listening to multiple diretories."
|
@@ -27,7 +27,6 @@ module Listen
|
|
27
27
|
@changes = []
|
28
28
|
@block = block
|
29
29
|
@registry = Celluloid::Registry.new
|
30
|
-
@supervisor = Celluloid::SupervisionGroup.run!(@registry)
|
31
30
|
_init_debug
|
32
31
|
end
|
33
32
|
|
@@ -40,14 +39,14 @@ module Listen
|
|
40
39
|
unpause
|
41
40
|
@stopping = false
|
42
41
|
registry[:adapter].async.start
|
43
|
-
|
42
|
+
Thread.new { _wait_for_changes }
|
44
43
|
end
|
45
44
|
|
46
45
|
# Terminates all Listen actors and kill the adapter.
|
47
46
|
#
|
48
47
|
def stop
|
49
48
|
@stopping = true
|
50
|
-
|
49
|
+
supervisor.terminate
|
51
50
|
end
|
52
51
|
|
53
52
|
# Pauses listening callback (adapter still running)
|
@@ -126,6 +125,7 @@ module Listen
|
|
126
125
|
end
|
127
126
|
|
128
127
|
def _init_actors
|
128
|
+
@supervisor = Celluloid::SupervisionGroup.run!(registry)
|
129
129
|
supervisor.add(Silencer, as: :silencer, args: self)
|
130
130
|
supervisor.add(Record, as: :record, args: self)
|
131
131
|
supervisor.pool(Change, as: :change_pool, args: self)
|
@@ -136,7 +136,7 @@ module Listen
|
|
136
136
|
|
137
137
|
def _wait_for_changes
|
138
138
|
loop do
|
139
|
-
break if @stopping
|
139
|
+
break if @stopping
|
140
140
|
|
141
141
|
changes = _pop_changes
|
142
142
|
unless changes.all? { |_,v| v.empty? }
|
@@ -144,8 +144,6 @@ module Listen
|
|
144
144
|
end
|
145
145
|
sleep options[:wait_for_delay]
|
146
146
|
end
|
147
|
-
|
148
|
-
supervisor.finalize
|
149
147
|
rescue => ex
|
150
148
|
Kernel.warn "[Listen warning]: Change block raised an exception: #{$!}"
|
151
149
|
Kernel.warn "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
|
data/lib/listen/version.rb
CHANGED
@@ -63,11 +63,6 @@ describe Listen::Listener do
|
|
63
63
|
adapter.stub_chain(:async, :start)
|
64
64
|
}
|
65
65
|
|
66
|
-
it "traps INT signal" do
|
67
|
-
expect(Signal).to receive(:trap).with('INT')
|
68
|
-
listener.start
|
69
|
-
end
|
70
|
-
|
71
66
|
it "registers silencer" do
|
72
67
|
expect(supervisor).to receive(:add).with(Listen::Silencer, as: :silencer, args: listener)
|
73
68
|
listener.start
|
@@ -124,11 +119,9 @@ describe Listen::Listener do
|
|
124
119
|
end
|
125
120
|
|
126
121
|
describe "#stop" do
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
it "joins thread" do
|
131
|
-
expect(thread).to receive(:join)
|
122
|
+
it "terminates supervisor" do
|
123
|
+
listener.supervisor = supervisor
|
124
|
+
expect(supervisor).to receive(:terminate)
|
132
125
|
listener.stop
|
133
126
|
end
|
134
127
|
end
|
@@ -100,12 +100,8 @@ describe Listen::TCP::Listener do
|
|
100
100
|
end
|
101
101
|
|
102
102
|
context 'when stopped' do
|
103
|
-
let(:thread) { double(join: true) }
|
104
|
-
before do
|
105
|
-
subject.stub(:thread) { thread }
|
106
|
-
end
|
107
|
-
|
108
103
|
it 'honours stopped state and does nothing' do
|
104
|
+
allow(subject).to receive(:supervisor) { double('SupervisionGroup', terminate: true) }
|
109
105
|
subject.stop
|
110
106
|
expect(broadcaster).not_to receive(:async)
|
111
107
|
expect(callback).not_to receive(:call)
|
data/spec/lib/listen_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: listen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibaud Guillaume-Gentil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|