Sha256: ee1d88593ecd174e0ea44eee86ec9380b84a59208fa949149051af22cb6cd937

Contents?: true

Size: 596 Bytes

Versions: 6

Compression:

Stored size: 596 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)
      end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/propshaft-0.6.4/lib/propshaft/resolver/static.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/propshaft-0.6.4/lib/propshaft/resolver/static.rb
propshaft-0.6.4 lib/propshaft/resolver/static.rb
propshaft-0.6.3 lib/propshaft/resolver/static.rb
propshaft-0.6.2 lib/propshaft/resolver/static.rb
propshaft-0.6.1 lib/propshaft/resolver/static.rb