Skip to content

Commit

Permalink
Merge commit 'merbjedi/master'
Browse files Browse the repository at this point in the history
* commit 'merbjedi/master':
  Adding Pathname support to compass configs
  Adding PathName support for add_project_configuration
  Separating out Rails2 actionpack integration logic
  • Loading branch information
chriseppstein committed Feb 22, 2010
2 parents fd11471 + 5fc52ba commit 0c593e2
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 4 deletions.
File renamed without changes.
12 changes: 8 additions & 4 deletions 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
Expand Down
1 change: 1 addition & 0 deletions lib/compass/configuration/helpers.rb
Expand Up @@ -31,6 +31,7 @@ def configuration_for(config, filename = nil)
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)
Expand Down
1 change: 1 addition & 0 deletions lib/compass/configuration/serialization.rb
Expand Up @@ -41,6 +41,7 @@ def parse_string(contents, filename)
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
Expand Down
30 changes: 30 additions & 0 deletions test/configuration_test.rb
Expand Up @@ -93,6 +93,36 @@ def test_additional_import_paths
# 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 = <<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.split("\n"), Compass.configuration.serialize.split("\n")
Expand Down

0 comments on commit 0c593e2

Please sign in to comment.