Sha256: 783b1b5e1bf05cb1cc2d5b5d0c017fa6fa2a2419d6808772d2e92e53ca1768bc

Contents?: true

Size: 1.49 KB

Versions: 8

Compression:

Stored size: 1.49 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"
require "propshaft/compilers/source_mapping_urls"

class Propshaft::Assembly
  attr_reader :config

  def initialize(config)
    @config = config
  end

  def load_path
    @load_path ||= Propshaft::LoadPath.new(config.paths, version: config.version)
  end

  def resolver
    @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

  def reveal(path_type = :logical_path)
    path_type = path_type.presence_in(%i[ logical_path path ]) || raise(ArgumentError, "Unknown path_type: #{path_type}")
    
    load_path.assets.collect do |asset|
      asset.send(path_type)
    end
  end

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

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/propshaft-0.6.4/lib/propshaft/assembly.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/propshaft-0.6.4/lib/propshaft/assembly.rb
propshaft-0.7.0 lib/propshaft/assembly.rb
propshaft-0.6.4 lib/propshaft/assembly.rb
propshaft-0.6.3 lib/propshaft/assembly.rb
propshaft-0.6.2 lib/propshaft/assembly.rb
propshaft-0.6.1 lib/propshaft/assembly.rb
propshaft-0.6.0 lib/propshaft/assembly.rb