class Runter::Watcher
Public Class Methods
new(json)
click to toggle source
# File lib/runter/watcher.rb, line 3 def initialize(json) @files = [] @name = json["name"] @singleActions = json["singleFileActions"] @bulkActions = json["bulkActions"] @files = [] load_files(json["src"]) end
Public Instance Methods
get_watch_files()
click to toggle source
# File lib/runter/watcher.rb, line 18 def get_watch_files() return @files end
handle_change(file)
click to toggle source
# File lib/runter/watcher.rb, line 21 def handle_change(file) if(@files.include?(file)) perform_single_actions(file) perform_bulk_actions(file) end end
load_files(watchPaths)
click to toggle source
# File lib/runter/watcher.rb, line 11 def load_files(watchPaths) watchPaths.each{|path| Dir[path].each{|file| @files.push("./#{file}") } } end
perform_bulk_actions(file)
click to toggle source
# File lib/runter/watcher.rb, line 33 def perform_bulk_actions(file) return if @bulkActions == nil @bulkActions.each{|action| action.gsub! "$1", file Runter::Shell.execute(action) } end
perform_single_actions(file)
click to toggle source
# File lib/runter/watcher.rb, line 27 def perform_single_actions(file) @singleActions.each{|action| action.gsub! "$1", file Runter::Shell.execute(action) } end