Class: Cog::Plugin
- Inherits:
-
Object
- Object
- Cog::Plugin
- 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
-
#cogfile_path ⇒ String
readonly
Path to the plugin’s cogfile.
-
#name ⇒ String
readonly
Name of the plugin.
-
#path ⇒ String
readonly
Path to the plugin directory.
-
#stamp_generator_block ⇒ Block
The block to use to stamp the generator.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Sort plugins by name.
-
#initialize(cogfile_path) ⇒ Plugin
constructor
A new instance of Plugin.
Constructor Details
#initialize(cogfile_path) ⇒ Plugin
Returns a new instance of Plugin.
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. cogfile_path @path = File.dirname @cogfile_path @name = File.basename @path @name = $1 if /^(.+?)\-(\d|\.)+(rc2)?$/ =~ @name end |
Instance Attribute Details
#cogfile_path ⇒ String (readonly)
Returns path to the plugin’s cogfile.
13 14 15 |
# File 'lib/cog/plugin.rb', line 13 def cogfile_path @cogfile_path end |
#name ⇒ String (readonly)
Returns name of the plugin.
7 8 9 |
# File 'lib/cog/plugin.rb', line 7 def name @name end |
#path ⇒ String (readonly)
Returns path to the plugin directory.
10 11 12 |
# File 'lib/cog/plugin.rb', line 10 def path @path end |
#stamp_generator_block ⇒ Block
Returns 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 |