Sha256: b29ed08e7d01d216b589408ca110e73ec4e9d8e8c2bb168f72e77c496251c9ed
Contents?: true
Size: 1.12 KB
Versions: 4
Compression:
Stored size: 1.12 KB
Contents
module ArchitectureJS class Watcher attr_accessor :project, :listener def initialize(project) @project = project @listener = Listen.to(@project.root) @listener.ignore(/#{@project.config[:build_dir]}|spec|test/) .filter(/\.jst?$/) .change do |modified, added, removed| update_files(modified, "modified") if modified.length > 0 update_files(added, "added") if added.length > 0 update_files(removed, "deleted") if removed.length > 0 end end def watch @listener.start(false) self end def stop @listener.stop end private def update_files(files, action) files.each do |f| f = File.basename f if action == "deleted" FileUtils.rm_rf("#{@project.root}/#{f}") puts "remove #{@project.root}/#{f}" end puts "\n" << ArchitectureJS::Notification.event("#{f} was #{action}") end @project.read_config @project.update print ArchitectureJS::Notification.prompt end end end
Version data entries
4 entries across 4 versions & 1 rubygems