Permalink
Browse files

Merge pull request #20 from nclark/master

optionally configure sass and css directories in compass plugin
  • Loading branch information...
2 parents 0ee28b5 + 23b98ca commit a0ed5b88ca17bac9f716afe8c8a1bdbeb27baaf6 @quirkey committed Jul 23, 2011
View
14 lib/soca/plugins/compass.rb
@@ -9,17 +9,27 @@ class Compass < Soca::Plugin
name 'compass'
def run(options = {})
+ @options = options
+
Soca.logger.info "compiling compass"
- compass_from = File.join(app_dir, 'sass')
- compass_to = File.join(app_dir, 'css')
+
unless Soca.debug
options = {:logger => ::Compass::NullLogger.new}.merge(options)
end
+
compass = ::Compass::Compiler.new(app_dir, compass_from, compass_to, ::Compass.sass_engine_options.merge(options || {}))
Soca.logger.debug "compass: #{compass.inspect}"
compass.run
end
+ private
+ def compass_from
+ @options.has_key?(:from) ? File.join(app_dir, @options[:from]) : File.join(app_dir, 'sass')
+ end
+
+ def compass_to
+ @options.has_key?(:to) ? File.join(app_dir, @options[:to]) : File.join(app_dir, 'css')
+ end
end
end
end
View
2 test/helper.rb
@@ -2,10 +2,12 @@
require 'test/unit'
require 'shoulda'
require 'mocha'
+require 'compass'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'soca'
+require 'soca/plugins/compass'
class Test::Unit::TestCase
View
54 test/test_compass_plugin.rb
@@ -0,0 +1,54 @@
+require 'helper'
+
+class TestCompassPlugin < Test::Unit::TestCase
+ def app_path(relative='')
+ File.expand_path(@test_app_dir + '/' + relative)
+ end
+
+ context 'compass plugin' do
+ setup do
+ pusher = Soca::Pusher.new(app_path)
+ @plugin = Soca::Plugins::Compass.new(pusher)
+ end
+
+ context 'given no options' do
+ should 'invoke compass compiler with default options' do
+ Compass::Compiler.expects(:new).
+ with(@test_app_dir, app_path('sass'), app_path('css'), anything).
+ returns(mock(:run => true))
+
+ @plugin.run
+ end
+ end
+
+ context 'given a from option' do
+ should 'invoke compass compiler with provided from option' do
+ Compass::Compiler.expects(:new).
+ with(@test_app_dir, app_path('app/sass'), app_path('css'), anything).
+ returns(mock(:run => true))
+
+ @plugin.run :from => 'app/sass'
+ end
+ end
+
+ context 'given a to option' do
+ should 'invoke compass compiler with provided to option' do
+ Compass::Compiler.expects(:new).
+ with(@test_app_dir, app_path('sass'), app_path('snoop_dogg/css'), anything).
+ returns(mock(:run => true))
+
+ @plugin.run :to => 'snoop_dogg/css'
+ end
+ end
+
+ context 'given a from option and a to option' do
+ should 'invoke compas compiler with provided from and to options' do
+ Compass::Compiler.expects(:new).
+ with(@test_app_dir, app_path('app/sass'), app_path('app/css'), anything).
+ returns(mock(:run => true))
+
+ @plugin.run :from => 'app/sass', :to => 'app/css'
+ end
+ end
+ end
+end
View
0 test/test_plugins.rb → test/test_macro_plugin.rb
File renamed without changes.

0 comments on commit a0ed5b8

Please sign in to comment.