Sha256: 2467d53455be137bea1d6f1bc02fb768342a05e7e236b15f1bdbb101f69034cc

Contents?: true

Size: 670 Bytes

Versions: 3

Compression:

Stored size: 670 Bytes

Contents

module Propshaft::Resolver
  class Static
    attr_reader :manifest_path, :prefix

    def initialize(manifest_path:, prefix:)
      @manifest_path, @prefix = manifest_path, prefix
    end

    def resolve(logical_path)
      if asset_path = parsed_manifest[logical_path]
        File.join prefix, asset_path
      end
    end

    def read(logical_path, encoding: "ASCII-8BIT")
      if asset_path = parsed_manifest[logical_path]
        File.read(manifest_path.dirname.join(asset_path), encoding: encoding)
      end
    end

    private
      def parsed_manifest
        @parsed_manifest ||= JSON.parse(manifest_path.read, symbolize_names: false)
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
propshaft-1.1.0 lib/propshaft/resolver/static.rb
propshaft-1.0.1 lib/propshaft/resolver/static.rb
propshaft-1.0.0 lib/propshaft/resolver/static.rb