Class: Rad::Assets::Resource

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

Direct Known Subclasses

PackagedResource

Constant Summary collapse

ASSET_REQUIRE_RE =
/rad\.assets\.require[ \t]+['"]([a-zA-Z0-9_\-\.\/]+)['"]/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_path) ⇒ Resource

Returns a new instance of Resource.



7
8
9
10
# File 'lib/rad/assets/resource.rb', line 7

def initialize http_path
  raise "resources path should be absolute (#{http_path})!" unless http_path =~ /^\//
  @http_path = http_path
end

Instance Attribute Details

#http_pathObject (readonly)

Returns the value of attribute http_path.



2
3
4
# File 'lib/rad/assets/resource.rb', line 2

def http_path
  @http_path
end

Instance Method Details

#resolved_http_pathsObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/rad/assets/resource.rb', line 12

def resolved_http_paths
  fs_path = assets.fs_path(http_path) || raise("no asset #{http_path}!")
  paths = []
  fs_path.to_file.read.scan ASSET_REQUIRE_RE do |dependency_http_path|
    res = Rad::Assets::Resource.new(dependency_http_path.first)
    paths.push *res.resolved_http_paths
  end
  paths << "#{assets.static_path_prefix}#{http_path}"
  paths.uniq
end