Sha256: f24dc7e1ab73aaf4d5a604b782be4fc28d4d6e6dd68797d7c644854b8cfd13cf
Contents?: true
Size: 1.44 KB
Versions: 6
Compression:
Stored size: 1.44 KB
Contents
require 'rubygems' require 'sass' require 'fileutils' require 'pathname' require File.join(File.dirname(__FILE__), 'base') require File.join(File.dirname(__FILE__), 'update_project') module Compass module Commands class WatchProject < UpdateProject attr_accessor :last_update_time def perform puts ">>> Compiling all stylesheets." super self.last_update_time = most_recent_update_time puts ">>> Compass is now watching for changes. Press Ctrl-C to Stop." loop do # TODO: Make this efficient by using filesystem monitoring. begin sleep 1 rescue Interrupt puts "" exit 0 end file, t = should_update? if t begin puts ">>> Change detected to: #{file}" super rescue StandardError => e ::Compass::Exec.report_error(e, options) end self.last_update_time = t end end end def most_recent_update_time Dir.glob(separate("#{project_src_directory}/**/*.sass")).map {|sass_file| File.stat(sass_file).mtime}.max end def should_update? t = most_recent_update_time if t > last_update_time file = Dir.glob(separate("#{project_src_directory}/**/*.sass")).detect {|sass_file| File.stat(sass_file).mtime >= t} [file, t] end end end end end
Version data entries
6 entries across 6 versions & 3 rubygems