Sha256: 4738828dd9cb5aac977ea3a8e8b194dd5aad871fd63067624cf5ee5f4e0ec9a8
Contents?: true
Size: 1.87 KB
Versions: 2
Compression:
Stored size: 1.87 KB
Contents
# frozen_string_literal: true module Pakyow module Assets module Actions # Pipeline Action that processes assets at request time. # # This is intended for development use, please don't use it in production. # Instead, precompile assets into the public directory. # class Process def call(connection) if connection.app.config.assets.process # TODO: can we short circuit if the request path doesn't match the connection? if asset = find_asset(connection) || find_pack(connection) || find_asset_map(connection) || find_pack_map(connection) connection.set_header("content-type", asset.mime_type) connection.body = asset connection.halt end end end private def find_asset(connection, path = connection.path) connection.app.state(:asset).find { |asset| asset.public_path == path } end def find_pack(connection, path = connection.path) connection.app.state(:pack).lazy.map { |pack| pack.packed(path) }.find { |packed| !packed.nil? && packed.any? } end def find_asset_map(connection) if wants_map?(connection) if (asset = find_asset(connection, unmapped(connection))) && asset.source_map? asset.source_map end end end def find_pack_map(connection) if (pack = find_pack(connection, unmapped(connection))) && pack.source_map? pack.source_map else nil end end def wants_map?(connection) connection.path.end_with?(".map") end def unmapped(connection) File.join(File.dirname(connection.path), File.basename(connection.path, ".map")) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pakyow-assets-1.0.0.rc2 | lib/pakyow/assets/actions/process.rb |
pakyow-assets-1.0.0.rc1 | lib/pakyow/assets/actions/process.rb |