Class: Compass::Commands::WatchProject
- Inherits:
-
UpdateProject
- Object
- Base
- UpdateProject
- Compass::Commands::WatchProject
- Defined in:
- lib/compass/commands/watch_project.rb
Instance Attribute Summary collapse
-
#last_update_time ⇒ Object
Returns the value of attribute last_update_time.
Attributes inherited from UpdateProject
#options, #project_css_subdirectory, #project_directory, #project_name, #project_src_subdirectory
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from UpdateProject
#compile, #initialize, #output_style, #project_src_directory, #sass_load_paths
Methods inherited from Base
Constructor Details
This class inherits a constructor from Compass::Commands::UpdateProject
Instance Attribute Details
#last_update_time ⇒ Object
Returns the value of attribute last_update_time.
11 12 13 |
# File 'lib/compass/commands/watch_project.rb', line 11 def last_update_time @last_update_time end |
Instance Method Details
#most_recent_update_time ⇒ Object
30 31 32 |
# File 'lib/compass/commands/watch_project.rb', line 30 def most_recent_update_time Dir.glob(separate("#{project_src_directory}/**/*.sass")).map {|sass_file| File.stat(sass_file).mtime}.max end |
#perform ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/compass/commands/watch_project.rb', line 12 def perform super self.last_update_time = most_recent_update_time loop do # TODO: Make this efficient by using filesystem monitoring. sleep 1 file, t = should_update? if t begin puts ">>> Change detected to #{file} <<<" super rescue StandardError => e ::Compass::Exec.report_error(e, ) end self.last_update_time = t end end end |
#should_update? ⇒ Boolean
33 34 35 36 37 38 39 |
# File 'lib/compass/commands/watch_project.rb', line 33 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 |