class KiskoSuits::Watcher
Attributes
initial_filename[R]
on_update[R]
watched_paths[R]
Public Class Methods
new(initial_filename, on_update)
click to toggle source
# File lib/kisko-suits/watcher.rb, line 7 def initialize(initial_filename, on_update) @initial_filename = initial_filename @on_update = on_update @watched_paths = Set.new end
Public Instance Methods
start()
click to toggle source
# File lib/kisko-suits/watcher.rb, line 13 def start process_path(initial_filename) add_path(initial_filename) watch end
Private Instance Methods
add_path(filename)
click to toggle source
# File lib/kisko-suits/watcher.rb, line 42 def add_path(filename) watched_paths << filename end
process_path(path)
click to toggle source
# File lib/kisko-suits/watcher.rb, line 34 def process_path(path) found_paths = on_update.call(path) found_paths.each do |new_filename| add_path(new_filename) end end
watch()
click to toggle source
# File lib/kisko-suits/watcher.rb, line 21 def watch watch_file(watched_paths) end
watch_file(filenames)
click to toggle source
# File lib/kisko-suits/watcher.rb, line 25 def watch_file(filenames) watcher = Filewatcher.new(filenames.to_a) watcher.watch do |changed_filename| process_path(changed_filename) watcher.finalize watch end end