listen 2.7.4 → 2.7.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +232 -0
  3. data/.travis.yml +6 -3
  4. data/Gemfile +9 -1
  5. data/Guardfile +6 -1
  6. data/README.md +17 -4
  7. data/lib/listen.rb +9 -4
  8. data/lib/listen/adapter.rb +5 -7
  9. data/lib/listen/adapter/base.rb +8 -5
  10. data/lib/listen/adapter/bsd.rb +58 -21
  11. data/lib/listen/adapter/darwin.rb +2 -4
  12. data/lib/listen/adapter/linux.rb +20 -10
  13. data/lib/listen/adapter/polling.rb +0 -2
  14. data/lib/listen/adapter/tcp.rb +6 -5
  15. data/lib/listen/adapter/windows.rb +8 -6
  16. data/lib/listen/change.rb +1 -2
  17. data/lib/listen/cli.rb +25 -22
  18. data/lib/listen/directory.rb +8 -6
  19. data/lib/listen/listener.rb +25 -19
  20. data/lib/listen/record.rb +4 -2
  21. data/lib/listen/silencer.rb +55 -25
  22. data/lib/listen/tcp.rb +9 -0
  23. data/lib/listen/tcp/broadcaster.rb +0 -2
  24. data/lib/listen/tcp/listener.rb +13 -8
  25. data/lib/listen/tcp/message.rb +0 -2
  26. data/lib/listen/version.rb +1 -1
  27. data/listen.gemspec +4 -3
  28. data/spec/acceptance/listen_spec.rb +190 -109
  29. data/spec/acceptance/tcp_spec.rb +28 -26
  30. data/spec/lib/listen/adapter/base_spec.rb +14 -12
  31. data/spec/lib/listen/adapter/bsd_spec.rb +5 -2
  32. data/spec/lib/listen/adapter/darwin_spec.rb +5 -2
  33. data/spec/lib/listen/adapter/linux_spec.rb +40 -25
  34. data/spec/lib/listen/adapter/polling_spec.rb +29 -14
  35. data/spec/lib/listen/adapter/tcp_spec.rb +24 -6
  36. data/spec/lib/listen/adapter/windows_spec.rb +5 -2
  37. data/spec/lib/listen/adapter_spec.rb +20 -17
  38. data/spec/lib/listen/change_spec.rb +36 -26
  39. data/spec/lib/listen/directory_spec.rb +128 -71
  40. data/spec/lib/listen/file_spec.rb +67 -34
  41. data/spec/lib/listen/listener_spec.rb +135 -105
  42. data/spec/lib/listen/record_spec.rb +32 -29
  43. data/spec/lib/listen/silencer_spec.rb +78 -56
  44. data/spec/lib/listen/tcp/broadcaster_spec.rb +3 -2
  45. data/spec/lib/listen/tcp/listener_spec.rb +17 -11
  46. data/spec/lib/listen/tcp/message_spec.rb +1 -1
  47. data/spec/lib/listen_spec.rb +18 -6
  48. data/spec/spec_helper.rb +5 -1
  49. data/spec/support/acceptance_helper.rb +3 -3
  50. data/spec/support/fixtures_helper.rb +10 -9
  51. metadata +17 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 959fbba40046ffb9eed7759c7c3169bfbd5c592a
4
- data.tar.gz: e3a755884abdc5e53bba22a87afaf4c167ddc9d7
3
+ metadata.gz: f2b1fec6652b9c788556648b883430623b4953d2
4
+ data.tar.gz: 84e2262d6b7952b3afdb08defa5035604718f2f9
5
5
  SHA512:
6
- metadata.gz: 2f1a7354c43c2f29405183e81d5497241e3238acb3cb6b3b4987c720125b1dcc09f64ef29ef704985116008b32a63f35a53ea2d97c075a0451daa0c9904ab6e5
7
- data.tar.gz: 73755c82578e92f4d6a2111a30445c4cd7c9a40c9399347da5d37c7ef68a7cd373d17381a1c24cff517a9936ab799ac564e3dc6ef698a73dcd4ef55b69113313
6
+ metadata.gz: 3b7d31da3edbb75296f7bc8f174c192c9317f87295c13eca6081fbac78793b8b28a9d88851e00f9b74dce5cff508d6bf31ab5e552e1fb1f941160589809a8aba
7
+ data.tar.gz: 6d4df130ce978ecbbb46069030d1a7324aac5624719c2129d570e6fb7b5553035e4c44dd3c5a9618ec07d2bae9bc6a0099b44dbe448c4b90355ac08620d9ddcd
data/.rubocop.yml ADDED
@@ -0,0 +1,232 @@
1
+ AccessorMethodName:
2
+ Enabled: false
3
+
4
+ Alias:
5
+ Enabled: false
6
+
7
+ ArrayJoin:
8
+ Enabled: false
9
+
10
+ AsciiComments:
11
+ Enabled: false
12
+
13
+ AsciiIdentifiers:
14
+ Enabled: false
15
+
16
+ Attr:
17
+ Enabled: false
18
+
19
+ BlockNesting:
20
+ Enabled: false
21
+
22
+ CaseEquality:
23
+ Enabled: false
24
+
25
+ CharacterLiteral:
26
+ Enabled: false
27
+
28
+ ClassLength:
29
+ Enabled: false
30
+
31
+ ClassVars:
32
+ Enabled: false
33
+
34
+ CollectionMethods:
35
+ PreferredMethods:
36
+ find: detect
37
+ reduce: inject
38
+ collect: map
39
+ find_all: select
40
+
41
+ ColonMethodCall:
42
+ Enabled: false
43
+
44
+ CommentAnnotation:
45
+ Enabled: false
46
+
47
+ CyclomaticComplexity:
48
+ Enabled: false
49
+
50
+ Delegate:
51
+ Enabled: false
52
+
53
+ DeprecatedHashMethods:
54
+ Enabled: false
55
+
56
+ Documentation:
57
+ Enabled: false
58
+
59
+ DotPosition:
60
+ EnforcedStyle: trailing
61
+
62
+ DoubleNegation:
63
+ Enabled: false
64
+
65
+ EmptyLiteral:
66
+ Enabled: false
67
+
68
+ Encoding:
69
+ Enabled: false
70
+
71
+ EvenOdd:
72
+ Enabled: false
73
+
74
+ FileName:
75
+ Enabled: false
76
+
77
+ FlipFlop:
78
+ Enabled: false
79
+
80
+ FormatString:
81
+ Enabled: false
82
+
83
+ GlobalVars:
84
+ Enabled: false
85
+
86
+ IfUnlessModifier:
87
+ Enabled: false
88
+
89
+ IfWithSemicolon:
90
+ Enabled: false
91
+
92
+ Lambda:
93
+ Enabled: false
94
+
95
+ LambdaCall:
96
+ Enabled: false
97
+
98
+ LineEndConcatenation:
99
+ Enabled: false
100
+
101
+ LineLength:
102
+ Max: 80
103
+
104
+ MethodLength:
105
+ Enabled: false
106
+
107
+ ModuleFunction:
108
+ Enabled: false
109
+
110
+ NegatedIf:
111
+ Enabled: false
112
+
113
+ NegatedWhile:
114
+ Enabled: false
115
+
116
+ NilComparison:
117
+ Enabled: false
118
+
119
+ Not:
120
+ Enabled: false
121
+
122
+ NumericLiterals:
123
+ Enabled: false
124
+
125
+ OneLineConditional:
126
+ Enabled: false
127
+
128
+ OpMethod:
129
+ Enabled: false
130
+
131
+ ParameterLists:
132
+ Enabled: false
133
+
134
+ PercentLiteralDelimiters:
135
+ PreferredDelimiters:
136
+ '%': '{}'
137
+
138
+ PerlBackrefs:
139
+ Enabled: false
140
+
141
+ PredicateName:
142
+ NamePrefixBlacklist:
143
+ - is_
144
+
145
+ Proc:
146
+ Enabled: false
147
+
148
+ RaiseArgs:
149
+ Enabled: false
150
+
151
+ RegexpLiteral:
152
+ Enabled: false
153
+
154
+ SelfAssignment:
155
+ Enabled: false
156
+
157
+ SingleLineBlockParams:
158
+ Enabled: false
159
+
160
+ SingleLineMethods:
161
+ Enabled: false
162
+
163
+ SpecialGlobalVars:
164
+ Enabled: false
165
+
166
+ VariableInterpolation:
167
+ Enabled: false
168
+
169
+ TrailingComma:
170
+ Enabled: false
171
+
172
+ TrivialAccessors:
173
+ Enabled: false
174
+
175
+ VariableInterpolation:
176
+ Enabled: false
177
+
178
+ WhenThen:
179
+ Enabled: false
180
+
181
+ WhileUntilModifier:
182
+ Enabled: false
183
+
184
+ WordArray:
185
+ Enabled: false
186
+
187
+ # Lint
188
+
189
+ AmbiguousOperator:
190
+ Enabled: false
191
+
192
+ AmbiguousRegexpLiteral:
193
+ Enabled: false
194
+
195
+ AssignmentInCondition:
196
+ Enabled: false
197
+
198
+ ConditionPosition:
199
+ Enabled: false
200
+
201
+ DeprecatedClassMethods:
202
+ Enabled: false
203
+
204
+ ElseLayout:
205
+ Enabled: false
206
+
207
+ HandleExceptions:
208
+ Enabled: false
209
+
210
+ InvalidCharacterLiteral:
211
+ Enabled: false
212
+
213
+ LiteralInCondition:
214
+ Enabled: false
215
+
216
+ LiteralInInterpolation:
217
+ Enabled: false
218
+
219
+ Loop:
220
+ Enabled: false
221
+
222
+ ParenthesesAsGroupedExpression:
223
+ Enabled: false
224
+
225
+ RequireParentheses:
226
+ Enabled: false
227
+
228
+ UnderscorePrefixedVariableName:
229
+ Enabled: false
230
+
231
+ Void:
232
+ Enabled: false
data/.travis.yml CHANGED
@@ -3,14 +3,17 @@ bundler_args: --without tool
3
3
  rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
- - 2.1.0
6
+ - 2.1.2
7
7
  - jruby
8
- - rbx
8
+ - rbx-2
9
9
  matrix:
10
10
  allow_failures:
11
11
  - rvm: jruby
12
- - rvm: rbx
12
+ - rvm: rbx-2
13
13
  notifications:
14
14
  recipients:
15
15
  - thibaud@thibaud.gg
16
16
  - remy@rymai.me
17
+ os:
18
+ - linux
19
+ - osx
data/Gemfile CHANGED
@@ -4,11 +4,19 @@ gemspec
4
4
 
5
5
  require 'rbconfig'
6
6
  gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i
7
- gem 'rb-kqueue', '>= 0.2' if RbConfig::CONFIG['target_os'] =~ /freebsd/i
7
+
8
+ if RbConfig::CONFIG['target_os'] =~ /bsd|dragonfly/i
9
+ gem 'rb-kqueue', '>= 0.2'
10
+ # Versions not included have known bugs
11
+ # Even master branches may not work...
12
+ gem 'ffi', github: 'carpetsmoker/ffi', ref: 'ac63e07f7'
13
+ gem 'celluloid', github: 'celluloid/celluloid', ref: '7fdef04'
14
+ end
8
15
 
9
16
  group :tool do
10
17
  gem 'yard', require: false
11
18
  gem 'guard-rspec', require: false
19
+ gem 'guard-rubocop'
12
20
  end
13
21
 
14
22
  group :test do
data/Guardfile CHANGED
@@ -1,6 +1,11 @@
1
- guard :rspec do
1
+ guard :rspec, cmd: 'bundle exec rspec', failed_mode: :keep do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
4
  watch(%r{^spec/support/*}) { 'spec' }
5
5
  watch('spec/spec_helper.rb') { 'spec' }
6
6
  end
7
+
8
+ guard :rubocop, all_on_start: false, cli: '--rails' do
9
+ watch(%r{.+\.rb$}) { |m| m[0] }
10
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
11
+ end
data/README.md CHANGED
@@ -7,7 +7,7 @@ The Listen gem listens to file modifications and notifies you about the changes.
7
7
  ## Features
8
8
 
9
9
  * Supports watching multiple directories from a single listener.
10
- * OS-specific adapters on MRI for Mac OS X 10.6+, Linux, *BSD and Windows, [more info](#listen-adapters) below.
10
+ * OS-specific adapters on MRI for Mac OS X 10.6+, Linux, ~~\*BSD~~ and Windows, [more info](#listen-adapters) below.
11
11
  * Detects file modification, addition and removal.
12
12
  * Allows supplying regexp-patterns to ignore paths for better results.
13
13
  * File content checksum comparison for modifications made under the same second (OS X only).
@@ -16,7 +16,9 @@ The Listen gem listens to file modifications and notifies you about the changes.
16
16
 
17
17
  Please note that:
18
18
  - Specs suite on JRuby and Rubinius aren't reliable on Travis CI, but should work.
19
- - Windows and *BSD adapter aren't continuously and automaticaly tested.
19
+ - Windows and \*BSD adapter aren't continuously and automaticaly tested.
20
+ - \*BSD is broken and not supported any more, see: [#220](https://github.com/guard/listen/issues/220)
21
+
20
22
 
21
23
  ## Pending features
22
24
 
@@ -154,7 +156,7 @@ Also, setting the environment variable `LISTEN_GEM_DEBUGGING=1` does the same as
154
156
  ## Listen adapters
155
157
 
156
158
  The Listen gem has a set of adapters to notify it when there are changes.
157
- There are 4 OS-specific adapters to support Darwin, Linux, *BSD and Windows.
159
+ There are 4 OS-specific adapters to support Darwin, Linux, ~~*BSD~~ and Windows.
158
160
  These adapters are fast as they use some system-calls to implement the notifying function.
159
161
 
160
162
  There is also a polling adapter which is a cross-platform adapter and it will
@@ -178,12 +180,23 @@ gem 'wdm', '>= 0.1.0' if RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i
178
180
 
179
181
  ### On *BSD
180
182
 
183
+ **NOTE: *BSD currently is BROKEN with no plans to fix it or support it (see: [#220](https://github.com/guard/listen/issues/220))**
184
+
181
185
  If your are on *BSD you can try to use the [`rb-kqueue`](https://github.com/mat813/rb-kqueue) instead of polling.
182
186
  Please add the following to your Gemfile:
183
187
 
184
188
  ```ruby
185
189
  require 'rbconfig'
186
- gem 'rb-kqueue', '>= 0.2' if RbConfig::CONFIG['target_os'] =~ /freebsd/i
190
+ gem 'rb-kqueue', '>= 0.2'
191
+ if RbConfig::CONFIG['target_os'] =~ /bsd|dragonfly/i
192
+ gem 'rb-kqueue', '>= 0.2'
193
+
194
+ # Base versions have known conflicts/bugs
195
+ # Even master branches may not work...
196
+ gem 'ffi', github: 'carpetsmoker/ffi', ref: 'ac63e07f7'
197
+ gem 'celluloid', github: 'celluloid/celluloid', ref: '7fdef04'
198
+ end
199
+
187
200
  ```
188
201
 
189
202
  ### Issues
data/lib/listen.rb CHANGED
@@ -1,14 +1,15 @@
1
1
  require 'celluloid'
2
2
  require 'listen/listener'
3
- require 'listen/tcp/listener'
4
3
 
5
4
  module Listen
6
5
  class << self
7
6
  attr_accessor :stopping
8
7
 
9
- # Listens to file system modifications on a either single directory or multiple directories.
8
+ # Listens to file system modifications on a either single directory or
9
+ # multiple directories.
10
10
  #
11
- # When :forward_to is specified, this listener will broadcast modifications over TCP.
11
+ # When :forward_to is specified, this listener will broadcast modifications
12
+ # over TCP.
12
13
  #
13
14
  # @param (see Listen::Listener#new)
14
15
  #
@@ -24,6 +25,7 @@ module Listen
24
25
  @stopping = false
25
26
  options = args.last.is_a?(Hash) ? args.last : {}
26
27
  if target = options.delete(:forward_to)
28
+ require 'listen/tcp'
27
29
  TCP::Listener.new(target, :broadcaster, *args, &block)
28
30
  else
29
31
  Listener.new(*args, &block)
@@ -31,7 +33,9 @@ module Listen
31
33
  end
32
34
 
33
35
  # Stop all listeners & Celluloid
34
- # Use it for testing purpose or when you are sure that Celluloid could be ended.
36
+ #
37
+ # Use it for testing purpose or when you are sure that Celluloid could be
38
+ # ended.
35
39
  #
36
40
  def stop
37
41
  Celluloid.shutdown
@@ -49,6 +53,7 @@ module Listen
49
53
  # @return [Listen::Listener] the listener
50
54
  #
51
55
  def on(target, *args, &block)
56
+ require 'listen/tcp'
52
57
  TCP::Listener.new(target, :recipient, *args, &block)
53
58
  end
54
59
 
@@ -3,13 +3,13 @@ require 'listen/adapter/bsd'
3
3
  require 'listen/adapter/darwin'
4
4
  require 'listen/adapter/linux'
5
5
  require 'listen/adapter/polling'
6
- require 'listen/adapter/tcp'
7
6
  require 'listen/adapter/windows'
8
7
 
9
8
  module Listen
10
9
  module Adapter
11
- OPTIMIZED_ADAPTERS = %w[Darwin Linux BSD Windows]
12
- POLLING_FALLBACK_MESSAGE = "Listen will be polling for changes. Learn more at https://github.com/guard/listen#polling-fallback."
10
+ OPTIMIZED_ADAPTERS = %w(Darwin Linux BSD Windows)
11
+ POLLING_FALLBACK_MESSAGE = 'Listen will be polling for changes.'\
12
+ 'Learn more at https://github.com/guard/listen#polling-fallback.'
13
13
 
14
14
  def self.select(options = {})
15
15
  return TCP if options[:force_tcp]
@@ -28,10 +28,8 @@ module Listen
28
28
  end
29
29
 
30
30
  def self._warn_polling_fallback(options)
31
- return if options[:polling_fallback_message] == false
32
-
33
- warning = options.fetch(:polling_fallback_message, POLLING_FALLBACK_MESSAGE)
34
- Kernel.warn "[Listen warning]:\n #{warning}"
31
+ msg = options.fetch(:polling_fallback_message, POLLING_FALLBACK_MESSAGE)
32
+ Kernel.warn "[Listen warning]:\n #{msg}" if msg
35
33
  end
36
34
  end
37
35
  end
@@ -1,6 +1,5 @@
1
1
  module Listen
2
2
  module Adapter
3
-
4
3
  class Base
5
4
  include Celluloid
6
5
 
@@ -14,11 +13,15 @@ module Listen
14
13
  end
15
14
 
16
15
  def self.usable?
17
- raise NotImplementedError
16
+ fail NotImplementedError
18
17
  end
19
18
 
20
19
  def start
21
- raise NotImplementedError
20
+ fail NotImplementedError
21
+ end
22
+
23
+ def self.local_fs?
24
+ true
22
25
  end
23
26
 
24
27
  private
@@ -33,9 +36,9 @@ module Listen
33
36
 
34
37
  def _notify_change(path, options)
35
38
  sleep 0.01 until listener.registry[:change_pool]
36
- listener.registry[:change_pool].async.change(path, options) if listener.listen?
39
+ pool = listener.registry[:change_pool]
40
+ pool.async.change(path, options) if listener.listen?
37
41
  end
38
42
  end
39
-
40
43
  end
41
44
  end