Skip to content

Commit

Permalink
Merge pull request Compass#197 from danielpclark/master
Browse files Browse the repository at this point in the history
Fixes Compass#195 (works with latest Sass and Sprockets)
  • Loading branch information
yesmeck committed Dec 21, 2014
2 parents e74ee67 + 2c17afc commit 73e4885
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.gem
*.rbc
.bundle
.idea
.config
.yardoc
gemfiles/*.gemfile.lock
Expand Down
24 changes: 21 additions & 3 deletions lib/compass-rails/patches/sass_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
klass.class_eval do
def evaluate(context, locals, &block)
# Use custom importer that knows about Sprockets Caching
cache_store = Sprockets::SassCacheStore.new(context.environment)
cache_store = begin Sprockets::SassCacheStore.new(context.environment); rescue; nil; end ||
Sprockets::SassProcessor::CacheStore.new(sprockets_cache_store, context.environment)
paths = context.environment.paths.map { |path| CompassRails::SpriteImporter.new(context, path) }
paths += context.environment.paths.map { |path| self.class.parent::SassImporter.new(context, path) }
paths += context.environment.paths.map { |path| sass_importer(context, path) }
paths += ::Rails.application.config.sass.load_paths


Expand All @@ -18,7 +19,7 @@ def evaluate(context, locals, &block)
:line => line,
:syntax => syntax,
:cache_store => cache_store,
:importer => self.class.parent::SassImporter.new(context, context.pathname),
:importer => sass_importer(context, context.pathname),
:load_paths => paths,
:sprockets => {
:context => context,
Expand All @@ -32,5 +33,22 @@ def evaluate(context, locals, &block)
context.__LINE__ = e.sass_backtrace.first[:line]
raise e
end

private
def sass_importer(context, path)
begin self.class.parent::SassImporter.new(context, path); rescue; nil; end ||
self.class.parent::SassImporter.new(path)
end

def sprockets_cache_store
case Rails.application.config.assets.cache_store
when :null_store
Sprockets::Cache::NullStore.new
when :memory_store, :mem_cache_store
Sprockets::Cache::MemoryStore.new
else
Sprockets::Cache::FileStore.new(Dir::tmpdir)
end
end
end

2 changes: 1 addition & 1 deletion lib/compass-rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module CompassRails
unless defined?(::CompassRails::VERSION)
VERSION = "2.0.1"
VERSION = "2.0.2"
end
end

0 comments on commit 73e4885

Please sign in to comment.