listen 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.3.2 - 4 Mars, 2012
2
+
3
+ ### New features
4
+
5
+ - Add pause/unpause listener's methods. ([@thibaudgg][])
6
+
1
7
  ## 0.3.1 - February 22, 2012
2
8
 
3
9
  ### Bug fix
data/README.md CHANGED
@@ -94,6 +94,18 @@ These options can be set through `Listen.to` params or via methods (see the "Obj
94
94
  # default: "WARNING: Listen fallen back to polling, learn more at https://github.com/guard/listen#fallback."
95
95
  ```
96
96
 
97
+ ### Pause/Unpause
98
+
99
+ Listener can also easily be paused/unpaused:
100
+
101
+ ``` ruby
102
+ listener = Listen.to('dir/path/to/listen')
103
+ listener.start # enter the run loop
104
+ listener.pause # stop the run loop and enter the wait loop
105
+ listener.unpause # re-enter the run loop
106
+ listener.stop
107
+ ```
108
+
97
109
  ## Listen adapters
98
110
 
99
111
  The Listen gem has a set of adapters to notify it when there are changes.
@@ -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
12
+ attr_accessor :directory, :ignored_paths, :file_filters, :sha1_checksums, :paths, :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,7 +55,35 @@ module Listen
55
55
  # Stop the adapter.
56
56
  #
57
57
  def stop
58
+ if @paused
59
+ @paused = false
60
+ else
61
+ @adapter.stop
62
+ end
63
+ end
64
+
65
+ # Stop the adapter and wait
66
+ #
67
+ def pause
68
+ @paused = true
58
69
  @adapter.stop
70
+ sleep 0.1 while @paused
71
+ end
72
+
73
+ # UnPause and re-initialize @paths and start the adapter
74
+ #
75
+ def unpause
76
+ @paused = false
77
+ init_paths
78
+ @adapter.start
79
+ end
80
+
81
+ # Is this listener paused
82
+ #
83
+ # @return [Boolean] listener paused status
84
+ #
85
+ def paused?
86
+ @paused == true
59
87
  end
60
88
 
61
89
  # Add ignored path to the listener.
@@ -1,3 +1,3 @@
1
1
  module Listen
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
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.1
4
+ version: 0.3.2
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-02-22 00:00:00.000000000 Z
12
+ date: 2012-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rb-fsevent
16
- requirement: &70155283627820 !ruby/object:Gem::Requirement
16
+ requirement: &70305954323260 !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: *70155283627820
24
+ version_requirements: *70305954323260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rb-inotify
27
- requirement: &70155283627360 !ruby/object:Gem::Requirement
27
+ requirement: &70305954322620 !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: *70155283627360
35
+ version_requirements: *70305954322620
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rb-fchange
38
- requirement: &70155283626780 !ruby/object:Gem::Requirement
38
+ requirement: &70305954322080 !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: *70155283626780
46
+ version_requirements: *70305954322080
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70155283626220 !ruby/object:Gem::Requirement
49
+ requirement: &70305954321620 !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: *70155283626220
57
+ version_requirements: *70305954321620
58
58
  description: The Listen gem listens to file modifications and notifies you about the
59
59
  changes. Works everywhere!
60
60
  email: