listen 2.6.2 → 2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 812276687dc4c17d96ced0f45548a4e57cc955bd
4
- data.tar.gz: 5b56ff60f6ec54a18472406df7e254305efe6017
3
+ metadata.gz: ac6fd4b57871600c33db9f04c53928b0aa538ab0
4
+ data.tar.gz: dc7c7574fc2d091abfc188e8de6407f3cdb1b39c
5
5
  SHA512:
6
- metadata.gz: aa9b862960d220fa996af84fc890514289683f81d4852c08a6b3f2ec2843c0c3044c87a65a38486a4d47d823e874768f51b8c6ceede7cf080e12ef353e8be09d
7
- data.tar.gz: 67bf684c0d85aa8a5278199f46a950b3c2149f3a4e912db8987cf143eb1e269cbf7c40440849830f28bbb17e61a0c90a9b99aef3398d3445933012c0897a8a53
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
- gem 'listen', '~> 2.0'
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
- Note: Ignoring regexp patterns are evaluated against relative paths.
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
- Note: Only regexp patterns are evaluated only against relative **file** paths.
91
+ Note: Only regexp patterns are evaluated only against relative **file** paths.
90
92
 
91
93
  ## Changes callback
92
94
 
data/bin/listen CHANGED
@@ -3,5 +3,10 @@
3
3
  require 'listen'
4
4
  require 'listen/cli'
5
5
 
6
- Listen::CLI.start
6
+ unless defined?(JRUBY_VERSION)
7
+ if Signal.list.keys.include?('INT')
8
+ Signal.trap('INT') { Listen.stop }
9
+ end
10
+ end
7
11
 
12
+ Listen::CLI.start
@@ -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
@@ -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, :thread, :stopping
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
- @thread = Thread.new { _wait_for_changes }
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
- thread.join
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 || Listen.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")}"
@@ -1,3 +1,3 @@
1
1
  module Listen
2
- VERSION = '2.6.2'
2
+ VERSION = '2.7.0'
3
3
  end
@@ -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
- let(:thread) { double(join: true) }
128
- before { listener.stub(:thread) { thread } }
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)
@@ -22,9 +22,9 @@ describe Listen do
22
22
  end
23
23
 
24
24
  describe '.stop' do
25
- it "stops all listeners" do
25
+ it "stops all listeners & Celluloid" do
26
26
  Listen.stop
27
- expect(Listen.stopping).to be_true
27
+ expect(Celluloid.internal_pool.running?).to be_false
28
28
  end
29
29
  end
30
30
 
@@ -34,6 +34,9 @@ Celluloid.logger.level = Logger::ERROR
34
34
 
35
35
  RSpec.configuration.before(:each) do
36
36
  Listen.stopping = false
37
- Celluloid.shutdown
38
37
  Celluloid.boot
39
38
  end
39
+
40
+ RSpec.configuration.after(:each) do
41
+ Celluloid.shutdown
42
+ end
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.6.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-02-28 00:00:00.000000000 Z
11
+ date: 2014-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid