-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Listen | ||
module Adapter | ||
class SimulatedDarwin < Linux | ||
def self.usable? | ||
os = RbConfig::CONFIG['target_os'] | ||
return false unless const_get('OS_REGEXP') =~ os | ||
/1|true/ =~ ENV['LISTEN_GEM_SIMULATE_FSEVENT'] | ||
end | ||
|
||
def _process_event(dir, event) | ||
# NOTE: avoid using event.absolute_name since new API | ||
# will need to have a custom recursion implemented | ||
# to properly match events to configured directories | ||
path = Pathname.new(event.watcher.path) + event.name | ||
rel_path = path.relative_path_from(dir).to_s | ||
|
||
_log :debug, "fake_fsevent: #{rel_path} (#{event.flags.inspect})" | ||
|
||
@darwin ||= Class.new(Darwin) do | ||
def _configure(dir, &callback) | ||
end | ||
end.new({mq: @mq}) | ||
|
||
if (event.flags & [:moved_to, :moved_from]) || _dir_event?(event) | ||
rel_path = path.dirname.relative_path_from(dir).to_s | ||
@darwin.send(:_process_event, dir, [(dir + rel_path).to_s + "/"]) | ||
else | ||
@darwin.send(:_process_event, dir, [(dir + rel_path).to_s + "/"]) | ||
end | ||
end | ||
end | ||
end | ||
end |