Allow Importer objects to be placed onto the load path using add_import_path.
Closes #392.
This commit is contained in:
parent
a9317f0d7b
commit
b566979180
@ -13,8 +13,13 @@ module Compass
|
|||||||
Compass::Frameworks::ALL.each do |framework|
|
Compass::Frameworks::ALL.each do |framework|
|
||||||
locations << [framework.stylesheets_directory, File.join(css_path || css_dir || ".", framework.name)]
|
locations << [framework.stylesheets_directory, File.join(css_path || css_dir || ".", framework.name)]
|
||||||
end
|
end
|
||||||
|
load_paths = []
|
||||||
resolve_additional_import_paths.each do |additional_path|
|
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))]
|
locations << [additional_path, File.join(css_path || css_dir || ".", File.basename(additional_path))]
|
||||||
|
else
|
||||||
|
load_paths << additional_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
plugin_opts = {:template_location => locations}
|
plugin_opts = {:template_location => locations}
|
||||||
plugin_opts[:style] = output_style if output_style
|
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[:cache_location] = cache_path unless cache_path.nil?
|
||||||
plugin_opts.merge!(sass_options || {})
|
plugin_opts.merge!(sass_options || {})
|
||||||
plugin_opts[:load_paths] ||= []
|
plugin_opts[:load_paths] ||= []
|
||||||
|
plugin_opts[:load_paths] += load_paths
|
||||||
plugin_opts[:load_paths] << Compass::SpriteImporter.new
|
plugin_opts[:load_paths] << Compass::SpriteImporter.new
|
||||||
plugin_opts
|
plugin_opts
|
||||||
end
|
end
|
||||||
|
|
||||||
def resolve_additional_import_paths
|
def resolve_additional_import_paths
|
||||||
(additional_import_paths || []).map do |path|
|
(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)
|
File.join(project_path, path)
|
||||||
else
|
else
|
||||||
path
|
path
|
||||||
|
@ -240,6 +240,21 @@ EXPECTED
|
|||||||
assert_correct expected_serialization.split("\n"), Compass.configuration.serialize.split("\n")
|
assert_correct expected_serialization.split("\n"), Compass.configuration.serialize.split("\n")
|
||||||
end
|
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
|
def test_config_with_pathname
|
||||||
contents = StringIO.new(<<-CONFIG)
|
contents = StringIO.new(<<-CONFIG)
|
||||||
http_path = "/"
|
http_path = "/"
|
||||||
|
Loading…
Reference in New Issue
Block a user