From 21cfce33db81e185ce5517818844a9849b5a836e Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Fri, 3 Jul 2009 21:57:04 -0700 Subject: [PATCH] [Extensions] When installing a file, the :like option can now be set to have it installed into the same location as what it is like. --- lib/compass/installers/base.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/compass/installers/base.rb b/lib/compass/installers/base.rb index 03bb9f5dd1..0a20c2e2c3 100644 --- a/lib/compass/installers/base.rb +++ b/lib/compass/installers/base.rb @@ -31,7 +31,7 @@ def manifest_file # Initializes the project to work with compass def init dirs = manifest.map do |entry| - File.dirname(send("install_location_for_#{entry.type}", entry.to)) + File.dirname(send("install_location_for_#{entry.type}", entry.to, entry.options)) end if manifest.has_stylesheet? @@ -90,9 +90,16 @@ def pattern_name_as_dir def self.installer(type, &locator) locator ||= lambda{|to| to} loc_method = "install_location_for_#{type}".to_sym - define_method loc_method, locator + define_method("simple_#{loc_method}", locator) + define_method(loc_method) do |to, options| + if options[:like] && options[:like] != type + send("install_location_for_#{options[:like]}", to, options) + else + send("simple_#{loc_method}", to) + end + end define_method "install_#{type}" do |from, to, options| - copy templatize(from), targetize(send(loc_method, to)) + copy templatize(from), targetize(send(loc_method, to, options)) end end @@ -100,6 +107,10 @@ def self.installer(type, &locator) "#{sass_dir}/#{pattern_name_as_dir}#{to}" end + installer :css do |to| + "#{css_dir}/#{to}" + end + installer :image do |to| "#{images_dir}/#{to}" end