listen 2.3.1 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8644cb90075a5b296441b6e04044258dc64c738
4
- data.tar.gz: 09212d8aafd577ab7ce6181b99798d43d69d6f44
3
+ metadata.gz: 55175dd6e3cf35a92523c2cf980a4a7bdb17786e
4
+ data.tar.gz: 65865b20296fe78c73c68dbd31da592f0665b684
5
5
  SHA512:
6
- metadata.gz: a016d2f3551965258853b077f249f1b19d5f6f3bccce6707f5f9aba4be054faf18a08f2c9f491fb6fd8afeda25fd4481fb041c90489739ce34bd7e5bdeef0c06
7
- data.tar.gz: 0448bb8714d6ad0209a7db76ef3ceef29075d8e464f3d26d3e8bb5830173423b48b2c665c6eb7b0ff69881b1e976e750da57fbc2f6950b2dc4a7433f981149d2
6
+ metadata.gz: e3833e2a9b82f597701fac590420f1531c79c9800ae7dc0c029a2087693fc35c3a34843598e23ca51360ad1555d91554bde92a860eabf125e6ee2c82085eb445
7
+ data.tar.gz: 09f971472db48ab4f10f65e8e8bf71a94fabdc18aab60c073d9dcb35719bbe1172ad42c9cd6105931fa1f1634ddd33a47262626556d467cc41f462e7cc959871
@@ -2,19 +2,29 @@ require 'celluloid'
2
2
  require 'listen/listener'
3
3
 
4
4
  module Listen
5
+ class << self
6
+ attr_accessor :stopping
5
7
 
6
- # Listens to file system modifications on a either single directory or multiple directories.
7
- #
8
- # @param (see Listen::Listener#new)
9
- #
10
- # @yield [modified, added, removed] the changed files
11
- # @yieldparam [Array<String>] modified the list of modified files
12
- # @yieldparam [Array<String>] added the list of added files
13
- # @yieldparam [Array<String>] removed the list of removed files
14
- #
15
- # @return [Listen::Listener] the listener
16
- #
17
- def self.to(*args, &block)
18
- Listener.new(*args, &block)
8
+ # Listens to file system modifications on a either single directory or multiple directories.
9
+ #
10
+ # @param (see Listen::Listener#new)
11
+ #
12
+ # @yield [modified, added, removed] the changed files
13
+ # @yieldparam [Array<String>] modified the list of modified files
14
+ # @yieldparam [Array<String>] added the list of added files
15
+ # @yieldparam [Array<String>] removed the list of removed files
16
+ #
17
+ # @return [Listen::Listener] the listener
18
+ #
19
+ def to(*args, &block)
20
+ @stopping = false
21
+ Listener.new(*args, &block)
22
+ end
23
+
24
+ # Stop all listeners
25
+ #
26
+ def stop
27
+ @stopping = true
28
+ end
19
29
  end
20
30
  end
@@ -143,7 +143,7 @@ module Listen
143
143
 
144
144
  def _wait_for_changes
145
145
  loop do
146
- break if @stopping
146
+ break if @stopping || Listen.stopping
147
147
 
148
148
  changes = _pop_changes
149
149
  unless changes.all? { |_,v| v.empty? }
@@ -3,7 +3,7 @@ module Listen
3
3
  include Celluloid
4
4
 
5
5
  # The default list of directories that get ignored.
6
- DEFAULT_IGNORED_DIRECTORIES = %w[.bundle .git .hg .rbx .svn bundle log tmp vendor/ruby]
6
+ DEFAULT_IGNORED_DIRECTORIES = %w[.bundle .git .hg .rbx .svn bundle log tmp vendor/ruby vendor/bundle]
7
7
 
8
8
  # The default list of files that get ignored.
9
9
  DEFAULT_IGNORED_EXTENSIONS = %w[.DS_Store .tmp]
@@ -1,3 +1,3 @@
1
1
  module Listen
2
- VERSION = '2.3.1'
2
+ VERSION = '2.4.0'
3
3
  end
@@ -1,10 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Listen do
4
- describe '#to' do
4
+ describe '.to' do
5
5
  it "initalizes listener" do
6
6
  expect(Listen::Listener).to receive(:new).with('/path')
7
7
  described_class.to('/path')
8
8
  end
9
+
10
+ it "sets stopping at false" do
11
+ allow(Listen::Listener).to receive(:new)
12
+ Listen.to('/path')
13
+ expect(Listen.stopping).to be_false
14
+ end
15
+ end
16
+
17
+ describe '.stop' do
18
+ it "stops all listeners" do
19
+ Listen.stop
20
+ expect(Listen.stopping).to be_true
21
+ end
9
22
  end
10
23
  end
@@ -33,6 +33,7 @@ Thread.abort_on_exception = true
33
33
  Celluloid.logger.level = Logger::ERROR
34
34
 
35
35
  RSpec.configuration.before(:each) do
36
+ Listen.stopping = false
36
37
  Celluloid.shutdown
37
38
  Celluloid.boot
38
39
  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.3.1
4
+ version: 2.4.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: 2013-12-03 00:00:00.000000000 Z
11
+ date: 2013-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 2.0.14
184
+ rubygems_version: 2.1.11
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: Listen to file modifications