listen 2.7.5 → 2.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -0
  3. data/.rspec +0 -0
  4. data/.rubocop.yml +0 -0
  5. data/.travis.yml +0 -1
  6. data/.yardopts +0 -0
  7. data/CHANGELOG.md +0 -0
  8. data/CONTRIBUTING.md +0 -0
  9. data/Gemfile +25 -4
  10. data/Guardfile +0 -0
  11. data/LICENSE.txt +0 -0
  12. data/README.md +18 -10
  13. data/Rakefile +0 -0
  14. data/lib/listen.rb +2 -4
  15. data/lib/listen/adapter.rb +13 -4
  16. data/lib/listen/adapter/base.rb +33 -16
  17. data/lib/listen/adapter/bsd.rb +21 -38
  18. data/lib/listen/adapter/darwin.rb +17 -25
  19. data/lib/listen/adapter/linux.rb +34 -52
  20. data/lib/listen/adapter/polling.rb +9 -25
  21. data/lib/listen/adapter/tcp.rb +27 -14
  22. data/lib/listen/adapter/windows.rb +67 -23
  23. data/lib/listen/change.rb +26 -23
  24. data/lib/listen/cli.rb +0 -0
  25. data/lib/listen/directory.rb +47 -58
  26. data/lib/listen/file.rb +66 -101
  27. data/lib/listen/listener.rb +214 -155
  28. data/lib/listen/queue_optimizer.rb +104 -0
  29. data/lib/listen/record.rb +15 -5
  30. data/lib/listen/silencer.rb +14 -10
  31. data/lib/listen/tcp.rb +0 -1
  32. data/lib/listen/tcp/broadcaster.rb +31 -26
  33. data/lib/listen/tcp/message.rb +2 -2
  34. data/lib/listen/version.rb +1 -1
  35. data/listen.gemspec +1 -1
  36. data/spec/acceptance/listen_spec.rb +151 -239
  37. data/spec/acceptance/tcp_spec.rb +125 -134
  38. data/spec/lib/listen/adapter/base_spec.rb +13 -30
  39. data/spec/lib/listen/adapter/bsd_spec.rb +7 -35
  40. data/spec/lib/listen/adapter/darwin_spec.rb +18 -30
  41. data/spec/lib/listen/adapter/linux_spec.rb +49 -55
  42. data/spec/lib/listen/adapter/polling_spec.rb +20 -35
  43. data/spec/lib/listen/adapter/tcp_spec.rb +25 -27
  44. data/spec/lib/listen/adapter/windows_spec.rb +7 -33
  45. data/spec/lib/listen/adapter_spec.rb +10 -10
  46. data/spec/lib/listen/change_spec.rb +55 -57
  47. data/spec/lib/listen/directory_spec.rb +105 -155
  48. data/spec/lib/listen/file_spec.rb +186 -73
  49. data/spec/lib/listen/listener_spec.rb +233 -216
  50. data/spec/lib/listen/record_spec.rb +60 -22
  51. data/spec/lib/listen/silencer_spec.rb +48 -75
  52. data/spec/lib/listen/tcp/broadcaster_spec.rb +78 -69
  53. data/spec/lib/listen/tcp/listener_spec.rb +28 -71
  54. data/spec/lib/listen/tcp/message_spec.rb +48 -14
  55. data/spec/lib/listen_spec.rb +3 -3
  56. data/spec/spec_helper.rb +6 -3
  57. data/spec/support/acceptance_helper.rb +250 -31
  58. data/spec/support/fixtures_helper.rb +6 -4
  59. data/spec/support/platform_helper.rb +2 -2
  60. metadata +5 -5
  61. 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
- cd(paths.first) if number_of_directories == 1
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'] =~ /freebsd/i
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.5
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-05-15 00:00:00.000000000 Z
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: '2.14'
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: '2.14'
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
@@ -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