Class: Dassets::SourceProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/dassets/source_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#cacheObject (readonly)

Returns the value of attribute cache.



8
9
10
# File 'lib/dassets/source_proxy.rb', line 8

def cache
  @cache
end

#digest_pathObject (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_filesObject (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

#contentObject



20
21
22
# File 'lib/dassets/source_proxy.rb', line 20

def content
  @cache["#{self.key} -- content"] ||= source_content
end

#exists?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/dassets/source_proxy.rb', line 32

def exists?
  @source_files.inject(true){ |res, f| res && f.exists? }
end

#fingerprintObject



24
25
26
# File 'lib/dassets/source_proxy.rb', line 24

def fingerprint
  @cache["#{self.key} -- fingerprint"] ||= source_fingerprint
end

#keyObject



16
17
18
# File 'lib/dassets/source_proxy.rb', line 16

def key
  "#{self.digest_path} -- #{self.mtime}"
end

#mtimeObject



28
29
30
# File 'lib/dassets/source_proxy.rb', line 28

def mtime
  @source_files.map{ |f| f.mtime }.compact.max
end