Sha256: a749cf3090e187527ac343aee99182ce4f33dc784b4f0e5761788ecbcf839478

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

require "propshaft/load_path"
require "propshaft/resolver/dynamic"
require "propshaft/resolver/static"
require "propshaft/server"
require "propshaft/processor"
require "propshaft/compilers"
require "propshaft/compilers/css_asset_urls"

class Propshaft::Assembly
  attr_reader :config

  def initialize(config)
    @config = config
  end

  def load_path
    Propshaft::LoadPath.new(config.paths)
  end

  def resolver
    if manifest_path.exist?
      Propshaft::Resolver::Static.new manifest_path: manifest_path, prefix: config.prefix
    else
      Propshaft::Resolver::Dynamic.new load_path: load_path, prefix: config.prefix
    end
  end

  def server
    Propshaft::Server.new(self)
  end

  def processor
    Propshaft::Processor.new \
      load_path: load_path, output_path: config.output_path, compilers: compilers
  end

  def compilers
    @compilers ||=
      Propshaft::Compilers.new(self).tap do |compilers|
        Array(config.compilers).each do |(mime_type, klass)|
          compilers.register mime_type, klass
        end
      end
  end

  private
    def manifest_path
      config.output_path.join(Propshaft::Processor::MANIFEST_FILENAME)
    end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
propshaft-0.1.6 lib/propshaft/assembly.rb
propshaft-0.1.5 lib/propshaft/assembly.rb
propshaft-0.1.4 lib/propshaft/assembly.rb
propshaft-0.1.3 lib/propshaft/assembly.rb
propshaft-0.1.2 lib/propshaft/assembly.rb
propshaft-0.1.1 lib/propshaft/assembly.rb
propshaft-0.1.0 lib/propshaft/assembly.rb