Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow assets to be cache keys

  • Loading branch information...
commit ed4b14afc2d2f84c0f5cd7bd36e750a4b8977a4d 1 parent 9757037
@josh josh authored
Showing with 16 additions and 4 deletions.
  1. +4 −0 lib/sprockets/asset.rb
  2. +12 −4 lib/sprockets/processed_asset.rb
View
4 lib/sprockets/asset.rb
@@ -183,6 +183,10 @@ def inspect
">"
end
+ def hash
+ digest.hash
+ end
+
# Assets are equal if they share the same path, mtime and digest.
def eql?(other)
other.class == self.class &&
View
16 lib/sprockets/processed_asset.rb
@@ -15,17 +15,25 @@ def initialize(environment, logical_path, pathname)
# TODO: Move these into there own method
- @required_assets = []
-
+ @required_assets = []
+ required_assets_cache = {}
(context._required_paths + [pathname.to_s]).each do |path|
if path == self.pathname.to_s
- @required_assets << self unless @required_assets.include?(self)
+ unless required_assets_cache[self]
+ required_assets_cache[self] = true
+ @required_assets << self
+ end
elsif asset = environment.find_asset(path, :bundle => false)
asset.required_assets.each do |asset_dependency|
- @required_assets << asset_dependency unless @required_assets.include?(asset_dependency)
+ unless required_assets_cache[asset_dependency]
+ required_assets_cache[asset_dependency] = true
+ @required_assets << asset_dependency
+ end
end
end
end
+ required_assets_cache.clear
+ required_assets_cache = nil
context._dependency_paths.each do |path|
@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.