Class: Dassets::SourceProxy
- Inherits:
-
Object
- Object
- Dassets::SourceProxy
- Defined in:
- lib/dassets/source_proxy.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#digest_path ⇒ Object
readonly
Returns the value of attribute digest_path.
-
#source_files ⇒ Object
readonly
Returns the value of attribute source_files.
Instance Method Summary collapse
- #content ⇒ Object
- #exists? ⇒ Boolean
- #fingerprint ⇒ Object
-
#initialize(digest_path, cache = nil) ⇒ SourceProxy
constructor
A new instance of SourceProxy.
- #key ⇒ Object
- #mtime ⇒ Object
Constructor Details
#initialize(digest_path, cache = nil) ⇒ SourceProxy
Returns a new instance of SourceProxy.
10 11 12 13 14 |
# File 'lib/dassets/source_proxy.rb', line 10 def initialize(digest_path, cache = nil) @digest_path = digest_path @cache = cache || Dassets::Cache::NoCache.new @source_files = get_source_files(@digest_path, @cache) end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
8 9 10 |
# File 'lib/dassets/source_proxy.rb', line 8 def cache @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 |
#source_files ⇒ Object (readonly)
Returns the value of attribute source_files.
8 9 10 |
# File 'lib/dassets/source_proxy.rb', line 8 def source_files @source_files end |
Instance Method Details
#content ⇒ Object
20 21 22 |
# File 'lib/dassets/source_proxy.rb', line 20 def content @cache["#{self.key} -- content"] ||= source_content end |
#exists? ⇒ Boolean
32 33 34 |
# File 'lib/dassets/source_proxy.rb', line 32 def exists? @source_files.inject(true){ |res, f| res && f.exists? } end |
#fingerprint ⇒ Object
24 25 26 |
# File 'lib/dassets/source_proxy.rb', line 24 def fingerprint @cache["#{self.key} -- fingerprint"] ||= source_fingerprint end |
#key ⇒ Object
16 17 18 |
# File 'lib/dassets/source_proxy.rb', line 16 def key "#{self.digest_path} -- #{self.mtime}" end |
#mtime ⇒ Object
28 29 30 |
# File 'lib/dassets/source_proxy.rb', line 28 def mtime @source_files.map{ |f| f.mtime }.compact.max end |