Merged rails-3.2 branch.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9528 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -3,19 +3,8 @@ Description:
|
||||
|
||||
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/config/locales
|
||||
create vendor/plugins/redmine_meetings/test
|
||||
create vendor/plugins/redmine_meetings/README.rdoc
|
||||
create vendor/plugins/redmine_meetings/init.rb
|
||||
create vendor/plugins/redmine_meetings/config/locales/en.yml
|
||||
create vendor/plugins/redmine_meetings/test/test_helper.rb
|
||||
create plugins/meetings/README.rdoc
|
||||
create plugins/meetings/init.rb
|
||||
create plugins/meetings/config/routes.rb
|
||||
create plugins/meetings/config/locales/en.yml
|
||||
create plugins/meetings/test/test_helper.rb
|
||||
|
||||
@@ -1,32 +1,33 @@
|
||||
class RedminePluginGenerator < Rails::Generator::NamedBase
|
||||
class RedminePluginGenerator < Rails::Generators::NamedBase
|
||||
source_root File.expand_path("../templates", __FILE__)
|
||||
|
||||
attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
|
||||
|
||||
def initialize(runtime_args, runtime_options = {})
|
||||
def initialize(*args)
|
||||
super
|
||||
@plugin_name = "redmine_#{file_name.underscore}"
|
||||
@plugin_name = file_name.underscore
|
||||
@plugin_pretty_name = plugin_name.titleize
|
||||
@plugin_path = "vendor/plugins/#{plugin_name}"
|
||||
@plugin_path = "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}/config/locales"
|
||||
m.directory "#{plugin_path}/test"
|
||||
def copy_templates
|
||||
empty_directory "#{plugin_path}/app"
|
||||
empty_directory "#{plugin_path}/app/controllers"
|
||||
empty_directory "#{plugin_path}/app/helpers"
|
||||
empty_directory "#{plugin_path}/app/models"
|
||||
empty_directory "#{plugin_path}/app/views"
|
||||
empty_directory "#{plugin_path}/db/migrate"
|
||||
empty_directory "#{plugin_path}/lib/tasks"
|
||||
empty_directory "#{plugin_path}/assets/images"
|
||||
empty_directory "#{plugin_path}/assets/javascripts"
|
||||
empty_directory "#{plugin_path}/assets/stylesheets"
|
||||
empty_directory "#{plugin_path}/config/locales"
|
||||
empty_directory "#{plugin_path}/test"
|
||||
|
||||
m.template 'README.rdoc', "#{plugin_path}/README.rdoc"
|
||||
m.template 'init.rb.erb', "#{plugin_path}/init.rb"
|
||||
m.template 'en_rails_i18n.yml', "#{plugin_path}/config/locales/en.yml"
|
||||
m.template 'test_helper.rb.erb', "#{plugin_path}/test/test_helper.rb"
|
||||
end
|
||||
template 'README.rdoc', "#{plugin_path}/README.rdoc"
|
||||
template 'init.rb.erb', "#{plugin_path}/init.rb"
|
||||
template 'routes.rb', "#{plugin_path}/config/routes.rb"
|
||||
template 'en_rails_i18n.yml', "#{plugin_path}/config/locales/en.yml"
|
||||
template 'test_helper.rb.erb', "#{plugin_path}/test/test_helper.rb"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
require 'redmine'
|
||||
|
||||
Redmine::Plugin.register :<%= plugin_name %> do
|
||||
name '<%= plugin_pretty_name %> plugin'
|
||||
author 'Author name'
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
# Plugin's routes
|
||||
# See: http://guides.rubyonrails.org/routing.html
|
||||
@@ -2,4 +2,4 @@ Description:
|
||||
Generates a plugin controller.
|
||||
|
||||
Example:
|
||||
./script/generate redmine_plugin_controller MyPlugin Pools index show vote
|
||||
./script/generate redmine_plugin_controller meetings pools index show vote
|
||||
|
||||
@@ -1,55 +1,27 @@
|
||||
require 'rails_generator/base'
|
||||
require 'rails_generator/generators/components/controller/controller_generator'
|
||||
class RedminePluginControllerGenerator < Rails::Generators::NamedBase
|
||||
source_root File.expand_path("../templates", __FILE__)
|
||||
argument :controller, :type => :string
|
||||
argument :actions, :type => :array, :default => [], :banner => "ACTION ACTION ..."
|
||||
|
||||
class RedminePluginControllerGenerator < ControllerGenerator
|
||||
attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
|
||||
|
||||
def initialize(runtime_args, runtime_options = {})
|
||||
runtime_args = runtime_args.dup
|
||||
usage if runtime_args.empty?
|
||||
@plugin_name = "redmine_" + runtime_args.shift.underscore
|
||||
def initialize(*args)
|
||||
super
|
||||
@plugin_name = file_name.underscore
|
||||
@plugin_pretty_name = plugin_name.titleize
|
||||
@plugin_path = "vendor/plugins/#{plugin_name}"
|
||||
super(runtime_args, runtime_options)
|
||||
@plugin_path = "plugins/#{plugin_name}"
|
||||
@controller_class = controller.camelize
|
||||
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
|
||||
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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class <%= class_name %>Controller < ApplicationController
|
||||
class <%= @controller_class %>Controller < ApplicationController
|
||||
unloadable
|
||||
|
||||
<% actions.each do |action| -%>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class <%= class_name %>ControllerTest < ActionController::TestCase
|
||||
class <%= @controller_class %>ControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
module <%= class_name %>Helper
|
||||
module <%= @controller_class %>Helper
|
||||
end
|
||||
|
||||
@@ -1 +1 @@
|
||||
<h2><%= class_name %>#<%= action %></h2>
|
||||
<h2><%= @controller_class %>Controller#<%= @action_name %></h2>
|
||||
|
||||
@@ -2,4 +2,4 @@ Description:
|
||||
Generates a plugin model.
|
||||
|
||||
Examples:
|
||||
./script/generate redmine_plugin_model MyPlugin pool title:string question:text
|
||||
./script/generate redmine_plugin_model meetings pool
|
||||
|
||||
@@ -1,45 +1,19 @@
|
||||
require 'rails_generator/base'
|
||||
require 'rails_generator/generators/components/model/model_generator'
|
||||
class RedminePluginModelGenerator < Rails::Generators::NamedBase
|
||||
source_root File.expand_path("../templates", __FILE__)
|
||||
argument :model, :type => :string
|
||||
|
||||
class RedminePluginModelGenerator < ModelGenerator
|
||||
attr_accessor :plugin_path, :plugin_name, :plugin_pretty_name
|
||||
attr_reader :plugin_path, :plugin_name, :plugin_pretty_name
|
||||
|
||||
def initialize(runtime_args, runtime_options = {})
|
||||
runtime_args = runtime_args.dup
|
||||
usage if runtime_args.empty?
|
||||
@plugin_name = "redmine_" + runtime_args.shift.underscore
|
||||
def initialize(*args)
|
||||
super
|
||||
@plugin_name = file_name.underscore
|
||||
@plugin_pretty_name = plugin_name.titleize
|
||||
@plugin_path = "vendor/plugins/#{plugin_name}"
|
||||
super(runtime_args, runtime_options)
|
||||
@plugin_path = "plugins/#{plugin_name}"
|
||||
@model_class = model.camelize
|
||||
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
|
||||
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"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# 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 -%>
|
||||
@@ -1,13 +0,0 @@
|
||||
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
|
||||
@@ -1,3 +1,3 @@
|
||||
class <%= class_name %> < ActiveRecord::Base
|
||||
class <%= @model_class %> < ActiveRecord::Base
|
||||
unloadable
|
||||
end
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class <%= class_name %>Test < ActiveSupport::TestCase
|
||||
fixtures :<%= table_name %>
|
||||
class <%= @model_class %>Test < ActiveSupport::TestCase
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
|
||||
Reference in New Issue
Block a user