Class: Listen::Adapter::Base
- Inherits:
-
Object
- Object
- Listen::Adapter::Base
show all
- Includes:
- Celluloid
- Defined in:
- lib/listen/adapter/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(listener) ⇒ Base
Returns a new instance of Base.
8
9
10
11
12
13
|
# File 'lib/listen/adapter/base.rb', line 8
def initialize(listener)
@listener = listener
rescue
_log :error, "adapter config failed: #{$!}:#{$@.join("\n")}"
raise
end
|
Instance Attribute Details
#listener ⇒ Object
Returns the value of attribute listener.
6
7
8
|
# File 'lib/listen/adapter/base.rb', line 6
def listener
@listener
end
|
Class Method Details
.local_fs? ⇒ Boolean
27
28
29
|
# File 'lib/listen/adapter/base.rb', line 27
def self.local_fs?
true
end
|
.usable? ⇒ Boolean
31
32
33
|
# File 'lib/listen/adapter/base.rb', line 31
def self.usable?
const_get('OS_REGEXP') =~ RbConfig::CONFIG['target_os']
end
|
Instance Method Details
37
38
|
# File 'lib/listen/adapter/base.rb', line 37
def _configure
end
|
#_directories ⇒ Object
40
41
42
|
# File 'lib/listen/adapter/base.rb', line 40
def _directories
listener.directories
end
|
#_log(type, message) ⇒ Object
56
57
58
|
# File 'lib/listen/adapter/base.rb', line 56
def _log(type, message)
Celluloid.logger.send(type, message)
end
|
#_notify_change(type, path, options = {}) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/listen/adapter/base.rb', line 44
def _notify_change(type, path, options = {})
unless (worker = listener.async(:change_pool))
_log :warn, 'Failed to allocate worker from change pool'
return
end
worker.change(type, path, options)
rescue RuntimeError
_log :error, "_notify_change crashed: #{$!}:#{$@.join("\n")}"
raise
end
|
#start ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/listen/adapter/base.rb', line 15
def start
_configure
Thread.new do
begin
_run
rescue
_log :error, "run() in thread failed: #{$!}:#{$@.join("\n")}"
raise
end
end
end
|