From 5fc52baa0257f9b0ae12e3d186ecd2c4842e816d Mon Sep 17 00:00:00 2001 From: Jacques Crocker Date: Sat, 20 Feb 2010 13:06:29 -0800 Subject: [PATCH] Adding Pathname support to compass configs --- lib/compass/configuration/serialization.rb | 1 + test/configuration_test.rb | 30 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/compass/configuration/serialization.rb b/lib/compass/configuration/serialization.rb index ed93686b..902e7556 100644 --- a/lib/compass/configuration/serialization.rb +++ b/lib/compass/configuration/serialization.rb @@ -41,6 +41,7 @@ module Compass eval(contents, bind, filename) ATTRIBUTES.each do |prop| value = eval(prop.to_s, bind) rescue nil + value = value.to_s if value.is_a?(Pathname) self.send("#{prop}=", value) unless value.nil? end if @added_import_paths diff --git a/test/configuration_test.rb b/test/configuration_test.rb index d13c528e..1fca5d1a 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -93,6 +93,36 @@ 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.split("\n"), Compass.configuration.serialize.split("\n") + end + + def test_config_with_pathname + contents = StringIO.new(<<-CONFIG) + http_path = "/" + project_path = Pathname.new("/home/chris/my_compass_project") + css_dir = "css" + additional_import_paths = ["../foo"] + add_import_path "/path/to/my/framework" + CONFIG + + Compass.add_configuration(contents, "test_additional_import_paths") + + assert Compass.configuration.to_sass_engine_options[:load_paths].include?("/home/chris/my_compass_project/../foo") + assert Compass.configuration.to_sass_engine_options[:load_paths].include?("/path/to/my/framework"), Compass.configuration.to_sass_engine_options[:load_paths].inspect + assert_equal "/home/chris/my_compass_project/css/framework", Compass.configuration.to_sass_plugin_options[:template_location]["/path/to/my/framework"] + assert_equal "/home/chris/my_compass_project/css/foo", Compass.configuration.to_sass_plugin_options[:template_location]["/home/chris/my_compass_project/../foo"] + + expected_serialization = <