Allow Importer objects to be placed onto the load path using add_import_path.

Closes #392.
This commit is contained in:
Chris Eppstein 2012-03-18 13:09:24 -07:00
parent a9317f0d7b
commit b566979180
2 changed files with 23 additions and 2 deletions

View File

@ -13,8 +13,13 @@ module Compass
Compass::Frameworks::ALL.each do |framework|
locations << [framework.stylesheets_directory, File.join(css_path || css_dir || ".", framework.name)]
end
load_paths = []
resolve_additional_import_paths.each do |additional_path|
if additional_path.is_a?(String)
locations << [additional_path, File.join(css_path || css_dir || ".", File.basename(additional_path))]
else
load_paths << additional_path
end
end
plugin_opts = {:template_location => locations}
plugin_opts[:style] = output_style if output_style
@ -23,13 +28,14 @@ module Compass
plugin_opts[:cache_location] = cache_path unless cache_path.nil?
plugin_opts.merge!(sass_options || {})
plugin_opts[:load_paths] ||= []
plugin_opts[:load_paths] += load_paths
plugin_opts[:load_paths] << Compass::SpriteImporter.new
plugin_opts
end
def resolve_additional_import_paths
(additional_import_paths || []).map do |path|
if project_path && !absolute_path?(path)
if path.is_a?(String) && project_path && !absolute_path?(path)
File.join(project_path, path)
else
path

View File

@ -240,6 +240,21 @@ EXPECTED
assert_correct expected_serialization.split("\n"), Compass.configuration.serialize.split("\n")
end
def test_additional_import_paths_can_be_importers
contents = StringIO.new(<<-CONFIG)
http_path = "/"
project_path = "/home/chris/my_compass_project"
css_dir = "css"
additional_import_paths = ["../foo"]
add_import_path Sass::Importers::Filesystem.new("/tmp/foo")
CONFIG
Compass.add_configuration(contents, "test_additional_import_paths")
assert Compass.configuration.sass_load_paths.find{|p| p.is_a?(Sass::Importers::Filesystem) && p.root == "/tmp/foo"}
assert Compass.configuration.to_sass_plugin_options[:load_paths].find{|p| p.is_a?(Sass::Importers::Filesystem) && p.root == "/tmp/foo"}
end
def test_config_with_pathname
contents = StringIO.new(<<-CONFIG)
http_path = "/"