Class: Sprockets::Helpers::RailsHelper::AssetPaths
- Inherits:
-
ActionView::AssetPaths
- Object
- ActionView::AssetPaths
- Sprockets::Helpers::RailsHelper::AssetPaths
- Defined in:
- lib/sprockets/helpers/rails_helper.rb
Overview
:nodoc:
Defined Under Namespace
Classes: AssetNotPrecompiledError
Instance Attribute Summary collapse
-
#asset_digests ⇒ Object
Returns the value of attribute asset_digests.
-
#asset_environment ⇒ Object
Returns the value of attribute asset_environment.
-
#asset_prefix ⇒ Object
Returns the value of attribute asset_prefix.
Attributes inherited from ActionView::AssetPaths
Instance Method Summary collapse
- #asset_for(source, ext) ⇒ Object
- #compute_public_path(source, dir, ext = nil, include_host = true, protocol = nil) ⇒ Object
-
#compute_source_path(source, ext) ⇒ Object
Return the filesystem path for the source.
- #digest_for(logical_path) ⇒ Object
- #rewrite_asset_path(source, dir) ⇒ Object
- #rewrite_extension(source, dir, ext) ⇒ Object
Methods inherited from ActionView::AssetPaths
Constructor Details
This class inherits a constructor from ActionView::AssetPaths
Instance Attribute Details
#asset_digests ⇒ Object
Returns the value of attribute asset_digests.
107 108 109 |
# File 'lib/sprockets/helpers/rails_helper.rb', line 107 def asset_digests @asset_digests end |
#asset_environment ⇒ Object
Returns the value of attribute asset_environment.
107 108 109 |
# File 'lib/sprockets/helpers/rails_helper.rb', line 107 def asset_environment @asset_environment end |
#asset_prefix ⇒ Object
Returns the value of attribute asset_prefix.
107 108 109 |
# File 'lib/sprockets/helpers/rails_helper.rb', line 107 def asset_prefix @asset_prefix end |
Instance Method Details
#asset_for(source, ext) ⇒ Object
120 121 122 123 124 125 |
# File 'lib/sprockets/helpers/rails_helper.rb', line 120 def asset_for(source, ext) source = source.to_s return nil if is_uri?(source) source = rewrite_extension(source, nil, ext) asset_environment[source] end |
#compute_public_path(source, dir, ext = nil, include_host = true, protocol = nil) ⇒ Object
111 112 113 |
# File 'lib/sprockets/helpers/rails_helper.rb', line 111 def compute_public_path(source, dir, ext=nil, include_host=true, protocol=nil) super(source, asset_prefix, ext, include_host, protocol) end |
#compute_source_path(source, ext) ⇒ Object
Return the filesystem path for the source
116 117 118 |
# File 'lib/sprockets/helpers/rails_helper.rb', line 116 def compute_source_path(source, ext) asset_for(source, ext) end |
#digest_for(logical_path) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/sprockets/helpers/rails_helper.rb', line 127 def digest_for(logical_path) if asset_digests && (digest = asset_digests[logical_path]) return digest end if Rails.application.config.assets.compile if asset = asset_environment[logical_path] return asset.digest_path end return logical_path else raise AssetNotPrecompiledError.new("#{logical_path} isn't precompiled") end end |
#rewrite_asset_path(source, dir) ⇒ Object
142 143 144 145 146 147 148 149 150 151 |
# File 'lib/sprockets/helpers/rails_helper.rb', line 142 def rewrite_asset_path(source, dir) if source[0] == ?/ source else source = digest_for(source) if Rails.application.config.assets.digest source = File.join(dir, source) source = "/#{source}" unless source =~ /^\// source end end |
#rewrite_extension(source, dir, ext) ⇒ Object
153 154 155 156 157 158 159 |
# File 'lib/sprockets/helpers/rails_helper.rb', line 153 def rewrite_extension(source, dir, ext) if ext && File.extname(source).empty? "#{source}.#{ext}" else source end end |