Sha256: 76b418fd81ff49f72819235b095e7fe09e9a49661875f1dcfe255581fab95f16

Contents?: true

Size: 651 Bytes

Versions: 5

Compression:

Stored size: 651 Bytes

Contents

class Premailer
  module Rails
    module CSSLoaders
      module AssetPipelineLoader
        extend self

        def load(url)
          if asset_pipeline_present?
            file = file_name(url)
            asset = ::Rails.application.assets.find_asset(file)
            asset.to_s if asset
          end
        end

        def asset_pipeline_present?
          defined?(::Rails) and ::Rails.application.respond_to?(:assets)
        end

        def file_name(url)
          URI(url).path
            .sub("#{::Rails.configuration.assets.prefix}/", '')
            .sub(/-(\h{32}|\h{64})\.css$/, '.css')
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/premailer-rails-1.8.2/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/premailer-rails-1.8.2/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/premailer-rails-1.8.2/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb
premailer-rails-1.8.2 lib/premailer/rails/css_loaders/asset_pipeline_loader.rb
premailer-rails-1.8.1 lib/premailer/rails/css_loaders/asset_pipeline_loader.rb