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 false
end end
def install_stylesheet(from, to, options) def self.installer(type, &locator)
copy templatize(from), targetize("#{sass_dir}/#{to}") 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 end
def install_image(from, to, options) installer :stylesheet do |to|
copy templatize(from), targetize("#{images_dir}/#{to}") "#{sass_dir}/#{to}"
end end
def install_script(from, to, options) installer :image do |to|
copy templatize(from), targetize("#{javascripts_dir}/#{to}") "#{images_dir}/#{to}"
end end
def install_file(from, to, options) installer :script do |to|
copy templatize(from), targetize(to) "#{javascripts_dir}/#{to}"
end end
installer :file
# returns an absolute path given a path relative to the current installation target. # 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. # Paths can use unix style "/" and will be corrected for the current platform.
def targetize(path) def targetize(path)