class Object

Public Instance Methods

cachebust_generated_images(path) click to toggle source
# File lib/compass-rails/patches/4_0.rb, line 11
def cachebust_generated_images(path)
  generated_images_dir = Compass.configuration.generated_images_dir
  generated_images_dir = Rails.root.join(generated_images_dir)

  sprockets_env     = options[:sprockets][:environment]
  sprockets_trail   = sprockets_env.send(:trail)
  sprockets_entries = sprockets_trail.instance_variable_get(:@entries) || {}
  sprockets_stats   = sprockets_trail.instance_variable_get(:@stats) || {}

  if sprockets_entries.key?(generated_images_dir.to_s)
    path = path.value
    dir  = File.dirname(path)

    # Delete the entries (directories) which cache the files/dirs in a directory
    entry = generated_images_dir.join(dir).to_s
    sprockets_entries.delete(entry)

    # Delete the stats (file/dir info) which cache the what kind of file/dir each image is
    stat = generated_images_dir.join(path).to_s
    sprockets_stats.delete(stat)
  end
end
evaluate(context, locals, &block) click to toggle source
# File lib/compass-rails/patches/sass_importer.rb, line 8
def evaluate(context, locals, &block)
  # Use custom importer that knows about Sprockets Caching
  cache_store = 
    if defined?(Sprockets::SassCacheStore)
      Sprockets::SassCacheStore.new(context.environment)
    else
      Sprockets::SassProcessor::CacheStore.new(sprockets_cache_store, context.environment)
    end

  paths  = context.environment.paths.map { |path| CompassRails::SpriteImporter.new(path) }
  paths += context.environment.paths.map { |path| sass_importer(context, path) }
  paths += ::Rails.application.config.sass.load_paths

  options = CompassRails.sass_config.merge( {
    :filename => eval_file,
    :line => line,
    :syntax => syntax,
    :cache_store => cache_store,
    :importer => sass_importer(context, context.pathname),
    :load_paths => paths,
    :sprockets => {
      :context => context,
      :environment => context.environment
    }
  })

  engine = ::Sass::Engine.new(data, options)

  engine.dependencies.map do |dependency|
    filename = dependency.options[:filename]
    if filename.include?('*') # Handle sprite globs
      image_path = Rails.root.join(Compass.configuration.images_dir).to_s
      Dir[File.join(image_path, filename)].each do |f|
        context.depend_on(f)
      end
    else
      context.depend_on(filename)
    end
  end

  engine.render
rescue ::Sass::SyntaxError => e
  # Annotates exception message with parse line number
  context.__LINE__ = e.sass_backtrace.first[:line]
  raise e
end
generated_image_url(path, cache_buster = Sass::Script::Bool.new(false)) click to toggle source
# File lib/compass-rails/patches/3_1.rb, line 5
def generated_image_url(path, cache_buster = Sass::Script::Bool.new(false))
  asset_url(path, Sass::Script::String.new('image'))
end
image_path_for_size(image_file) click to toggle source
Calls superclass method
# File lib/compass-rails/patches/compass.rb, line 4
def image_path_for_size(image_file)
  begin
    file = ::Rails.application.assets.find_asset(image_file)
    return file
  rescue ::Sprockets::FileOutsidePaths
    return super(image_file)
  end
end
sass_importer(context, path) click to toggle source
# File lib/compass-rails/patches/sass_importer.rb, line 62
def sass_importer(context, path)
  case sass_importer_artiy.abs
  when 1
    self.class.parent::SassImporter.new(path)
  else
    self.class.parent::SassImporter.new(context, path)
  end
end
sass_importer_artiy() click to toggle source
# File lib/compass-rails/patches/sass_importer.rb, line 57
def sass_importer_artiy
  @sass_importer_artiy ||= self.class.parent::SassImporter.instance_method(:initialize).arity
end
sprockets_cache_store() click to toggle source
# File lib/compass-rails/patches/sass_importer.rb, line 71
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