Module: Cog::Controllers::PluginController

Defined in:
lib/cog/controllers/plugin_controller.rb

Overview

Manage cog plugins

Class Method Summary collapse

Class Method Details

.create(name) ⇒ nil

Generate a new project plugin with the given name

Parameters:

  • name (String)

    name of the plugin to create. Should not conflict with other plugin names

Returns:

  • (nil)

Raises:

  • (Errors::DuplicatePlugin)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cog/controllers/plugin_controller.rb', line 12

def self.create(name)
  raise Errors::DuplicatePlugin.new(name) unless Cog.plugin(name).nil?
  @cogfile_type = :plugin
  @prefix = ''
  @cog_version = Cog::VERSION
  @plugin_name = name.to_s.underscore
  @plugin_module = name.to_s.camelize
  prefix = Cog.project_plugin_path
  prefix = prefix ? "#{prefix}/" : ''
  opt = { :absolute_destination => true, :binding => binding }
  [
    ['Cogfile', 'Cogfile'],
    ['plugin/plugin.rb', "lib/#{@plugin_name}.rb"],
    ['plugin/generator.rb.erb', "templates/#{@plugin_name}/generator.rb.erb"],
  ].each do |tm, dest|
    Generator.stamp "cog/#{tm}", "#{prefix}#{@plugin_name}/#{dest}", opt
  end
  nil
end

.listArray<String>

Returns a list of available plugins.

Returns:



33
34
35
36
37
38
39
# File 'lib/cog/controllers/plugin_controller.rb', line 33

def self.list
  cs = Helpers::CascadingSet.new
  Cog.plugins.each do |plugin|
    cs.add_plugin plugin
  end
  cs.to_a
end