Class: Cog::Plugin

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

Overview

Describes a plugin found on the Config#plugin_path. The plugin DSL::Cogfile will have already been processed, and should have contained a call to DSL::Cogfile#autoload_plugin, which will make it’s DSL available to generators via a GeneratorSandbox.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cogfile_path) ⇒ Plugin

Returns a new instance of Plugin.

Parameters:

  • cogfile_path (String)

    path to the plugin Cogfile



19
20
21
22
23
24
25
26
27
# File 'lib/cog/plugin.rb', line 19

def initialize(cogfile_path)
  unless File.exists?(cogfile_path)
    raise Errors::InvalidPluginConfiguration.new :cogfile => cogfile_path
  end
  @cogfile_path = File.expand_path cogfile_path
  @path = File.dirname @cogfile_path
  @name = File.basename @path
  @name = $1 if /^(.+?)\-(\d|\.)+(rc2)?$/ =~ @name
end

Instance Attribute Details

#cogfile_pathString (readonly)

Returns path to the plugin’s cogfile.

Returns:

  • (String)

    path to the plugin’s cogfile



13
14
15
# File 'lib/cog/plugin.rb', line 13

def cogfile_path
  @cogfile_path
end

#nameString (readonly)

Returns name of the plugin.

Returns:

  • (String)

    name of the plugin



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

def name
  @name
end

#pathString (readonly)

Returns path to the plugin directory.

Returns:

  • (String)

    path to the plugin directory



10
11
12
# File 'lib/cog/plugin.rb', line 10

def path
  @path
end

#stamp_generator_blockBlock

Returns the block to use to stamp the generator.

Returns:

  • (Block)

    the block to use to stamp the generator



16
17
18
# File 'lib/cog/plugin.rb', line 16

def stamp_generator_block
  @stamp_generator_block
end

Instance Method Details

#<=>(other) ⇒ Object

Sort plugins by name



30
31
32
# File 'lib/cog/plugin.rb', line 30

def <=>(other)
  @name <=> other.name
end