Module: Sass::Script::Functions

Includes:
Compass::RailsImageFunctionPatch
Included in:
EvaluationContext
Defined in:
lib/compass-rails/patches/4_0.rb,
lib/compass-rails/patches/4_0.rb,
lib/compass-rails/patches/3_1.rb,
lib/compass-rails/patches/3_1.rb

Instance Method Summary collapse

Instance Method Details

#cachebust_generated_images(image_path, subdirectory = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/compass-rails/patches/4_0.rb', line 14

def cachebust_generated_images(image_path, subdirectory = nil)
  generated_images_path = Rails.root.join(Compass.configuration.generated_images_dir).to_s
  if subdirectory.nil? 
      bust_cache_path = generated_images_path
  else
      bust_cache_path = generated_images_path + "/" + subdirectory
  end
  bust_image_stat_path = generated_images_path + "/" + image_path.to_s

  sprockets_entries = options[:sprockets][:environment].send(:trail).instance_variable_get(:@entries)

  # sprockets_entries.delete(generated_images_path) if sprockets_entries.has_key? generated_images_path
  if sprockets_entries.has_key? generated_images_path
      # sprockets_entries.delete(generated_images_path) 

      # Delete the entries (directories) which cache the files/dirs in a directory
      options[:sprockets][:environment].send(:trail).instance_variable_get(:@entries).delete(bust_cache_path) 

      # Delete the stats (file/dir info) which cache the what kind of file/dir each image is
      options[:sprockets][:environment].send(:trail).instance_variable_get(:@stats).delete(bust_image_stat_path) 
  end
end

#generated_image_url(path, only_path = nil) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/compass-rails/patches/4_0.rb', line 6

def generated_image_url(path, only_path = nil)
  pathobject = Pathname.new(path.to_s)
  subdirectory = pathobject.dirname.to_s

  cachebust_generated_images(path, subdirectory)
  asset_url(path)
end