Sha256: eaa91dd18ac71786daf4cb08197fc39f91eefa84ba35c0d0f01904f645cdb240
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
module ArchitectureJS class Watcher attr_accessor :project, :listener def initialize(project) @project = project @listener = Listen.to(@project.root) 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 @listener.ignore(/#{@project.config[:build_dir]}/) end def watch(message = false) @listener.start puts ArchitectureJS::Notification.log message if message 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}/#{@project.config[:build_dir]}/#{f}") if File.exists? "#{@project.root}/#{@project.config[:build_dir]}/#{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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
architecture-js-0.6.2 | lib/architecture-js/watcher.rb |