2012-04-25 21:17:49 +04:00
|
|
|
class RedminePluginModelGenerator < Rails::Generators::NamedBase
|
|
|
|
source_root File.expand_path("../templates", __FILE__)
|
|
|
|
argument :model, :type => :string
|
2008-09-05 14:31:06 +04:00
|
|
|
|
2012-04-25 21:17:49 +04:00
|
|
|
attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
|
2012-04-01 16:42:09 +04:00
|
|
|
|
2012-04-25 21:17:49 +04:00
|
|
|
def initialize(*args)
|
|
|
|
super
|
|
|
|
@plugin_name = file_name.underscore
|
2008-09-05 14:31:06 +04:00
|
|
|
@plugin_pretty_name = plugin_name.titleize
|
2012-04-25 21:17:49 +04:00
|
|
|
@plugin_path = "plugins/#{plugin_name}"
|
|
|
|
@model_class = model.camelize
|
2008-09-05 14:31:06 +04:00
|
|
|
end
|
2012-04-01 16:42:09 +04:00
|
|
|
|
2012-04-25 21:17:49 +04:00
|
|
|
def copy_templates
|
|
|
|
template 'model.rb.erb', "#{plugin_path}/app/models/#{model}.rb"
|
|
|
|
template 'unit_test.rb.erb', "#{plugin_path}/test/unit/#{model}_test.rb"
|
2008-10-25 13:35:51 +04:00
|
|
|
end
|
2008-09-05 14:31:06 +04:00
|
|
|
end
|