Module: ActionView::Helpers::AssetTagHelper
- Defined in:
- lib/virtual_asset_path.rb
Instance Method Summary collapse
-
#rails_asset_id(*args) ⇒ Object
no longer needed <-> would conflict.
- #rewrite_asset_path_with_virtual_folder(*args) ⇒ Object
- #virtual_asset_folder(source) ⇒ Object
-
#virtual_asset_folder_id(path) ⇒ Object
overwrite to disable / use mtime ?.
Instance Method Details
#rails_asset_id(*args) ⇒ Object
no longer needed <-> would conflict
63 64 65 |
# File 'lib/virtual_asset_path.rb', line 63 def rails_asset_id(*args) nil end |
#rewrite_asset_path_with_virtual_folder(*args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/virtual_asset_path.rb', line 10 def rewrite_asset_path_with_virtual_folder(*args) asset_path = rewrite_asset_path_without_virtual_folder(*args) id = virtual_asset_folder(asset_path) if id.present? case VirtualAssetPath.style when :folder, nil then "/asset-v#{id}#{asset_path}" when :suffix suffix = "-asset-v#{id}" if asset_path.include?('.') asset_path.sub(/\.[^\.]*$/, "#{suffix}\\0") else "#{asset_path}#{suffix}" end when :query then "#{asset_path}?#{id}" end else asset_path end end |
#virtual_asset_folder(source) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/virtual_asset_path.rb', line 31 def virtual_asset_folder(source) if asset_id = ENV["RAILS_ASSET_ID"] asset_id else if @@cache_asset_timestamps && (asset_id = @@asset_timestamps_cache[source]) asset_id else path = File.join(ASSETS_DIR, source) asset_id = File.exist?(path) ? virtual_asset_folder_id(path) : '' if @@cache_asset_timestamps @@asset_timestamps_cache_guard.synchronize do @@asset_timestamps_cache[source] = asset_id end end asset_id end end end |
#virtual_asset_folder_id(path) ⇒ Object
overwrite to disable / use mtime ?
53 54 55 56 57 58 59 60 |
# File 'lib/virtual_asset_path.rb', line 53 def virtual_asset_folder_id(path) case VirtualAssetPath.method when :MD5,nil then Digest::MD5.file(path).hexdigest[0..6] when :mtime then File.mtime(path).to_i.to_s else raise "unsupported hashing method" end end |