Sha256: a99e6d07c98c2e4817e925337602eba6500a92f97d4bb8573c2ef17378d6f919

Contents?: true

Size: 987 Bytes

Versions: 1

Compression:

Stored size: 987 Bytes

Contents

# frozen_string_literal: true

module Bridgetown
  module Model
    class PluginOrigin < RepoOrigin
      class << self
        def handle_scheme?(scheme)
          scheme == "plugin"
        end
      end

      def manifest
        @manifest ||= begin
          manifest_origin = Addressable::URI.unescape(url.path.delete_prefix("/")).split("/").first
          Bridgetown::PluginManager.source_manifests.find do |manifest|
            manifest.origin.to_s == manifest_origin
          end.tap do |manifest| # rubocop:disable Style/MultilineBlockChain
            raise "Unable to locate a source manifest for #{manifest_origin}" unless manifest
          end
        end
      end

      def relative_path
        @relative_path ||= Pathname.new(
          Addressable::URI.unescape(url.path.delete_prefix("/")).split("/")[1..-1].join("/")
        )
      end

      def original_path
        @original_path ||= relative_path.expand_path(manifest.content)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bridgetown-core-1.0.0.alpha1 lib/bridgetown-core/model/plugin_origin.rb