view .svn/pristine/3e/3e339092f343524c6085cf1a81f2c664a0ae64ee.svn-base @ 1386:e4c393cebb1a luisf

Merger from testing branch.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 24 Sep 2013 16:25:05 +0100
parents 038ba2d95de8
children
line wrap: on
line source
class RedminePluginControllerGenerator < Rails::Generators::NamedBase
  source_root File.expand_path("../templates", __FILE__)
  argument :controller, :type => :string
  argument :actions, :type => :array, :default => [], :banner => "ACTION ACTION ..."

  attr_reader :plugin_path, :plugin_name, :plugin_pretty_name

  def initialize(*args)
    super
    @plugin_name = file_name.underscore
    @plugin_pretty_name = plugin_name.titleize
    @plugin_path = "plugins/#{plugin_name}"
    @controller_class = controller.camelize
  end

  def copy_templates
    template 'controller.rb.erb', "#{plugin_path}/app/controllers/#{controller}_controller.rb"
    template 'helper.rb.erb', "#{plugin_path}/app/helpers/#{controller}_helper.rb"
    template 'functional_test.rb.erb', "#{plugin_path}/test/functional/#{controller}_controller_test.rb"
    # View template for each action.
    actions.each do |action|
      path = "#{plugin_path}/app/views/#{controller}/#{action}.html.erb"
      @action_name = action
      template 'view.html.erb', path
    end
  end
end