Class: Rad::Assets::PackagedResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/rad/assets/packaged_resource.rb

Constant Summary collapse

PACKAGED_POSTFIX =
'packaged'

Instance Method Summary collapse

Instance Method Details

#resolved_http_pathsObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rad/assets/packaged_resource.rb', line 4

def resolved_http_paths
  http_path = "#{assets.static_path_prefix}#{self.http_path}"

  fs_path = self.fs_path http_path
  http_paths = []
  fs_path.to_file.read.scan ASSET_REQUIRE_RE do |dependency_http_path|
    res = Rad::Assets::PackagedResource.new(dependency_http_path.first)
    http_paths.push *res.resolved_http_paths
  end
  http_paths << http_path

  fs_paths = http_paths.collect{|path| self.fs_path path}
  packaged_file = self.fs_path(packaged_http_path(http_path)).to_file

  rebuild = (
    !packaged_file.exist? or
    fs_paths.any?{|path| path.to_file.updated_at > packaged_file.updated_at}
  )
  rebuild! packaged_file, fs_paths if rebuild

  [packaged_http_path(http_path)]
end