From 719cd980ae438093d33876a06c956ce388ee78d1 Mon Sep 17 00:00:00 2001 From: Jacques Crocker Date: Sat, 20 Feb 2010 12:43:10 -0800 Subject: [PATCH 1/3] Separating out Rails2 actionpack integration logic Rails3 has different internal implementations on ActionPack which is causing breakage when trying to calculate image_paths. Lets only calculate this logic for Rails 2 at the moment, and figure out what to do with Rails3 later --- .../rails/{ => actionpack2}/action_controller.rb | 0 .../rails/{ => actionpack2}/sass_plugin.rb | 0 .../app_integration/rails/{ => actionpack2}/urls.rb | 0 lib/compass/app_integration/rails/runtime.rb | 12 ++++++++---- 4 files changed, 8 insertions(+), 4 deletions(-) rename lib/compass/app_integration/rails/{ => actionpack2}/action_controller.rb (100%) rename lib/compass/app_integration/rails/{ => actionpack2}/sass_plugin.rb (100%) rename lib/compass/app_integration/rails/{ => actionpack2}/urls.rb (100%) diff --git a/lib/compass/app_integration/rails/action_controller.rb b/lib/compass/app_integration/rails/actionpack2/action_controller.rb similarity index 100% rename from lib/compass/app_integration/rails/action_controller.rb rename to lib/compass/app_integration/rails/actionpack2/action_controller.rb diff --git a/lib/compass/app_integration/rails/sass_plugin.rb b/lib/compass/app_integration/rails/actionpack2/sass_plugin.rb similarity index 100% rename from lib/compass/app_integration/rails/sass_plugin.rb rename to lib/compass/app_integration/rails/actionpack2/sass_plugin.rb diff --git a/lib/compass/app_integration/rails/urls.rb b/lib/compass/app_integration/rails/actionpack2/urls.rb similarity index 100% rename from lib/compass/app_integration/rails/urls.rb rename to lib/compass/app_integration/rails/actionpack2/urls.rb diff --git a/lib/compass/app_integration/rails/runtime.rb b/lib/compass/app_integration/rails/runtime.rb index 82a353d1..d1a5ed5b 100644 --- a/lib/compass/app_integration/rails/runtime.rb +++ b/lib/compass/app_integration/rails/runtime.rb @@ -1,10 +1,14 @@ unless defined?(Compass::RAILS_LOADED) Compass::RAILS_LOADED = true - - %w(action_controller sass_plugin urls).each do |lib| - require "compass/app_integration/rails/#{lib}" + + if ActionPack::VERSION::MAJOR >= 3 + # figure something out so image_path works with rails integration + else + %w(action_controller sass_plugin urls).each do |lib| + require "compass/app_integration/rails/actionpack2/#{lib}" + end end - + # Wierd that this has to be re-included to pick up sub-modules. Ruby bug? class Sass::Script::Functions::EvaluationContext include Sass::Script::Functions From 2b985fd191b02aface72e52111d0ad818e73ad78 Mon Sep 17 00:00:00 2001 From: Jacques Crocker Date: Sat, 20 Feb 2010 12:48:58 -0800 Subject: [PATCH 2/3] Adding PathName support for add_project_configuration --- lib/compass/configuration/helpers.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/compass/configuration/helpers.rb b/lib/compass/configuration/helpers.rb index 643523fa..f2aa9f34 100644 --- a/lib/compass/configuration/helpers.rb +++ b/lib/compass/configuration/helpers.rb @@ -31,6 +31,7 @@ module Compass if config.is_a?(Compass::Configuration::Data) config elsif config.respond_to?(:read) + filename ||= config.to_s if config.is_a?(Pathname) Compass::Configuration::Data.new_from_string(config.read, filename) elsif config.is_a?(Hash) Compass::Configuration::Data.new(filename, config) From 5fc52baa0257f9b0ae12e3d186ecd2c4842e816d Mon Sep 17 00:00:00 2001 From: Jacques Crocker Date: Sat, 20 Feb 2010 13:06:29 -0800 Subject: [PATCH 3/3] 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 = <