Sha256: e2961ea8da4fb3453daaaeeaae53aa8a3359a2c7ec6d17272621677518abbd03

Contents?: true

Size: 620 Bytes

Versions: 3

Compression:

Stored size: 620 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)
      if asset_path = parsed_manifest[logical_path]
        manifest_path.dirname.join(asset_path).read
      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-0.9.1 lib/propshaft/resolver/static.rb
propshaft-0.8.0 lib/propshaft/resolver/static.rb
propshaft-0.7.0 lib/propshaft/resolver/static.rb