Adds a branch for unlimited project hierarchy.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/work@2148 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
Description:
|
||||
The plugin generator creates stubs for a new Redmine plugin.
|
||||
|
||||
Example:
|
||||
./script/generate redmine_plugin meetings
|
||||
create vendor/plugins/redmine_meetings/app/controllers
|
||||
create vendor/plugins/redmine_meetings/app/helpers
|
||||
create vendor/plugins/redmine_meetings/app/models
|
||||
create vendor/plugins/redmine_meetings/app/views
|
||||
create vendor/plugins/redmine_meetings/db/migrate
|
||||
create vendor/plugins/redmine_meetings/lib/tasks
|
||||
create vendor/plugins/redmine_meetings/assets/images
|
||||
create vendor/plugins/redmine_meetings/assets/javascripts
|
||||
create vendor/plugins/redmine_meetings/assets/stylesheets
|
||||
create vendor/plugins/redmine_meetings/lang
|
||||
create vendor/plugins/redmine_meetings/README
|
||||
create vendor/plugins/redmine_meetings/init.rb
|
||||
create vendor/plugins/redmine_meetings/lang/en.yml
|
||||
@@ -0,0 +1,31 @@
|
||||
class RedminePluginGenerator < Rails::Generator::NamedBase
|
||||
attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
|
||||
|
||||
def initialize(runtime_args, runtime_options = {})
|
||||
super
|
||||
@plugin_name = "redmine_#{file_name.underscore}"
|
||||
@plugin_pretty_name = plugin_name.titleize
|
||||
@plugin_path = "vendor/plugins/#{plugin_name}"
|
||||
end
|
||||
|
||||
def manifest
|
||||
record do |m|
|
||||
m.directory "#{plugin_path}/app/controllers"
|
||||
m.directory "#{plugin_path}/app/helpers"
|
||||
m.directory "#{plugin_path}/app/models"
|
||||
m.directory "#{plugin_path}/app/views"
|
||||
m.directory "#{plugin_path}/db/migrate"
|
||||
m.directory "#{plugin_path}/lib/tasks"
|
||||
m.directory "#{plugin_path}/assets/images"
|
||||
m.directory "#{plugin_path}/assets/javascripts"
|
||||
m.directory "#{plugin_path}/assets/stylesheets"
|
||||
m.directory "#{plugin_path}/lang"
|
||||
m.directory "#{plugin_path}/test"
|
||||
|
||||
m.template 'README.rdoc', "#{plugin_path}/README.rdoc"
|
||||
m.template 'init.rb.erb', "#{plugin_path}/init.rb"
|
||||
m.template 'en.yml', "#{plugin_path}/lang/en.yml"
|
||||
m.template 'test_helper.rb.erb', "#{plugin_path}/test/test_helper.rb"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
= <%= file_name %>
|
||||
|
||||
Description goes here
|
||||
@@ -0,0 +1,2 @@
|
||||
# English strings go here
|
||||
my_label: "My label"
|
||||
@@ -0,0 +1,8 @@
|
||||
require 'redmine'
|
||||
|
||||
Redmine::Plugin.register :<%= plugin_name %> do
|
||||
name '<%= plugin_pretty_name %> plugin'
|
||||
author 'Author name'
|
||||
description 'This is a plugin for Redmine'
|
||||
version '0.0.1'
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
# Load the normal Rails helper
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper')
|
||||
|
||||
# Ensure that we are using the temporary fixture path
|
||||
Engines::Testing.set_fixture_path
|
||||
@@ -0,0 +1,5 @@
|
||||
Description:
|
||||
Generates a plugin controller.
|
||||
|
||||
Example:
|
||||
./script/generate redmine_plugin_controller MyPlugin Pools index show vote
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
require 'rails_generator/base'
|
||||
require 'rails_generator/generators/components/controller/controller_generator'
|
||||
|
||||
class RedminePluginControllerGenerator < ControllerGenerator
|
||||
attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
|
||||
|
||||
def initialize(runtime_args, runtime_options = {})
|
||||
runtime_args = runtime_args.dup
|
||||
@plugin_name = "redmine_" + runtime_args.shift.underscore
|
||||
@plugin_pretty_name = plugin_name.titleize
|
||||
@plugin_path = "vendor/plugins/#{plugin_name}"
|
||||
super(runtime_args, runtime_options)
|
||||
end
|
||||
|
||||
def destination_root
|
||||
File.join(RAILS_ROOT, plugin_path)
|
||||
end
|
||||
|
||||
def manifest
|
||||
record do |m|
|
||||
# Check for class naming collisions.
|
||||
m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
|
||||
|
||||
# Controller, helper, views, and test directories.
|
||||
m.directory File.join('app/controllers', class_path)
|
||||
m.directory File.join('app/helpers', class_path)
|
||||
m.directory File.join('app/views', class_path, file_name)
|
||||
m.directory File.join('test/functional', class_path)
|
||||
|
||||
# Controller class, functional test, and helper class.
|
||||
m.template 'controller.rb.erb',
|
||||
File.join('app/controllers',
|
||||
class_path,
|
||||
"#{file_name}_controller.rb")
|
||||
|
||||
m.template 'functional_test.rb.erb',
|
||||
File.join('test/functional',
|
||||
class_path,
|
||||
"#{file_name}_controller_test.rb")
|
||||
|
||||
m.template 'helper.rb.erb',
|
||||
File.join('app/helpers',
|
||||
class_path,
|
||||
"#{file_name}_helper.rb")
|
||||
|
||||
# View template for each action.
|
||||
actions.each do |action|
|
||||
path = File.join('app/views', class_path, file_name, "#{action}.html.erb")
|
||||
m.template 'view.html.erb', path,
|
||||
:assigns => { :action => action, :path => path }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
class <%= class_name %>Controller < ApplicationController
|
||||
<% actions.each do |action| -%>
|
||||
|
||||
def <%= action %>
|
||||
end
|
||||
<% end -%>
|
||||
end
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class <%= class_name %>ControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,2 @@
|
||||
module <%= class_name %>Helper
|
||||
end
|
||||
@@ -0,0 +1 @@
|
||||
<h2><%= class_name %>#<%= action %></h2>
|
||||
@@ -0,0 +1,5 @@
|
||||
Description:
|
||||
Generates a plugin model.
|
||||
|
||||
Examples:
|
||||
./script/generate redmine_plugin_model MyPlugin pool title:string question:text
|
||||
@@ -0,0 +1,44 @@
|
||||
require 'rails_generator/base'
|
||||
require 'rails_generator/generators/components/model/model_generator'
|
||||
|
||||
class RedminePluginModelGenerator < ModelGenerator
|
||||
attr_accessor :plugin_path, :plugin_name, :plugin_pretty_name
|
||||
|
||||
def initialize(runtime_args, runtime_options = {})
|
||||
runtime_args = runtime_args.dup
|
||||
@plugin_name = "redmine_" + runtime_args.shift.underscore
|
||||
@plugin_pretty_name = plugin_name.titleize
|
||||
@plugin_path = "vendor/plugins/#{plugin_name}"
|
||||
super(runtime_args, runtime_options)
|
||||
end
|
||||
|
||||
def destination_root
|
||||
File.join(RAILS_ROOT, plugin_path)
|
||||
end
|
||||
|
||||
def manifest
|
||||
record do |m|
|
||||
# Check for class naming collisions.
|
||||
m.class_collisions class_path, class_name, "#{class_name}Test"
|
||||
|
||||
# Model, test, and fixture directories.
|
||||
m.directory File.join('app/models', class_path)
|
||||
m.directory File.join('test/unit', class_path)
|
||||
m.directory File.join('test/fixtures', class_path)
|
||||
|
||||
# Model class, unit test, and fixtures.
|
||||
m.template 'model.rb.erb', File.join('app/models', class_path, "#{file_name}.rb")
|
||||
m.template 'unit_test.rb.erb', File.join('test/unit', class_path, "#{file_name}_test.rb")
|
||||
|
||||
unless options[:skip_fixture]
|
||||
m.template 'fixtures.yml', File.join('test/fixtures', "#{table_name}.yml")
|
||||
end
|
||||
|
||||
unless options[:skip_migration]
|
||||
m.migration_template 'migration.rb.erb', 'db/migrate', :assigns => {
|
||||
:migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
|
||||
}, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
one:
|
||||
id: 1
|
||||
<% for attribute in attributes -%>
|
||||
<%= attribute.name %>: <%= attribute.default %>
|
||||
<% end -%>
|
||||
two:
|
||||
id: 2
|
||||
<% for attribute in attributes -%>
|
||||
<%= attribute.name %>: <%= attribute.default %>
|
||||
<% end -%>
|
||||
@@ -0,0 +1,13 @@
|
||||
class <%= migration_name %> < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :<%= table_name %> do |t|
|
||||
<% for attribute in attributes -%>
|
||||
t.column :<%= attribute.name %>, :<%= attribute.type %>
|
||||
<% end -%>
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :<%= table_name %>
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,2 @@
|
||||
class <%= class_name %> < ActiveRecord::Base
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class <%= class_name %>Test < Test::Unit::TestCase
|
||||
fixtures :<%= table_name %>
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user