Sha256: ced3452db693f484a865bac8113072cf65f800c504107f325c8af8d131efa07f

Contents?: true

Size: 989 Bytes

Versions: 1

Compression:

Stored size: 989 Bytes

Contents

module Runter
  class Watcher
    def initialize(json) 
      @files         = []
      @name          = json["name"]
      @singleActions = json["singleFileActions"]
      @bulkActions   = json["bulkActions"]
      @files         = []
      load_files(json["src"])
    end
    def load_files(watchPaths)
      watchPaths.each{|path|
        Dir[path].each{|file|
          @files.push("./#{file}")
        }
      }
    end
    def get_watch_files() 
      return @files
    end
    def handle_change(file) 
      if(@files.include?(file))
        perform_single_actions(file)
        perform_bulk_actions(file)
      end
    end
    def perform_single_actions(file)
      @singleActions.each{|action|
        action.gsub! "$1", file
        Runter::Shell.execute(action)
      }
    end
    def perform_bulk_actions(file)
      return if @bulkActions == nil
      @bulkActions.each{|action| 
        action.gsub! "$1", file
        Runter::Shell.execute(action)
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
runter-0.1.0 lib/runter/watcher.rb