04f14eb514
* edge: (118 commits) Make the tests pass in ruby 1.9 Fix a bug in FSSM for ruby 1.9. Closes GH-48. Version bump to 0.9.4 Update the TODO. If a template provides a haml file, it can have compass-enabled sass filters within it. Allow vendored frameworks to override built-in frameworks to enable [Rails] Allow compass extensions to be stored in the vendor/plugins/compass/extensions directory. Fix some issues regarding how the project type configuration gets applied. Don't leave directories around after testing. Name all configuration sources for debugging purposes. [Command Line] Primary commands get special status in the initial help output. [Command Line] Access the Sass Repl (sass -i) with the compass environment loaded. Separate the project type default configuration from the installer. Add config/compass.rb as a known config location. Default to config/compass.rb as the configuration file for rails projects. Fix a bug when the welcome message was not provided by an extension template. Version bump to 0.9.3 Starting work on the changelog for 0.10 Stuff that needs to be done before the next release. Help for each template that ships with compass. Allow the welcome message to replace the default one instead of just augment it. ... Conflicts: CHANGELOG.markdown VERSION.yml compass.gemspec lib/compass/configuration.rb lib/vendor/fssm.rb lib/vendor/fssm/state.rb
55 lines
1.1 KiB
Ruby
55 lines
1.1 KiB
Ruby
require 'yaml'
|
|
class FSSM::State
|
|
def initialize(path)
|
|
@path = path
|
|
@cache = FSSM::Tree::Cache.new
|
|
end
|
|
|
|
def refresh(base=nil, skip_callbacks=false)
|
|
previous, current = recache(base || @path.to_pathname)
|
|
|
|
unless skip_callbacks
|
|
deleted(previous, current)
|
|
created(previous, current)
|
|
modified(previous, current)
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def created(previous, current)
|
|
(current.keys - previous.keys).each {|created| @path.create(created)}
|
|
end
|
|
|
|
def deleted(previous, current)
|
|
(previous.keys - current.keys).each {|deleted| @path.delete(deleted)}
|
|
end
|
|
|
|
def modified(previous, current)
|
|
(current.keys & previous.keys).each do |file|
|
|
@path.update(file) if (current[file] <=> previous[file]) != 0
|
|
end
|
|
end
|
|
|
|
def recache(base)
|
|
base = Pathname.for(base)
|
|
previous = @cache.files
|
|
snapshot(base)
|
|
current = @cache.files
|
|
[previous, current]
|
|
end
|
|
|
|
def snapshot(base)
|
|
base = Pathname.for(base)
|
|
@cache.unset(base)
|
|
@path.glob.each {|glob| add_glob(base, glob)}
|
|
end
|
|
|
|
def add_glob(base, glob)
|
|
Pathname.glob(base.join(glob).to_s).each do |fn|
|
|
@cache.set(fn)
|
|
end
|
|
end
|
|
|
|
end
|