Class: Rad::Assets::Resource
- Inherits:
-
Object
- Object
- Rad::Assets::Resource
- Defined in:
- lib/rad/assets/resource.rb
Direct Known Subclasses
Constant Summary collapse
- ASSET_REQUIRE_RE =
/rad\.assets\.require[ \t]+['"]([a-zA-Z0-9_\-\.\/]+)['"]/
Instance Attribute Summary collapse
-
#http_path ⇒ Object
readonly
Returns the value of attribute http_path.
Instance Method Summary collapse
-
#initialize(http_path) ⇒ Resource
constructor
A new instance of Resource.
- #resolved_http_paths ⇒ Object
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_path ⇒ Object (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_paths ⇒ Object
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 |