Class: Listen::Adapter
- Inherits:
-
Object
- Object
- Listen::Adapter
- Defined in:
- lib/listen/adapter.rb
Direct Known Subclasses
Listen::Adapters::Darwin, Listen::Adapters::Linux, Listen::Adapters::Polling, Listen::Adapters::Windows
Constant Summary collapse
- DEFAULT_LATENCY =
The default delay between checking for changes.
0.1
- POLLING_FALLBACK_MESSAGE =
The default warning message when falling back to polling adapter.
"WARNING: Listen fallen back to polling, learn more at https://github.com/guard/listen#fallback."
Instance Attribute Summary collapse
-
#latency ⇒ Object
Returns the value of attribute latency.
Class Method Summary collapse
-
.select_and_initialize(directory, options = {}) {|changed_dirs, options| ... } ⇒ Listen::Adapter
Select the appropriate adapter implementation for the current OS and initializes it.
Instance Method Summary collapse
-
#initialize(directory, options = {}) {|changed_dirs, options| ... } ⇒ Listen::Adapter
constructor
Initialize the adapter.
-
#start ⇒ Object
Start the adapter.
-
#stop ⇒ Object
Stop the adapter.
Constructor Details
#initialize(directory, options = {}) {|changed_dirs, options| ... } ⇒ Listen::Adapter
Initialize the adapter.
56 57 58 59 60 61 |
# File 'lib/listen/adapter.rb', line 56 def initialize(directory, = {}, &callback) @directory = directory @callback = callback @latency ||= DEFAULT_LATENCY @latency = [:latency] if [:latency] end |
Instance Attribute Details
#latency ⇒ Object
Returns the value of attribute latency.
5 6 7 |
# File 'lib/listen/adapter.rb', line 5 def latency @latency end |
Class Method Details
.select_and_initialize(directory, options = {}) {|changed_dirs, options| ... } ⇒ Listen::Adapter
Select the appropriate adapter implementation for the current OS and initializes it.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/listen/adapter.rb', line 27 def self.select_and_initialize(directory, = {}, &callback) return Adapters::Polling.new(directory, , &callback) if .delete(:force_polling) if Adapters::Darwin.usable_and_work?(directory, ) Adapters::Darwin.new(directory, , &callback) elsif Adapters::Linux.usable_and_work?(directory, ) Adapters::Linux.new(directory, , &callback) elsif Adapters::Windows.usable_and_work?(directory, ) Adapters::Windows.new(directory, , &callback) else unless [:polling_fallback_message] == false Kernel.warn([:polling_fallback_message] || POLLING_FALLBACK_MESSAGE) end Adapters::Polling.new(directory, , &callback) end end |
Instance Method Details
#start ⇒ Object
Start the adapter.
65 66 67 |
# File 'lib/listen/adapter.rb', line 65 def start @stop = false end |
#stop ⇒ Object
Stop the adapter.
71 72 73 |
# File 'lib/listen/adapter.rb', line 71 def stop @stop = true end |