class Frontsau::Assets::Watcher
Constants
- EXT_MAP
Public Class Methods
new(&callback)
click to toggle source
# File lib/frontsau/assets/watcher.rb, line 12 def initialize &callback @callback = callback @watches = Frontsau.config[:assets][:sources].map{|s| Dir[s] }.flatten.uniq filewatcher() end
Public Instance Methods
filewatcher()
click to toggle source
# File lib/frontsau/assets/watcher.rb, line 18 def filewatcher FileWatcher.new(@watches).watch do |file| next if File.directory? file @watches.each do |p| if p.start_with? p file = file.gsub "#{p}/", "" end file end ext = File.extname file base = File.basename file, ext dir = File.dirname file if EXT_MAP[ext.downcase].present? ext = EXT_MAP[ext.downcase] end @callback.call "#{dir}/#{base}#{ext}" end end
fsevent()
click to toggle source
# File lib/frontsau/assets/watcher.rb, line 37 def fsevent fsevent = FSEvent.new opts = { watch_root: true, file_events: true } fsevent.watch @watches do |path| puts path end fsevent.run end
inotify()
click to toggle source
# File lib/frontsau/assets/watcher.rb, line 49 def inotify notifier = INotify::Notifier.new @watches.each do |path| notifier.watch path do puts "wee #{path}" end end notifier.run end