Sha256: 632049e1b4a3b72adcf3e06443667b57bccaf561290b7cf603eb907a35c43410

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 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 # :nodoc:
    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

8 entries across 8 versions & 1 rubygems

Version Path
mack-0.2.0.1 lib/generators/plugin_generator/plugin_generator.rb
mack-0.2.0 lib/generators/plugin_generator/plugin_generator.rb
mack-0.3.0 lib/generators/plugin_generator/plugin_generator.rb
mack-0.4.0 lib/generators/plugin_generator/plugin_generator.rb
mack-0.4.0.1 lib/generators/plugin_generator/plugin_generator.rb
mack-0.4.1 lib/generators/plugin_generator/plugin_generator.rb
mack-0.4.2.1 lib/generators/plugin_generator/plugin_generator.rb
mack-0.4.2 lib/generators/plugin_generator/plugin_generator.rb