Class: ActionView::AssetPaths
- Defined in:
- actionpack/lib/action_view/asset_paths.rb
Overview
:nodoc:
Direct Known Subclasses
Helpers::AssetTagHelper::AssetPaths, Sprockets::Helpers::RailsHelper::AssetPaths
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
-
#compute_public_path(source, dir, options = {}) ⇒ Object
Add the extension
ext
if not present. -
#compute_source_path(source, dir, ext) ⇒ Object
Return the filesystem path for the source.
-
#initialize(config, controller = nil) ⇒ AssetPaths
constructor
A new instance of AssetPaths.
- #is_uri?(path) ⇒ Boolean
Constructor Details
#initialize(config, controller = nil) ⇒ AssetPaths
Returns a new instance of AssetPaths.
9 10 11 12 |
# File 'actionpack/lib/action_view/asset_paths.rb', line 9 def initialize(config, controller = nil) @config = config @controller = controller end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config
7 8 9 |
# File 'actionpack/lib/action_view/asset_paths.rb', line 7 def config @config end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller
7 8 9 |
# File 'actionpack/lib/action_view/asset_paths.rb', line 7 def controller @controller end |
Instance Method Details
#compute_public_path(source, dir, options = {}) ⇒ Object
Add the extension ext
if not present. Return full or scheme-relative URLs otherwise untouched. Prefix with /dir/
if lacking a leading /
. Account for relative URL roots. Rewrite the asset path for cache-busting asset ids. Include asset host, if configured, with the correct request protocol.
When :relative (default), the protocol will be determined by the client using current protocol When :request, the protocol will be the request protocol Otherwise, the protocol is used (E.g. :http, :https, etc)
22 23 24 25 26 27 28 29 30 31 |
# File 'actionpack/lib/action_view/asset_paths.rb', line 22 def compute_public_path(source, dir, = {}) source = source.to_s return source if is_uri?(source) source = rewrite_extension(source, dir, [:ext]) if [:ext] source = rewrite_asset_path(source, dir, ) source = rewrite_relative_url_root(source, relative_url_root) source = rewrite_host_and_protocol(source, [:protocol]) source end |
#compute_source_path(source, dir, ext) ⇒ Object
Return the filesystem path for the source
34 35 36 37 38 39 40 41 42 43 |
# File 'actionpack/lib/action_view/asset_paths.rb', line 34 def compute_source_path(source, dir, ext) source = rewrite_extension(source, dir, ext) if ext sources = [] sources << config.assets_dir sources << dir unless source[0] == ?/ sources << source File.join(sources) end |
#is_uri?(path) ⇒ Boolean
45 46 47 |
# File 'actionpack/lib/action_view/asset_paths.rb', line 45 def is_uri?(path) path =~ %r{^[-a-z]+://|^(?:cid|data):|^//} end |