You are right, in fact there is no detailed documentation on how to use Compass from Ruby. This is unfortunate, but don't let the little details, like the documentation, stop us!
First try
When I was looking to do the same, I just poked a source around Compass and was able to put together this little Ruby script. At first glance it seems like a trick:
require 'compass' require 'sass/plugin' compiler = Compass::Compiler.new(
But, apparently, Compass has a bunch of default configuration settings that do not turn on automatically when the compiler constructor is called directly (of which SASS load_path is one). This can lead to errors when trying to import Compass and mixins functions, such as:
error: File to import was not found or unreadable: compass / css3
Compass <1.0.0 (aka "old way")
Here's how to call the compiler without overriding these defaults:
require 'compass' Compass.add_configuration( { :project_path => '.', :sass_path => 'styles/scss', :css_path => 'styles/css' }, 'custom'
However, with Compass version 1.0.0, Compass.compiler deprecated in favor of Compass.sass_compiler , which leads to ...
Comps> = 1.0.0 (aka "new way")
Thanks to @philipp for finding how to use the new API , we can update this snippet again to work with Compass.sass_compiler :
require 'compass' require 'compass/sass_compiler' Compass.add_configuration( { :project_path => '.', :sass_path => 'styles/scss', :css_path => 'styles/css' }, 'custom'
hopper
source share