Class: Octodown::Support::Services::Riposter

Inherits:
Object
  • Object
show all
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
# File 'lib/octodown/support/services/riposter.rb', line 5

def self.call(file, &listener_callback)
  require 'listen'

  path = File.dirname(File.expand_path(file.path))
  regex = Regexp.new(file.path)

  @listener ||= Listen.to(path, only: regex) do
    listener_callback.call
  end

  @listener.start
end