Class: Octodown::Support::Services::Riposter
- Inherits:
-
Object
- Object
- Octodown::Support::Services::Riposter
- Defined in:
- lib/octodown/support/services/riposter.rb
Class Method Summary collapse
Class Method Details
.call(file, &listener_callback) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/octodown/support/services/riposter.rb', line 5 def self.call(file, &listener_callback) require 'listen' path = File.dirname(File.(file.path)) escaped_path = Regexp.escape(file.path) regex = Regexp.new("^#{escaped_path}$") @listener ||= Listen.to(path, only: regex) do |modified, added, _rm| listener_callback.call if modified.any? || added.any? end @listener.start end |