diff --git a/lib/compass/configuration.rb b/lib/compass/configuration.rb index fdf686eb..aae4b0c3 100644 --- a/lib/compass/configuration.rb +++ b/lib/compass/configuration.rb @@ -1,26 +1,29 @@ module Compass module Configuration + def self.attributes_for_directory(dir_name, http_dir_name = dir_name) + [ + "#{dir_name}_dir", + "#{dir_name}_path", + ("http_#{http_dir_name}_dir" if http_dir_name), + ("http_#{http_dir_name}_path" if http_dir_name) + ].compact.map{|a| a.to_sym} + end + ATTRIBUTES = [ + # What kind of project? :project_type, + # Where is the project? :project_path, - :css_dir, - :sass_dir, - :images_dir, - :javascripts_dir, - :extensions_dir, - :css_path, - :sass_path, - :images_path, - :javascripts_path, - :extensions_path, :http_path, - :http_images_dir, - :http_stylesheets_dir, - :http_javascripts_dir, - :http_images_path, - :http_stylesheets_path, - :http_javascripts_path, + # Where are the various bits of the project + attributes_for_directory(:css, :stylesheets), + attributes_for_directory(:sass, nil), + attributes_for_directory(:images), + attributes_for_directory(:javascripts), + attributes_for_directory(:fonts), + attributes_for_directory(:extensions, nil), + # Compilation options :output_style, :environment, :relative_assets, @@ -28,7 +31,7 @@ module Compass :sass_options, :asset_host, :asset_cache_buster - ] + ].flatten end end diff --git a/lib/compass/configuration/defaults.rb b/lib/compass/configuration/defaults.rb index 8dcad8b5..c84a6d3d 100644 --- a/lib/compass/configuration/defaults.rb +++ b/lib/compass/configuration/defaults.rb @@ -14,6 +14,10 @@ module Compass "extensions" end + def default_fonts_dir + File.join(top_level.css_dir, "fonts") + end + def default_output_style if top_level.environment == :development :expanded @@ -56,6 +60,12 @@ module Compass end end + def default_fonts_path + if (pp = top_level.project_path) && (dir = top_level.fonts_dir) + File.join(pp, dir) + end + end + def default_http_images_dir top_level.images_dir @@ -73,6 +83,18 @@ module Compass http_root_relative top_level.http_stylesheets_dir end + def default_http_fonts_dir + if fd = top_level.fonts_dir_without_default + fd + else + "#{top_level.http_stylesheets_dir}/fonts" + end + end + + def default_http_fonts_path + http_root_relative top_level.http_fonts_dir + end + def default_http_javascripts_dir top_level.javascripts_dir end diff --git a/test/configuration_test.rb b/test/configuration_test.rb index 08c872fa..c53a625b 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -15,12 +15,12 @@ class ConfigurationTest < Test::Unit::TestCase # Require any additional compass plugins here. project_type = :stand_alone + # Set this to the root of your project when deployed: + http_path = "/" css_dir = "css" sass_dir = "sass" images_dir = "img" javascripts_dir = "js" - # Set this to the root of your project when deployed: - http_path = "/" output_style = :nested # To enable relative paths to assets via compass helper functions. Uncomment: # relative_assets = true @@ -87,9 +87,9 @@ class ConfigurationTest < Test::Unit::TestCase expected_serialization = <