Class: Rad::Assets

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#static_path_prefixObject

Config



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

def static_path_prefix
  @static_path_prefix
end

Instance Method Details

#asset?(http_path) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/rad/assets/assets.rb', line 35

def asset? http_path
  !!((http_path =~ /^\//) and fs_path(http_path))
end

#copy_to_public!Object



21
22
23
24
25
26
27
28
# File 'lib/rad/assets/assets.rb', line 21

def copy_to_public!
  paths.each do |path|
    path = path.to_dir
    raise "asset path should exist (#{path})!" unless path.exist?
    raise "asset path should be a directory (#{path})!" unless path.dir?
    path.copy_to "#{rad.http.public_path}#{static_path_prefix}".to_dir
  end
end

#fs_path(http_path) ⇒ Object



30
31
32
33
# File 'lib/rad/assets/assets.rb', line 30

def fs_path http_path
  http_path.must =~ /^\//
  environment.find_file http_path, paths
end

#pathsObject



17
18
19
# File 'lib/rad/assets/assets.rb', line 17

def paths
  @paths ||= []
end

#resolve_http_paths(http_path) ⇒ Object



11
12
13
14
# File 'lib/rad/assets/assets.rb', line 11

def resolve_http_paths http_path
  resource = pack? ? Rad::Assets::PackagedResource.new(http_path) : Rad::Assets::Resource.new(http_path)
  resource.resolved_http_paths
end