listen 3.0.7 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13a975f7ef6b99aac535ba9cd1d8889b3576039d
4
- data.tar.gz: 0dae5d3ca08ece9bcc92895c370cdffc45397868
3
+ metadata.gz: f18e337415a04b4714aa6a4b52bbf21a7c8a3d01
4
+ data.tar.gz: e70d968dd1f9d350a35d319bd932c521d15e0b75
5
5
  SHA512:
6
- metadata.gz: 366af3ba431e4a21473035a7c3a8e9431da5a5d6b440283edd3185f05fd53d616496fcbf0898f5888924d04d12c8fb95f14a6bb3ee907e5132ca3ab9e1da9d67
7
- data.tar.gz: f57d099f93115b1de4c42b6e7abb4b0d6ec96075b4f9731736f84dbb41b0217975164d48547803cf0c974cdbf39156df5621472dd503a07b37c1cadbdedb379e
6
+ metadata.gz: 3a84d19f4ecc7131d6ccfddf937c77f8d05b786a4b84d05bbf0808efd16d3066ecff5b2d25c511b3ac7fe70d73ad208f748a1236edc92ccb7bd8ec9f82b832b0
7
+ data.tar.gz: 5bbab04e17fa7e957343cad614936a59ea822af8e4a77657317b40a854f6fa3b8c0b2c26e7480b3fcd8e71129cdcdc0e66219c412a9e27f94e66df04b4792fc9
@@ -6,17 +6,34 @@ module Listen
6
6
  # Adapter implementation for Mac OS X `FSEvents`.
7
7
  #
8
8
  class Darwin < Base
9
- OS_REGEXP = /darwin(1.+)?$/i
9
+ OS_REGEXP = /darwin(?<major_version>1\d+)/i
10
10
 
11
11
  # The default delay between checking for changes.
12
12
  DEFAULTS = { latency: 0.1 }
13
13
 
14
+ INCOMPATIBLE_GEM_VERSION = <<-EOS.gsub(/^ {8}/, '')
15
+ rb-fsevent > 0.9.4 no longer supports OS X 10.6 through 10.8.
16
+
17
+ Please add the following to your Gemfile to avoid polling for changes:
18
+ require 'rbconfig'
19
+ if RbConfig::CONFIG['target_os'] =~ /darwin(1[0-3])/i
20
+ gem 'rb-fsevent', '<= 0.9.4'
21
+ end
22
+ EOS
23
+
24
+ def self.usable?
25
+ require 'rb-fsevent'
26
+ darwin_version = RbConfig::CONFIG['target_os'][OS_REGEXP, :major_version] or return false
27
+ return true if darwin_version.to_i >= 13 # darwin13 is OS X 10.9
28
+ return true if Gem::Version.new(FSEvent::VERSION) <= Gem::Version.new('0.9.4')
29
+ Kernel.warn INCOMPATIBLE_GEM_VERSION
30
+ false
31
+ end
32
+
14
33
  private
15
34
 
16
35
  # NOTE: each directory gets a DIFFERENT callback!
17
36
  def _configure(dir, &callback)
18
- require 'rb-fsevent'
19
-
20
37
  opts = { latency: options.latency }
21
38
 
22
39
  @workers ||= ::Queue.new
@@ -35,7 +35,9 @@ module Listen
35
35
  end
36
36
 
37
37
  def _run
38
+ Thread.current[:listen_blocking_read_thread] = true
38
39
  @worker.run
40
+ Thread.current[:listen_blocking_read_thread] = false
39
41
  end
40
42
 
41
43
  def _process_event(dir, event)
@@ -99,7 +101,7 @@ module Listen
99
101
  end
100
102
 
101
103
  def _stop
102
- @worker.close
104
+ @worker && @worker.close
103
105
  end
104
106
  end
105
107
  end
@@ -2,6 +2,8 @@ require 'listen/adapter'
2
2
  require 'listen/adapter/base'
3
3
  require 'listen/adapter/config'
4
4
 
5
+ require 'forwardable'
6
+
5
7
  # This class just aggregates configuration object to avoid Listener specs
6
8
  # from exploding with huge test setup blocks
7
9
  module Listen
@@ -12,7 +12,7 @@ module Listen
12
12
 
13
13
  # TODO: use children(with_directory: false)
14
14
  path = dir + rel_path
15
- current = Set.new(path.children)
15
+ current = Set.new(_children(path))
16
16
 
17
17
  Listen::Logger.debug do
18
18
  format('%s: %s(%s): %s -> %s',
@@ -28,7 +28,7 @@ module Listen
28
28
  end
29
29
  rescue Errno::ENOENT
30
30
  # The directory changed meanwhile, so rescan it
31
- current = Set.new(path.children)
31
+ current = Set.new(_children(path))
32
32
  retry
33
33
  end
34
34
 
@@ -72,5 +72,16 @@ module Listen
72
72
  opts.delete(:recursive)
73
73
  snapshot.invalidate(type, path, opts)
74
74
  end
75
+
76
+ def self._children(path)
77
+ return path.children unless RUBY_ENGINE == 'jruby'
78
+
79
+ # JRuby inconsistency workaround, see:
80
+ # https://github.com/jruby/jruby/issues/3840
81
+ exists = path.exist?
82
+ directory = path.directory?
83
+ return path.children unless (exists && !directory)
84
+ raise Errno::ENOTDIR, path.to_s
85
+ end
75
86
  end
76
87
  end
@@ -1,5 +1,7 @@
1
1
  require 'thread'
2
2
 
3
+ require 'forwardable'
4
+
3
5
  module Listen
4
6
  module Event
5
7
  class Queue
@@ -13,8 +13,16 @@ module Listen
13
13
  return if @threads.empty? # return to avoid using possibly stubbed Queue
14
14
 
15
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
+
16
21
  killed << @threads.pop.kill until @threads.empty?
17
- killed.pop.join until killed.empty?
22
+ until killed.empty?
23
+ th = killed.pop
24
+ th.join(*limit) unless th[:listen_blocking_read_thread]
25
+ end
18
26
  end
19
27
  end
20
28
  end
@@ -61,7 +61,7 @@ module Listen
61
61
 
62
62
  default_state :initializing
63
63
 
64
- state :initializing, to: :backend_started
64
+ state :initializing, to: [:backend_started, :stopped]
65
65
 
66
66
  state :backend_started, to: [:frontend_ready, :stopped] do
67
67
  backend.start
@@ -13,7 +13,7 @@ module Listen
13
13
 
14
14
  def children
15
15
  child_relative = _join
16
- (Dir.entries(sys_path) - %w(. ..)).map do |name|
16
+ (_entries(sys_path) - %w(. ..)).map do |name|
17
17
  Entry.new(@root, child_relative, name)
18
18
  end
19
19
  end
@@ -46,6 +46,17 @@ module Listen
46
46
  args = [@relative, @name].compact
47
47
  args.empty? ? nil : ::File.join(*args)
48
48
  end
49
+
50
+ def _entries(dir)
51
+ return Dir.entries(dir) unless RUBY_ENGINE == 'jruby'
52
+
53
+ # JRuby inconsistency workaround, see:
54
+ # https://github.com/jruby/jruby/issues/3840
55
+ exists = ::File.exist?(dir)
56
+ directory = ::File.directory?(dir)
57
+ return Dir.entries(dir) unless (exists && !directory)
58
+ raise Errno::ENOTDIR, dir
59
+ end
49
60
  end
50
61
  end
51
62
  end
@@ -1,3 +1,3 @@
1
1
  module Listen
2
- VERSION = '3.0.7'
2
+ VERSION = '3.0.8'
3
3
  end
metadata CHANGED
@@ -1,33 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: listen
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.7
4
+ version: 3.0.8
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: 2016-04-30 00:00:00.000000000 Z
11
+ date: 2016-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb-fsevent
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
17
20
  - - ">="
18
21
  - !ruby/object:Gem::Version
19
- version: 0.9.3
22
+ version: 0.9.4
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.9'
24
30
  - - ">="
25
31
  - !ruby/object:Gem::Version
26
- version: 0.9.3
32
+ version: 0.9.4
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rb-inotify
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.9'
31
40
  - - ">="
32
41
  - !ruby/object:Gem::Version
33
42
  version: 0.9.7
@@ -35,6 +44,9 @@ dependencies:
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.9'
38
50
  - - ">="
39
51
  - !ruby/object:Gem::Version
40
52
  version: 0.9.7
@@ -116,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
128
  version: '0'
117
129
  requirements: []
118
130
  rubyforge_project:
119
- rubygems_version: 2.2.2
131
+ rubygems_version: 2.5.1
120
132
  signing_key:
121
133
  specification_version: 4
122
134
  summary: Listen to file modifications