module Mygen::Plugins

Load plugins from a dir (default to $HOME/.mygen/plugins) Add all subdirs to $LOAD_PATH, and get ancestors of the generator class And register them in the myg shell command

Public Class Methods

load(path = File.join( ENV['HOME'], ".mygen", "plugins")) click to toggle source
# File lib/mygen/plugins.rb, line 8
def self.load(path = File.join( ENV['HOME'], ".mygen", "plugins"))
  path = path.gsub /\\/, '/'
  dirs = Dir.glob(File.join(path, "**/*.rb"))
  dirs.each do |d|
    register_plugin(d)
  end
  Generator.descendants
end
register_plugin(plugin) click to toggle source
# File lib/mygen/plugins.rb, line 17
def self.register_plugin(plugin)
  dir = File.dirname(plugin)
  $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
  klass = File.basename(plugin, '.rb').downcase
  require klass
end