Sha256: 72edebfb170b1c1b8867c3f744ed90a4882bcd4d8628bb740014c40951f8be2b

Contents?: true

Size: 941 Bytes

Versions: 13

Compression:

Stored size: 941 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..].join("/")
        )
      end

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bridgetown-core-1.1.0 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.1.0.beta3 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.1.0.beta2 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.1.0.beta1 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0.beta3 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0.beta2 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0.beta1 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0.alpha11 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0.alpha10 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0.alpha9 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0.alpha8 lib/bridgetown-core/model/plugin_origin.rb
bridgetown-core-1.0.0.alpha7 lib/bridgetown-core/model/plugin_origin.rb