diff --git a/lib/compass/configuration/data.rb b/lib/compass/configuration/data.rb index 5c9354c1..8ae6afa2 100644 --- a/lib/compass/configuration/data.rb +++ b/lib/compass/configuration/data.rb @@ -25,7 +25,7 @@ module Compass extend Compass::Configuration::Paths inherited_accessor *ATTRIBUTES - inherited_accessor :required_libraries #XXX we should make this array add up cumulatively. + inherited_accessor :required_libraries, :loaded_frameworks, :framework_path #XXX we should make these arrays add up cumulatively. strip_trailing_separator *ATTRIBUTES.select{|a| a.to_s =~ /dir|path/} @@ -95,6 +95,16 @@ module Compass super end + def load(framework_dir) + (self.loaded_frameworks ||= []) << framework_dir + Compass::Frameworks.register_directory framework_dir + end + + def discover(frameworks_dir) + (self.framework_path ||= []) << frameworks_dir + Compass::Frameworks.discover frameworks_dir + end + def relative_assets? # the http_images_path is deprecated, but here for backwards compatibility. relative_assets || http_images_path == :relative diff --git a/lib/compass/configuration/serialization.rb b/lib/compass/configuration/serialization.rb index 902e7556..1301c379 100644 --- a/lib/compass/configuration/serialization.rb +++ b/lib/compass/configuration/serialization.rb @@ -56,6 +56,12 @@ module Compass (required_libraries || []).each do |lib| contents << %Q{require '#{lib}'\n} end + (loaded_frameworks || []).each do |lib| + contents << %Q{load '#{lib}'\n} + end + (framework_path || []).each do |lib| + contents << %Q{discover '#{lib}'\n} + end contents << "# Require any additional compass plugins here.\n" contents << "\n" if (required_libraries || []).any? ATTRIBUTES.each do |prop| diff --git a/lib/compass/exec/global_options_parser.rb b/lib/compass/exec/global_options_parser.rb index c3ad7f1a..0f52225b 100644 --- a/lib/compass/exec/global_options_parser.rb +++ b/lib/compass/exec/global_options_parser.rb @@ -7,9 +7,24 @@ module Compass::Exec::GlobalOptionsParser opts.on('-r LIBRARY', '--require LIBRARY', "Require the given ruby LIBRARY before running commands.", " This is used to access compass plugins without having a", - " project configuration file.") do |library| - ::Compass.configuration.require library - end + " project configuration file." + ) do |library| + ::Compass.configuration.require library + end + + opts.on('-l FRAMEWORK_DIR', '--load FRAMEWORK_DIR', + "Load the framework or extensions found in the FRAMEWORK directory." + ) do |framework_dir| + require 'pathname' + ::Compass.configuration.load Pathname.new(framework_dir).realpath + end + + opts.on('-L FRAMEWORKS_DIR', '--load-all FRAMEWORKS_DIR', + "Load all the frameworks or extensions found in the FRAMEWORKS_DIR directory." + ) do |frameworks_dir| + require 'pathname' + ::Compass.configuration.discover Pathname.new(frameworks_dir).realpath + end opts.on('-q', '--quiet', :NONE, 'Quiet mode.') do self.options[:quiet] = true