Skip to content

Instantly share code, notes, and snippets.

@gpakosz
Created April 19, 2013 12:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gpakosz/5420177 to your computer and use it in GitHub Desktop.
Save gpakosz/5420177 to your computer and use it in GitHub Desktop.
Better yet hacky Compass / nanoc integration.
def compass_sass_engine_options
fail "configuring Compass with 'relative_assets = true' doesn't make much sense in the context of nanoc" if Compass.configuration.relative_assets?
options = Compass.sass_engine_options
options[:load_paths].each do |x|
class << x
alias _inspect inspect
def inspect
_inspect.gsub(/:0x\h+/, '')
end
end
end
options
end
@gpakosz
Copy link
Author

gpakosz commented Apr 19, 2013

Nanoc's rules memory is based on inspect however Compass.sass_engine_options instantiates different importers at each invocation, see https://github.com/chriseppstein/compass/blob/stable/lib/compass/configuration/adapters.rb#L70-L72

This makes Nanoc believe Rules file has changed since Compass/Sass filtered items have last been compiled.

Raping #inspect method on those instances of Sass::Importers::Filesystem and Compass::SpriteImporter prevents the objects' address from appearing in the string returned by #inspect and then Nanoc stops believing the Rules file has changed in between compiles. Duh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment