Class: Jax::Plugin

Inherits:
Engine
  • Object
show all
Defined in:
lib/jax/plugin.rb

Defined Under Namespace

Classes: Manifest

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Engine

find_root_with_flag, inherited

Constructor Details

#initialize(path) ⇒ Plugin

Returns a new instance of Plugin.



26
27
28
29
# File 'lib/jax/plugin.rb', line 26

def initialize(path)
  super()
  @relative_path = path.sub(/^#{Regexp::escape Jax.root.to_s}\/?/, '')
end

Instance Attribute Details

#relative_pathObject (readonly)

Returns the value of attribute relative_path.



7
8
9
# File 'lib/jax/plugin.rb', line 7

def relative_path
  @relative_path
end

Class Method Details

.all(list, paths) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jax/plugin.rb', line 10

def all(list, paths)
  plugins = []
  paths.each do |path|
    Dir["#{path}/*"].each do |plugin_path|
      plugin = new(plugin_path)
      next unless list.include?(plugin.name) || list.include?(:all)
      plugins << plugin
    end
  end

  plugins.sort_by do |p|
    [list.index(p.name) || list.index(:all), p.name.to_s]
  end
end

Instance Method Details

#configObject



46
47
48
# File 'lib/jax/plugin.rb', line 46

def config
  @config ||= Jax::Engine::Configuration.new(full_path)
end

#full_pathObject



38
39
40
# File 'lib/jax/plugin.rb', line 38

def full_path
  File.expand_path(relative_path, Jax.root)
end

#manifestObject



31
32
33
34
35
36
# File 'lib/jax/plugin.rb', line 31

def manifest
  @manifest ||= begin
    manifest = Jax::Plugin::Manifest.new(name)
    manifest.load
  end
end

#nameObject



42
43
44
# File 'lib/jax/plugin.rb', line 42

def name
  File.basename(relative_path)
end