Sha256: 41888cebbd4cfc61668df5eeb588ecb6ccf14b6262f0d71e13d7803756a70544

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

# Generates plugins for Mack applications.
# 
# Example:
#   rake generate:plugin name=my_cool_plugin
# This will generate the following in your mack application:
#   vendor/plugins/my_cool_plugin
#   vendor/plugins/my_cool_plugin/init.rb
#   vendor/plugins/my_cool_plugin/lib
#   vendor/plugins/my_cool_plugin/lib/my_cool_plugin.rb
class PluginGenerator < Mack::Generator::Base
  
  require_param :name
  
  def generate
    plugin_dir = File.join(MACK_ROOT, "vendor", "plugins", param(:name).downcase)
    template_dir = File.join(File.dirname(__FILE__), "templates")
    
    # create vendor/plugins/<name>
    directory(plugin_dir)
    # create vendor/plugins/<name>/lib
    directory(File.join(plugin_dir, "lib"))
    
    # create vendor/plugins/<name>/init.rb
    template(File.join(template_dir, "init.rb.template"), File.join(plugin_dir, "init.rb"))
    # create vendor/plugins/<name>/lib/<name>.rb
    template(File.join(template_dir, "lib", "plugin.rb.template"), File.join(plugin_dir, "lib", "#{param(:name).downcase}.rb"))
    
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mack-0.0.6.1 lib/generators/plugin_generator/plugin_generator.rb
mack-0.0.6.2 lib/generators/plugin_generator/plugin_generator.rb
mack-0.0.6 lib/generators/plugin_generator/plugin_generator.rb
mack-0.0.7.0 lib/generators/plugin_generator/plugin_generator.rb
mack-0.1.0 lib/generators/plugin_generator/plugin_generator.rb