Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Allow assets to be cache keys

  • Loading branch information...
commit ed4b14afc2d2f84c0f5cd7bd36e750a4b8977a4d 1 parent 9757037
Joshua Peek josh authored

Showing 2 changed files with 16 additions and 4 deletions. Show diff stats Hide diff stats

  1. +4 0 lib/sprockets/asset.rb
  2. +12 4 lib/sprockets/processed_asset.rb
4 lib/sprockets/asset.rb
@@ -183,6 +183,10 @@ def inspect
183 183 ">"
184 184 end
185 185
  186 + def hash
  187 + digest.hash
  188 + end
  189 +
186 190 # Assets are equal if they share the same path, mtime and digest.
187 191 def eql?(other)
188 192 other.class == self.class &&
16 lib/sprockets/processed_asset.rb
@@ -15,17 +15,25 @@ def initialize(environment, logical_path, pathname)
15 15
16 16 # TODO: Move these into there own method
17 17
18   - @required_assets = []
19   -
  18 + @required_assets = []
  19 + required_assets_cache = {}
20 20 (context._required_paths + [pathname.to_s]).each do |path|
21 21 if path == self.pathname.to_s
22   - @required_assets << self unless @required_assets.include?(self)
  22 + unless required_assets_cache[self]
  23 + required_assets_cache[self] = true
  24 + @required_assets << self
  25 + end
23 26 elsif asset = environment.find_asset(path, :bundle => false)
24 27 asset.required_assets.each do |asset_dependency|
25   - @required_assets << asset_dependency unless @required_assets.include?(asset_dependency)
  28 + unless required_assets_cache[asset_dependency]
  29 + required_assets_cache[asset_dependency] = true
  30 + @required_assets << asset_dependency
  31 + end
26 32 end
27 33 end
28 34 end
  35 + required_assets_cache.clear
  36 + required_assets_cache = nil
29 37
30 38 context._dependency_paths.each do |path|
31 39 @dependency_paths << DependencyFile.new(path, environment.stat(path).mtime, environment.file_digest(path).hexdigest)

0 comments on commit ed4b14a

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