DRY up the different types of installs.

This commit is contained in:
Chris Eppstein 2009-02-07 23:42:20 -08:00
parent a0552a67c4
commit 29666e177c

View File

@ -81,22 +81,29 @@ module Compass
false
end
def install_stylesheet(from, to, options)
copy templatize(from), targetize("#{sass_dir}/#{to}")
def self.installer(type, &locator)
locator ||= lambda{|to| to}
loc_method = "install_location_for_#{type}".to_sym
define_method loc_method, locator
define_method "install_#{type}" do |from, to, options|
copy templatize(from), targetize(send(loc_method, to))
end
end
def install_image(from, to, options)
copy templatize(from), targetize("#{images_dir}/#{to}")
installer :stylesheet do |to|
"#{sass_dir}/#{to}"
end
def install_script(from, to, options)
copy templatize(from), targetize("#{javascripts_dir}/#{to}")
installer :image do |to|
"#{images_dir}/#{to}"
end
def install_file(from, to, options)
copy templatize(from), targetize(to)
installer :script do |to|
"#{javascripts_dir}/#{to}"
end
installer :file
# returns an absolute path given a path relative to the current installation target.
# Paths can use unix style "/" and will be corrected for the current platform.
def targetize(path)