Watch arbitrary files within the compass configuration file.
This commit is contained in:
parent
8d3b2d92df
commit
ec699c42c8
@ -18,7 +18,11 @@ The Documentation for the [latest preview release](http://beta.compass-style.org
|
||||
---------------------
|
||||
|
||||
* Added optional support for IE8 with $legacy-support-for-ie8 which defaults to true.
|
||||
* Updated the opacity and filter-gradient mixins to make IE's hacky DirectX filters optional based on Compass's legacy support settings.
|
||||
* Updated the opacity and filter-gradient mixins to make IE's hacky DirectX filters
|
||||
optional based on Compass's legacy support settings.
|
||||
* Added the ability to piggy back on compass's watcher within your configuration file.
|
||||
See the [configuration reference](/help/tutorials/configuration-reference/) for details.
|
||||
|
||||
|
||||
0.11.alpha.4 (12/08/2010)
|
||||
-------------------------
|
||||
|
@ -302,3 +302,17 @@ that points to the asset on disk — which may or may not exist.
|
||||
To disable the asset cache buster:
|
||||
|
||||
asset_cache_buster :none
|
||||
|
||||
---
|
||||
|
||||
**`watch`** -- React to changes to arbitrary files within your project. Can be invoked
|
||||
more than once. Example:
|
||||
|
||||
watch "images/**/*" do |project_dir, relative_path|
|
||||
if File.exists?(File.join(project_dir, relative_path))
|
||||
puts "File size of #{relative_path} is: #{File.size(File.join(project_dir, relative_path))}"
|
||||
end
|
||||
end
|
||||
|
||||
This code will be called if the file is added, updated, or removed. Be sure to check for existence
|
||||
to avoid crashing the watcher in the case where the file has been removed.
|
@ -69,6 +69,23 @@ module Compass
|
||||
path.create &method(:recompile)
|
||||
end
|
||||
end
|
||||
Compass.configuration.watches.each do |glob, callback|
|
||||
monitor.path Compass.configuration.project_path do |path|
|
||||
path.glob glob
|
||||
path.update do |base, relative|
|
||||
puts ">>> Change detected to: #{relative}"
|
||||
callback.call(base, relative)
|
||||
end
|
||||
path.create do |base, relative|
|
||||
puts ">>> New file detected: #{relative}"
|
||||
callback.call(base, relative)
|
||||
end
|
||||
path.delete do |base, relative|
|
||||
puts ">>> File Removed: #{relative}"
|
||||
callback.call(base, relative)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -99,6 +99,21 @@ module Compass
|
||||
end
|
||||
end
|
||||
|
||||
def watch(glob, &block)
|
||||
@watches ||= []
|
||||
@watches << [glob, block]
|
||||
end
|
||||
|
||||
def watches
|
||||
if defined?(@watches)
|
||||
@watches
|
||||
elsif inherited_data.respond_to?(:watches)
|
||||
inherited_data.watches
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
# Require a compass plugin and capture that it occured so that the configuration serialization works next time.
|
||||
def require(lib)
|
||||
(self.required_libraries ||= []) << lib
|
||||
|
Loading…
Reference in New Issue
Block a user