Class: Dassets::SourceProxy
- Inherits:
-
Object
- Object
- Dassets::SourceProxy
- Defined in:
- lib/dassets/source_proxy.rb
Instance Attribute Summary collapse
-
#content_cache ⇒ Object
readonly
Returns the value of attribute content_cache.
-
#digest_path ⇒ Object
readonly
Returns the value of attribute digest_path.
-
#fingerprint_cache ⇒ Object
readonly
Returns the value of attribute fingerprint_cache.
-
#source_files ⇒ Object
readonly
Returns the value of attribute source_files.
Instance Method Summary collapse
- #content ⇒ Object
- #exists? ⇒ Boolean
- #fingerprint ⇒ Object
-
#initialize(digest_path, options = nil) ⇒ SourceProxy
constructor
A new instance of SourceProxy.
- #key ⇒ Object
- #mtime ⇒ Object
- #response_headers ⇒ Object
Constructor Details
#initialize(digest_path, options = nil) ⇒ SourceProxy
Returns a new instance of SourceProxy.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dassets/source_proxy.rb', line 11 def initialize(digest_path, = nil) ||= {} @digest_path = digest_path @content_cache = [:content_cache] || Dassets::Cache::NoCache.new @fingerprint_cache = [:fingerprint_cache] || Dassets::Cache::NoCache.new @source_files = get_source_files(@digest_path, { :content_cache => @content_cache, :fingerprint_cache => @fingerprint_cache }) end |
Instance Attribute Details
#content_cache ⇒ Object (readonly)
Returns the value of attribute content_cache.
8 9 10 |
# File 'lib/dassets/source_proxy.rb', line 8 def content_cache @content_cache end |
#digest_path ⇒ Object (readonly)
Returns the value of attribute digest_path.
8 9 10 |
# File 'lib/dassets/source_proxy.rb', line 8 def digest_path @digest_path end |
#fingerprint_cache ⇒ Object (readonly)
Returns the value of attribute fingerprint_cache.
8 9 10 |
# File 'lib/dassets/source_proxy.rb', line 8 def fingerprint_cache @fingerprint_cache end |
#source_files ⇒ Object (readonly)
Returns the value of attribute source_files.
9 10 11 |
# File 'lib/dassets/source_proxy.rb', line 9 def source_files @source_files end |
Instance Method Details
#content ⇒ Object
26 27 28 |
# File 'lib/dassets/source_proxy.rb', line 26 def content @content_cache[self.key] ||= source_content end |
#exists? ⇒ Boolean
42 43 44 |
# File 'lib/dassets/source_proxy.rb', line 42 def exists? @source_files.inject(true){ |res, f| res && f.exists? } end |
#fingerprint ⇒ Object
30 31 32 |
# File 'lib/dassets/source_proxy.rb', line 30 def fingerprint @fingerprint_cache[self.key] ||= source_fingerprint end |
#key ⇒ Object
22 23 24 |
# File 'lib/dassets/source_proxy.rb', line 22 def key "#{self.digest_path} -- #{self.mtime}" end |
#mtime ⇒ Object
34 35 36 |
# File 'lib/dassets/source_proxy.rb', line 34 def mtime @source_files.map{ |f| f.mtime }.compact.max end |
#response_headers ⇒ Object
38 39 40 |
# File 'lib/dassets/source_proxy.rb', line 38 def response_headers @source_files.inject(Hash.new){ |hash, f| hash.merge!(f.response_headers) } end |