Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Make sure generated sprites get into the asset manifest.

  • Loading branch information...
commit 05479341d10e5acb213bab5476a051946e240596 1 parent f78d2ce
Chris Eppstein authored March 11, 2012
4  lib/compass-rails/patches/3_1.rb
... ...
@@ -1,3 +1,5 @@
  1
+require 'compass-rails/patches/static_compiler'
  2
+
1 3
 module Sass::Script::Functions
2 4
   def generated_image_url(path, only_path = nil)
3 5
     asset_url(path, Sass::Script::String.new("image"))
@@ -25,4 +27,4 @@ module Sass::Script::Functions
25 27
 # Wierd that this has to be re-included to pick up sub-modules. Ruby bug?
26 28
 class Sass::Script::Functions::EvaluationContext
27 29
   include Sass::Script::Functions
28  
-end
  30
+end
4  lib/compass-rails/patches/sprite_importer.rb
@@ -16,7 +16,7 @@ def find(uri, options)
16 16
           end
17 17
         end
18 18
       end
19  
-      
  19
+
20 20
       old
21 21
     end
22 22
 
@@ -35,4 +35,4 @@ def resolver
35 35
     end
36 36
 
37 37
   end
38  
-end
  38
+end
12  lib/compass-rails/patches/static_compiler.rb
... ...
@@ -0,0 +1,12 @@
  1
+require 'sprockets/static_compiler'
  2
+
  3
+module Sprockets
  4
+  class StaticCompiler
  5
+    cattr_accessor :generated_sprites
  6
+    self.generated_sprites = {}
  7
+    def write_manifest_with_sprites(manifest)
  8
+      write_manifest_without_sprites(manifest.merge(self.class.generated_sprites))
  9
+    end
  10
+    alias_method_chain :write_manifest, :sprites
  11
+  end
  12
+end
5  lib/compass-rails/railties/3_1.rb
@@ -62,12 +62,9 @@ def compass
62 62
           asset         = Rails.application.assets.find_asset(filename)
63 63
           pathname      = Pathname.new(filename)
64 64
           logical_path  = filename[(Compass.configuration.images_path.length+1)..-1]
65  
-          # Force the asset into the cache so find_asset will find it.
66  
-          cached_assets = Rails.application.assets.instance_variable_get("@assets")
67  
-          cached_assets[logical_path] = cached_assets[filename] = asset
68 65
 
69 66
           target = Pathname.new(File.join(Rails.public_path, Rails.application.config.assets.prefix))
70  
-          asset = Rails.application.assets.find_asset(logical_path)
  67
+          Sprockets::StaticCompiler.generated_sprites[logical_path] = asset.digest_path
71 68
           filename = target.join(asset.digest_path)
72 69
           FileUtils.mkdir_p File.dirname(filename)
73 70
           asset.write_to filename

0 notes on commit 0547934

Please sign in to comment.
Something went wrong with that request. Please try again.