Sha256: f59ca4c7e7e9f916177911163234bf1d8237b46fd9b5cc46aef3f4567a43e7b7
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'listen' module SmallVictories class Watcher attr_accessor :compiler def initialize attributes={} self.compiler = attributes[:compiler] end def build_listener Listen.to( compiler.config.full_source_path, force_polling: true, ignore: [/#{compiler.config.destination}/], &(listen_handler) ) end def listen_handler proc do |modified, added, removed| paths = modified + added + removed extensions = paths.map{ |path| File.extname(path) } extensions.uniq.each do |ext| case ext when '.scss', '.sass', '.css' compiler.compile_css when '.coffee', '.js' compiler.compile_js when '.liquid', '.html' compiler.compile_html else end end end end def watch SmallVictories.logger.debug "👋" SmallVictories.logger.debug "👀" listener = build_listener listener.start trap("INT") do listener.stop puts "✋ Halting auto-regeneration." exit 0 end sleep_forever rescue ThreadError # Ctrl-C end def sleep_forever loop { sleep 1000 } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smallvictories-0.0.5 | lib/smallvictories/watcher.rb |