[Configuration] A more logical and consistent approach to http path locations.

This commit is contained in:
Chris Eppstein 2009-07-03 18:45:19 -07:00
parent 956c437fe9
commit 6555ab3952
2 changed files with 18 additions and 4 deletions

View File

@ -7,6 +7,7 @@ module Compass
ATTRIBUTES = [
:project_type,
:project_path,
:http_path,
:css_dir,
:sass_dir,
:images_dir,
@ -15,6 +16,8 @@ module Compass
:environment,
:relative_assets,
:http_images_path,
:http_stylesheets_path,
:http_javascripts_path,
:additional_import_paths,
:sass_options
]
@ -93,12 +96,12 @@ module Compass
"images"
end
def default_http_images_path
"/#{images_dir}"
def default_http_path
"/"
end
def comment_for_http_images_path
"# To enable relative image paths using the images_url() function:\n# http_images_path = :relative\n"
def comment_for_http_path
"# Set this to the root of your project when deployed:\n"
end
def relative_assets?
@ -140,6 +143,11 @@ module Compass
end
end
def mk_http_path(path)
hp = http_path[0..-2] if http_path[-1..-1] == "/"
"#{hp}/#{path}"
end
def add_import_path(*paths)
# The @added_import_paths variable works around an issue where
# the additional_import_paths gets overwritten during parse

View File

@ -13,6 +13,8 @@ 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"
@ -64,6 +66,7 @@ class ConfigurationTest < Test::Unit::TestCase
def test_additional_import_paths
contents = <<-CONFIG
http_path = "/"
project_path = "/home/chris/my_compass_project"
css_dir = "css"
additional_import_paths = ["../foo"]
@ -80,11 +83,14 @@ class ConfigurationTest < Test::Unit::TestCase
expected_serialization = <<EXPECTED
# Require any additional compass plugins here.
project_path = "/home/chris/my_compass_project"
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
additional_import_paths = ["../foo", "/path/to/my/framework"]
EXPECTED
assert_equal "/", Compass.configuration.http_path
assert_equal expected_serialization, Compass.configuration.serialize
end