diff --git a/frameworks/blueprint.rb b/frameworks/blueprint.rb deleted file mode 100644 index 47b3c87b..00000000 --- a/frameworks/blueprint.rb +++ /dev/null @@ -1,2 +0,0 @@ -blueprint_dir = File.join(Compass.base_directory, 'frameworks', 'blueprint') -Compass::Frameworks.register('blueprint', blueprint_dir) diff --git a/frameworks/compass.rb b/frameworks/compass.rb deleted file mode 100644 index 3ad82710..00000000 --- a/frameworks/compass.rb +++ /dev/null @@ -1,2 +0,0 @@ -compass_dir = File.join(Compass.base_directory, 'frameworks', 'compass') -Compass::Frameworks.register('compass', compass_dir) diff --git a/frameworks/compass/templates/extension/manifest.rb b/frameworks/compass/templates/extension/manifest.rb new file mode 100644 index 00000000..e69de29b diff --git a/lib/compass/frameworks.rb b/lib/compass/frameworks.rb index e74c4529..b34597bc 100644 --- a/lib/compass/frameworks.rb +++ b/lib/compass/frameworks.rb @@ -1,6 +1,10 @@ module Compass module Frameworks + extend self + ALL = [] + DEFAULT_FRAMEWORKS_PATH = File.join(Compass.base_directory, 'frameworks') + class Framework attr_accessor :name attr_accessor :templates_directory, :stylesheets_directory @@ -12,18 +16,38 @@ module Compass @stylesheets_directory = options[:stylesheets_directory] || File.join(path, 'stylesheets') end end + def register(name, *arguments) ALL << Framework.new(name, *arguments) end + def [](name) ALL.detect{|f| f.name.to_s == name.to_s} end - module_function :register, :[] + + def discover(frameworks_directory) + frameworks_directory = DEFAULT_FRAMEWORKS_PATH if frameworks_directory == :defaults + frameworks_directory = Dir.new(frameworks_directory) unless frameworks_directory.is_a?(Dir) + frameworks_directory.entries.reject{|e| e[0] == ?.}.each do |framework| + register_directory File.join(frameworks_directory.path, framework) + end + end + + def register_directory(directory) + loaders = [ + File.join(directory, "compass_init.rb"), + File.join(directory, 'lib', File.basename(directory)+".rb"), + File.join(directory, File.basename(directory)+".rb") + ] + loader = loaders.detect{|l| File.exists?(l)} + if loader + require loader + else + register File.basename(directory), directory + end + end + end end -# Import all of the default frameworks. -default_frameworks_directory = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'frameworks')) -Dir.glob(File.join(default_frameworks_directory, "*.rb")).each do |framework| - require framework -end +Compass::Frameworks.discover(:defaults)