From 8b8ad95c1544ad987af1f7c107b70923cca70a89 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Thu, 1 Jan 2009 23:18:21 -0800 Subject: [PATCH] Make framework plugins actually work. --- lib/compass/commands/base.rb | 2 +- lib/compass/commands/create_project.rb | 10 +++++++--- lib/compass/exec.rb | 4 ++++ lib/compass/frameworks.rb | 11 +++++++---- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/compass/commands/base.rb b/lib/compass/commands/base.rb index 0e1f8eb8..6d09c8f8 100644 --- a/lib/compass/commands/base.rb +++ b/lib/compass/commands/base.rb @@ -67,7 +67,7 @@ module Compass # returns the path to the templates directory and caches it def templates_directory - @templates_directory ||= File.expand_path(File.join(File.dirname(__FILE__), separate("../../../frameworks/#{options[:framework]}/templates"))) + @templates_directory ||= Compass::Frameworks[options[:framework]].templates_directory end # Write paths like we're on unix and then fix it diff --git a/lib/compass/commands/create_project.rb b/lib/compass/commands/create_project.rb index e768b2f4..5c850b08 100644 --- a/lib/compass/commands/create_project.rb +++ b/lib/compass/commands/create_project.rb @@ -21,9 +21,13 @@ module Compass css_dir = options[:css_dir] || "stylesheets" directory src_dir, options.merge(:force => true) directory css_dir, options.merge(:force => true) - template 'project/screen.sass', "#{src_dir}/screen.sass", options - template 'project/print.sass', "#{src_dir}/print.sass", options - template 'project/ie.sass', "#{src_dir}/ie.sass", options + project_dir = File.join(templates_directory, "project") + templates = Dir.chdir(project_dir) do + Dir.glob("*") + end + templates.each do |t| + template "project/#{t}", "#{src_dir}/#{t}", options + end UpdateProject.new(working_directory, options).perform end diff --git a/lib/compass/exec.rb b/lib/compass/exec.rb index ceefae85..69bdb84a 100644 --- a/lib/compass/exec.rb +++ b/lib/compass/exec.rb @@ -119,6 +119,10 @@ END opts.on('-s STYLE', '--output-style STYLE', [:nested, :expanded, :compact, :compressed], 'Select a CSS output mode (nested, expanded, compact, compressed)') do |style| self.options[:style] = style end + + opts.on('-r LIBRARY', '--require LIBRARY', "Require LIBRARY before running commands. This is used to access compass plugins.") do |library| + require library + end opts.on('--rails', "Install compass into your Ruby on Rails project found in the current directory.") do self.options[:command] = :install_rails diff --git a/lib/compass/frameworks.rb b/lib/compass/frameworks.rb index 27b50224..3b47a675 100644 --- a/lib/compass/frameworks.rb +++ b/lib/compass/frameworks.rb @@ -9,13 +9,16 @@ module Compass path = options[:path] || arguments.shift @name = name @templates_directory = options[:templates_directory] || File.join(path, 'templates') - @stylesheets_directory = options[:stylesheets_directory] || File.join(self.path, 'stylesheets') + @stylesheets_directory = options[:stylesheets_directory] || File.join(path, 'stylesheets') end end - def register(name, path) - ALL << Framework.new(name, path) + def register(name, *arguments) + ALL << Framework.new(name, *arguments) end - module_function :register + def [](name) + ALL.detect{|f| f.name == name} + end + module_function :register, :[] end end