Module: Premailer::Rails::CSSLoaders::AssetPipelineLoader
- Extended by:
- AssetPipelineLoader
- Included in:
- AssetPipelineLoader
- Defined in:
- lib/premailer/rails/css_loaders/asset_pipeline_loader.rb
Instance Method Summary collapse
Instance Method Details
#asset_pipeline_present? ⇒ Boolean
26 27 28 29 30 31 32 |
# File 'lib/premailer/rails/css_loaders/asset_pipeline_loader.rb', line 26 def asset_pipeline_present? defined?(::Rails) && ::Rails.respond_to?(:application) && ::Rails.application && ::Rails.application.respond_to?(:assets_manifest) && ::Rails.application.assets_manifest end |
#file_name(url) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/premailer/rails/css_loaders/asset_pipeline_loader.rb', line 15 def file_name(url) prefix = File.join( ::Rails.configuration.relative_url_root.to_s, ::Rails.configuration.assets.prefix.to_s, '/' ) URI(url).path .sub(/\A#{prefix}/, '') .sub(/-(\h{32}|\h{64})\.css\z/, '.css') end |
#load(url) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/premailer/rails/css_loaders/asset_pipeline_loader.rb', line 7 def load(url) return unless asset_pipeline_present? file = file_name(url) ::Rails.application.assets_manifest.find_sources(file).first rescue Errno::ENOENT, TypeError => _error end |