listen 2.7.5 → 2.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.rubocop.yml +0 -0
- data/.travis.yml +0 -1
- data/.yardopts +0 -0
- data/CHANGELOG.md +0 -0
- data/CONTRIBUTING.md +0 -0
- data/Gemfile +25 -4
- data/Guardfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +18 -10
- data/Rakefile +0 -0
- data/lib/listen.rb +2 -4
- data/lib/listen/adapter.rb +13 -4
- data/lib/listen/adapter/base.rb +33 -16
- data/lib/listen/adapter/bsd.rb +21 -38
- data/lib/listen/adapter/darwin.rb +17 -25
- data/lib/listen/adapter/linux.rb +34 -52
- data/lib/listen/adapter/polling.rb +9 -25
- data/lib/listen/adapter/tcp.rb +27 -14
- data/lib/listen/adapter/windows.rb +67 -23
- data/lib/listen/change.rb +26 -23
- data/lib/listen/cli.rb +0 -0
- data/lib/listen/directory.rb +47 -58
- data/lib/listen/file.rb +66 -101
- data/lib/listen/listener.rb +214 -155
- data/lib/listen/queue_optimizer.rb +104 -0
- data/lib/listen/record.rb +15 -5
- data/lib/listen/silencer.rb +14 -10
- data/lib/listen/tcp.rb +0 -1
- data/lib/listen/tcp/broadcaster.rb +31 -26
- data/lib/listen/tcp/message.rb +2 -2
- data/lib/listen/version.rb +1 -1
- data/listen.gemspec +1 -1
- data/spec/acceptance/listen_spec.rb +151 -239
- data/spec/acceptance/tcp_spec.rb +125 -134
- data/spec/lib/listen/adapter/base_spec.rb +13 -30
- data/spec/lib/listen/adapter/bsd_spec.rb +7 -35
- data/spec/lib/listen/adapter/darwin_spec.rb +18 -30
- data/spec/lib/listen/adapter/linux_spec.rb +49 -55
- data/spec/lib/listen/adapter/polling_spec.rb +20 -35
- data/spec/lib/listen/adapter/tcp_spec.rb +25 -27
- data/spec/lib/listen/adapter/windows_spec.rb +7 -33
- data/spec/lib/listen/adapter_spec.rb +10 -10
- data/spec/lib/listen/change_spec.rb +55 -57
- data/spec/lib/listen/directory_spec.rb +105 -155
- data/spec/lib/listen/file_spec.rb +186 -73
- data/spec/lib/listen/listener_spec.rb +233 -216
- data/spec/lib/listen/record_spec.rb +60 -22
- data/spec/lib/listen/silencer_spec.rb +48 -75
- data/spec/lib/listen/tcp/broadcaster_spec.rb +78 -69
- data/spec/lib/listen/tcp/listener_spec.rb +28 -71
- data/spec/lib/listen/tcp/message_spec.rb +48 -14
- data/spec/lib/listen_spec.rb +3 -3
- data/spec/spec_helper.rb +6 -3
- data/spec/support/acceptance_helper.rb +250 -31
- data/spec/support/fixtures_helper.rb +6 -4
- data/spec/support/platform_helper.rb +2 -2
- metadata +5 -5
- data/lib/listen/tcp/listener.rb +0 -108
@@ -12,13 +12,15 @@ include FileUtils
|
|
12
12
|
# @yieldparam [String] path the path to a fixture directory
|
13
13
|
#
|
14
14
|
def fixtures(number_of_directories = 1)
|
15
|
-
current_pwd = pwd
|
15
|
+
current_pwd = Dir.pwd
|
16
16
|
paths = 1.upto(number_of_directories).map { mk_fixture_tmp_dir }
|
17
|
-
|
17
|
+
|
18
|
+
FileUtils.cd(paths.first) if number_of_directories == 1
|
19
|
+
|
18
20
|
yield(*paths)
|
19
21
|
ensure
|
20
|
-
cd current_pwd
|
21
|
-
paths.map { |p| rm_rf(p) if File.exist?(p) }
|
22
|
+
FileUtils.cd current_pwd
|
23
|
+
paths.map { |p| FileUtils.rm_rf(p) if File.exist?(p) }
|
22
24
|
end
|
23
25
|
|
24
26
|
def mk_fixture_tmp_dir
|
@@ -7,9 +7,9 @@ def linux?
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def bsd?
|
10
|
-
RbConfig::CONFIG['target_os'] =~ /
|
10
|
+
RbConfig::CONFIG['target_os'] =~ /bsd|dragonfly/i
|
11
11
|
end
|
12
12
|
|
13
13
|
def windows?
|
14
|
-
RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
14
|
+
RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i
|
15
15
|
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.7.
|
4
|
+
version: 2.7.6
|
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-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 3.0.0rc1
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 3.0.0rc1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec-retry
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,11 +157,11 @@ files:
|
|
157
157
|
- lib/listen/directory.rb
|
158
158
|
- lib/listen/file.rb
|
159
159
|
- lib/listen/listener.rb
|
160
|
+
- lib/listen/queue_optimizer.rb
|
160
161
|
- lib/listen/record.rb
|
161
162
|
- lib/listen/silencer.rb
|
162
163
|
- lib/listen/tcp.rb
|
163
164
|
- lib/listen/tcp/broadcaster.rb
|
164
|
-
- lib/listen/tcp/listener.rb
|
165
165
|
- lib/listen/tcp/message.rb
|
166
166
|
- lib/listen/version.rb
|
167
167
|
- listen.gemspec
|
data/lib/listen/tcp/listener.rb
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
require 'listen/tcp/broadcaster'
|
2
|
-
require 'listen/tcp/message'
|
3
|
-
|
4
|
-
module Listen
|
5
|
-
module TCP
|
6
|
-
class Listener < Listen::Listener
|
7
|
-
DEFAULT_HOST = 'localhost'
|
8
|
-
|
9
|
-
attr_reader :host, :mode, :port
|
10
|
-
|
11
|
-
# Initializes a listener to broadcast or receive modifications over TCP
|
12
|
-
#
|
13
|
-
# @param [String/Fixnum] target to listen on (hostname:port or port)
|
14
|
-
# @param [Symbol] mode (either :broadcaster or :recipient)
|
15
|
-
#
|
16
|
-
# @param (see Listen::Listener#new)
|
17
|
-
#
|
18
|
-
def initialize(target, mode, *args, &block)
|
19
|
-
self.mode = mode
|
20
|
-
self.target = target
|
21
|
-
|
22
|
-
super *args, &block
|
23
|
-
end
|
24
|
-
|
25
|
-
def broadcaster?
|
26
|
-
@mode == :broadcaster
|
27
|
-
end
|
28
|
-
|
29
|
-
def recipient?
|
30
|
-
@mode == :recipient
|
31
|
-
end
|
32
|
-
|
33
|
-
# Initializes and starts TCP broadcaster
|
34
|
-
def start
|
35
|
-
super
|
36
|
-
if broadcaster?
|
37
|
-
supervisor.add(Broadcaster, as: :broadcaster, args: [host, port])
|
38
|
-
registry[:broadcaster].start
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Hook to broadcast changes over TCP
|
43
|
-
def block
|
44
|
-
if broadcaster?
|
45
|
-
proc do |modified, added, removed|
|
46
|
-
|
47
|
-
# Honour paused and stopped states
|
48
|
-
next if @paused || @stopping
|
49
|
-
|
50
|
-
# Broadcast changes as a hash
|
51
|
-
#
|
52
|
-
# @see Listen::Adapter::TCP#handle_message
|
53
|
-
message = Message.new(
|
54
|
-
modified: modified,
|
55
|
-
added: added,
|
56
|
-
removed: removed)
|
57
|
-
|
58
|
-
registry[:broadcaster].async.broadcast(message.payload)
|
59
|
-
|
60
|
-
# Invoke the original callback block
|
61
|
-
@block.call(modified, added, removed) if @block
|
62
|
-
end
|
63
|
-
else
|
64
|
-
super
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
private
|
69
|
-
|
70
|
-
def _init_options(options = {})
|
71
|
-
options = super(options)
|
72
|
-
options[:force_tcp] = true if recipient?
|
73
|
-
options
|
74
|
-
end
|
75
|
-
|
76
|
-
# Sets listener mode
|
77
|
-
#
|
78
|
-
# @param [Symbol] mode (either :broadcaster or :recipient)
|
79
|
-
#
|
80
|
-
def mode=(mode)
|
81
|
-
unless [:broadcaster, :recipient].include? mode
|
82
|
-
fail ArgumentError, 'TCP::Listener requires mode to be either'\
|
83
|
-
' :broadcaster or :recipient'
|
84
|
-
end
|
85
|
-
@mode = mode
|
86
|
-
end
|
87
|
-
|
88
|
-
# Sets listener target
|
89
|
-
#
|
90
|
-
# @param [String/Fixnum] target to listen on (hostname:port or port)
|
91
|
-
#
|
92
|
-
def target=(target)
|
93
|
-
unless target
|
94
|
-
fail ArgumentError, 'TCP::Listener requires target to be given'
|
95
|
-
end
|
96
|
-
|
97
|
-
@host = DEFAULT_HOST if recipient?
|
98
|
-
|
99
|
-
if target.is_a? Fixnum
|
100
|
-
@port = target
|
101
|
-
else
|
102
|
-
@host, @port = target.split(':')
|
103
|
-
@port = @port.to_i
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|