Sha256: da32f693cc04d0ba0392ba921f21c26328e246085203a5a4dd19303385c3301e

Contents?: true

Size: 733 Bytes

Versions: 20

Compression:

Stored size: 733 Bytes

Contents

class Propshaft::Compilers
  attr_reader :registrations, :assembly

  def initialize(assembly)
    @assembly      = assembly
    @registrations = Hash.new
  end

  def register(mime_type, klass)
    registrations[mime_type] ||= []
    registrations[mime_type] << klass
  end

  def any?
    registrations.any?
  end

  def compilable?(asset)
    registrations[asset.content_type.to_s].present?
  end

  def compile(asset)
    if relevant_registrations = registrations[asset.content_type.to_s]
      asset.content.dup.tap do |input|
        relevant_registrations.each do |compiler|
          input.replace compiler.new(assembly).compile(asset.logical_path, input)
        end
      end
    else
      asset.content
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/propshaft-0.6.4/lib/propshaft/compilers.rb
propshaft-0.8.0 lib/propshaft/compilers.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/propshaft-0.6.4/lib/propshaft/compilers.rb
propshaft-0.7.0 lib/propshaft/compilers.rb
propshaft-0.6.4 lib/propshaft/compilers.rb
propshaft-0.6.3 lib/propshaft/compilers.rb
propshaft-0.6.2 lib/propshaft/compilers.rb
propshaft-0.6.1 lib/propshaft/compilers.rb
propshaft-0.6.0 lib/propshaft/compilers.rb
propshaft-0.5.0 lib/propshaft/compilers.rb
propshaft-0.4.4 lib/propshaft/compilers.rb
propshaft-0.4.3 lib/propshaft/compilers.rb
propshaft-0.4.2 lib/propshaft/compilers.rb
propshaft-0.4.1 lib/propshaft/compilers.rb
propshaft-0.4.0 lib/propshaft/compilers.rb
propshaft-0.3.1 lib/propshaft/compilers.rb
propshaft-0.3.0 lib/propshaft/compilers.rb
propshaft-0.2.2 lib/propshaft/compilers.rb
propshaft-0.2.1 lib/propshaft/compilers.rb
propshaft-0.2.0 lib/propshaft/compilers.rb