Sha256: b16d52beb4dcbc431ea591e810bd13f6bf873ae56dcd6d2cb2f0cfd5d8f06dcb

Contents?: true

Size: 943 Bytes

Versions: 5

Compression:

Stored size: 943 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|
            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

5 entries across 5 versions & 1 rubygems

Version Path
bridgetown-core-1.0.0.alpha6 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0.alpha5 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0.alpha4 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0.alpha3 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0.alpha2 lib/bridgetown-core/model/plugin_origin.rb