Class: Bridgetown::Model::PluginOrigin

Inherits:
RepoOrigin show all
Defined in:
bridgetown-core/lib/bridgetown-core/model/plugin_origin.rb

Constant Summary

Constants inherited from Origin

Origin::EAGER_LOAD_DESCENDANTS

Instance Attribute Summary

Attributes inherited from RepoOrigin

#content, #front_matter_line_count

Attributes inherited from Origin

#id, #site

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RepoOrigin

#collection, data_file_extensions, #exists?, new_with_collection_path, #read, #url, #write

Methods included from FrontMatter::Importer

included, #read_front_matter

Methods inherited from Origin

#exists?, #initialize, #read, #verify_model?

Constructor Details

This class inherits a constructor from Bridgetown::Model::Origin

Class Method Details

.handle_scheme?(scheme) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'bridgetown-core/lib/bridgetown-core/model/plugin_origin.rb', line 7

def handle_scheme?(scheme)
  scheme == "plugin"
end

Instance Method Details

#manifestObject



12
13
14
15
16
17
18
19
20
21
# File 'bridgetown-core/lib/bridgetown-core/model/plugin_origin.rb', line 12

def manifest
  @manifest ||= begin
    manifest_origin = Addressable::URI.unescape(url.path.delete_prefix("/")).split("/").first
    site.config.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

#original_pathObject



29
30
31
# File 'bridgetown-core/lib/bridgetown-core/model/plugin_origin.rb', line 29

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

#relative_pathObject



23
24
25
26
27
# File 'bridgetown-core/lib/bridgetown-core/model/plugin_origin.rb', line 23

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