listen 3.1.5 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +10 -3
- data/README.md +240 -75
- data/bin/listen +3 -4
- data/lib/listen/adapter/base.rb +23 -35
- data/lib/listen/adapter/bsd.rb +6 -5
- data/lib/listen/adapter/config.rb +3 -4
- data/lib/listen/adapter/darwin.rb +29 -44
- data/lib/listen/adapter/linux.rb +15 -13
- data/lib/listen/adapter/polling.rb +8 -5
- data/lib/listen/adapter/windows.rb +15 -17
- data/lib/listen/adapter.rb +9 -11
- data/lib/listen/backend.rb +2 -0
- data/lib/listen/change.rb +14 -21
- data/lib/listen/cli.rb +6 -6
- data/lib/listen/directory.rb +14 -8
- data/lib/listen/error.rb +11 -0
- data/lib/listen/event/config.rb +9 -24
- data/lib/listen/event/loop.rb +44 -67
- data/lib/listen/event/processor.rb +41 -37
- data/lib/listen/event/queue.rb +12 -13
- data/lib/listen/file.rb +22 -7
- data/lib/listen/fsm.rb +72 -71
- data/lib/listen/listener/config.rb +4 -4
- data/lib/listen/listener.rb +26 -23
- data/lib/listen/logger.rb +24 -20
- data/lib/listen/monotonic_time.rb +27 -0
- data/lib/listen/options.rb +11 -8
- data/lib/listen/queue_optimizer.rb +13 -16
- data/lib/listen/record/entry.rb +4 -2
- data/lib/listen/record/symlink_detector.rb +10 -8
- data/lib/listen/record.rb +34 -32
- data/lib/listen/silencer/controller.rb +2 -0
- data/lib/listen/silencer.rb +20 -15
- data/lib/listen/thread.rb +54 -0
- data/lib/listen/version.rb +3 -1
- data/lib/listen.rb +15 -25
- metadata +20 -45
- data/lib/listen/internals/thread_pool.rb +0 -29
data/lib/listen.rb
CHANGED
@@ -1,28 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'logger'
|
4
|
+
require 'weakref'
|
2
5
|
require 'listen/logger'
|
3
6
|
require 'listen/listener'
|
4
7
|
|
5
|
-
require 'listen/internals/thread_pool'
|
6
|
-
|
7
|
-
# Show warnings about vulnerabilities, bugs and outdated Rubies, since previous
|
8
|
-
# versions aren't tested or officially supported.
|
9
|
-
require 'ruby_dep/warning'
|
10
|
-
RubyDep::Warning.new.show_warnings
|
11
|
-
|
12
|
-
# Always set up logging by default first time file is required
|
13
|
-
#
|
14
|
-
# NOTE: If you need to clear the logger completely, do so *after*
|
15
|
-
# requiring this file. If you need to set a custom logger,
|
16
|
-
# require the listen/logger file and set the logger before requiring
|
17
|
-
# this file.
|
18
|
-
Listen.setup_default_logger_if_unset
|
19
|
-
|
20
8
|
# Won't print anything by default because of level - unless you've set
|
21
9
|
# LISTEN_GEM_DEBUGGING or provided your own logger with a high enough level
|
22
|
-
Listen
|
23
|
-
Listen
|
10
|
+
Listen.logger.info "Listen loglevel set to: #{Listen.logger.level}"
|
11
|
+
Listen.logger.info "Listen version: #{Listen::VERSION}"
|
24
12
|
|
25
13
|
module Listen
|
14
|
+
@listeners = Queue.new
|
15
|
+
|
26
16
|
class << self
|
27
17
|
# Listens to file system modifications on a either single directory or
|
28
18
|
# multiple directories.
|
@@ -37,21 +27,21 @@ module Listen
|
|
37
27
|
# @return [Listen::Listener] the listener
|
38
28
|
#
|
39
29
|
def to(*args, &block)
|
40
|
-
@listeners ||= []
|
41
30
|
Listener.new(*args, &block).tap do |listener|
|
42
|
-
@listeners
|
31
|
+
@listeners.enq(WeakRef.new(listener))
|
43
32
|
end
|
44
33
|
end
|
45
34
|
|
46
35
|
# This is used by the `listen` binary to handle Ctrl-C
|
47
36
|
#
|
48
37
|
def stop
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
38
|
+
while (listener = @listeners.deq(true))
|
39
|
+
begin
|
40
|
+
listener.stop
|
41
|
+
rescue WeakRef::RefError
|
42
|
+
end
|
43
|
+
end
|
44
|
+
rescue ThreadError
|
55
45
|
end
|
56
46
|
end
|
57
47
|
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: 3.
|
4
|
+
version: 3.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:
|
11
|
+
date: 2021-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rb-fsevent
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.10'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.10.3
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0.
|
29
|
+
version: '0.10'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 0.10.3
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rb-inotify
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '0.9'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.9.
|
42
|
+
version: 0.9.10
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,35 +49,7 @@ dependencies:
|
|
49
49
|
version: '0.9'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 0.9.
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: ruby_dep
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '1.2'
|
60
|
-
type: :runtime
|
61
|
-
prerelease: false
|
62
|
-
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - "~>"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '1.2'
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: bundler
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - "~>"
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '1.12'
|
74
|
-
type: :development
|
75
|
-
prerelease: false
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - "~>"
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '1.12'
|
52
|
+
version: 0.9.10
|
81
53
|
description: The Listen gem listens to file modifications and notifies you about the
|
82
54
|
changes. Works everywhere!
|
83
55
|
email: thibaud@thibaud.gg
|
@@ -104,16 +76,17 @@ files:
|
|
104
76
|
- lib/listen/change.rb
|
105
77
|
- lib/listen/cli.rb
|
106
78
|
- lib/listen/directory.rb
|
79
|
+
- lib/listen/error.rb
|
107
80
|
- lib/listen/event/config.rb
|
108
81
|
- lib/listen/event/loop.rb
|
109
82
|
- lib/listen/event/processor.rb
|
110
83
|
- lib/listen/event/queue.rb
|
111
84
|
- lib/listen/file.rb
|
112
85
|
- lib/listen/fsm.rb
|
113
|
-
- lib/listen/internals/thread_pool.rb
|
114
86
|
- lib/listen/listener.rb
|
115
87
|
- lib/listen/listener/config.rb
|
116
88
|
- lib/listen/logger.rb
|
89
|
+
- lib/listen/monotonic_time.rb
|
117
90
|
- lib/listen/options.rb
|
118
91
|
- lib/listen/queue_optimizer.rb
|
119
92
|
- lib/listen/record.rb
|
@@ -121,33 +94,35 @@ files:
|
|
121
94
|
- lib/listen/record/symlink_detector.rb
|
122
95
|
- lib/listen/silencer.rb
|
123
96
|
- lib/listen/silencer/controller.rb
|
97
|
+
- lib/listen/thread.rb
|
124
98
|
- lib/listen/version.rb
|
125
99
|
homepage: https://github.com/guard/listen
|
126
100
|
licenses:
|
127
101
|
- MIT
|
128
|
-
metadata:
|
102
|
+
metadata:
|
103
|
+
allowed_push_host: https://rubygems.org
|
104
|
+
bug_tracker_uri: https://github.com/guard/listen/issues
|
105
|
+
changelog_uri: https://github.com/guard/listen/releases
|
106
|
+
documentation_uri: https://www.rubydoc.info/gems/listen/3.7.0
|
107
|
+
homepage_uri: https://github.com/guard/listen
|
108
|
+
source_code_uri: https://github.com/guard/listen/tree/v3.7.0
|
129
109
|
post_install_message:
|
130
110
|
rdoc_options: []
|
131
111
|
require_paths:
|
132
112
|
- lib
|
133
113
|
required_ruby_version: !ruby/object:Gem::Requirement
|
134
114
|
requirements:
|
135
|
-
- - "~>"
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '2.2'
|
138
115
|
- - ">="
|
139
116
|
- !ruby/object:Gem::Version
|
140
|
-
version: 2.
|
117
|
+
version: 2.4.0
|
141
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
119
|
requirements:
|
143
120
|
- - ">="
|
144
121
|
- !ruby/object:Gem::Version
|
145
122
|
version: '0'
|
146
123
|
requirements: []
|
147
|
-
|
148
|
-
rubygems_version: 2.5.1
|
124
|
+
rubygems_version: 3.0.1
|
149
125
|
signing_key:
|
150
126
|
specification_version: 4
|
151
127
|
summary: Listen to file modifications
|
152
128
|
test_files: []
|
153
|
-
has_rdoc:
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Listen
|
2
|
-
# @private api
|
3
|
-
module Internals
|
4
|
-
module ThreadPool
|
5
|
-
def self.add(&block)
|
6
|
-
Thread.new { block.call }.tap do |th|
|
7
|
-
(@threads ||= Queue.new) << th
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.stop
|
12
|
-
return unless @threads ||= nil
|
13
|
-
return if @threads.empty? # return to avoid using possibly stubbed Queue
|
14
|
-
|
15
|
-
killed = Queue.new
|
16
|
-
# You can't kill a read on a descriptor in JRuby, so let's just
|
17
|
-
# ignore running threads (listen rb-inotify waiting for disk activity
|
18
|
-
# before closing) pray threads die faster than they are created...
|
19
|
-
limit = RUBY_ENGINE == 'jruby' ? [1] : []
|
20
|
-
|
21
|
-
killed << @threads.pop.kill until @threads.empty?
|
22
|
-
until killed.empty?
|
23
|
-
th = killed.pop
|
24
|
-
th.join(*limit) unless th[:listen_blocking_read_thread]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|