mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Improving generators runner.
This commit is contained in:
@@ -7,22 +7,40 @@ if %w(--version -v).include? ARGV.first
|
||||
exit(0)
|
||||
end
|
||||
|
||||
require File.dirname(__FILE__) + '/../lib/generators'
|
||||
|
||||
if ARGV.size == 0
|
||||
puts "Please select a generator. Options: foo, bar"
|
||||
return
|
||||
rails = Rails::Generators.builtin.map do |group, name|
|
||||
name if group == "rails"
|
||||
end
|
||||
rails.compact!
|
||||
rails.sort!
|
||||
|
||||
others = Rails::Generators.builtin.map do |group, name|
|
||||
"#{group}:#{name}" unless rails.include?(name)
|
||||
end.compact
|
||||
others.sort!
|
||||
|
||||
puts "Please select a generator."
|
||||
puts "Builtin: #{rails.join(', ')}."
|
||||
puts "Others: #{others.join(', ')}."
|
||||
|
||||
exit
|
||||
elsif ARGV.size == 1
|
||||
ARGV << "--help"
|
||||
end
|
||||
|
||||
require File.dirname(__FILE__) + '/../lib/generators'
|
||||
|
||||
Rails::Generators.builtin.each do |group, name|
|
||||
require "generators/#{group}/#{name}/#{name}_generator"
|
||||
end
|
||||
|
||||
name = ARGV.shift
|
||||
name = ARGV.shift
|
||||
middle = name.sub(':', ':generators:') if name.count(':') == 1
|
||||
full = "rails:generators:#{name}" if name.count(':') == 0
|
||||
|
||||
if klass = Thor::Util.find_by_namespace("rails:generators:#{name}")
|
||||
if full && klass = Thor::Util.find_by_namespace(full)
|
||||
klass.start
|
||||
elsif middle && klass = Thor::Util.find_by_namespace(middle)
|
||||
klass.start
|
||||
elsif klass = Thor::Util.find_by_namespace(name)
|
||||
klass.start
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module Erb
|
||||
module Generators
|
||||
class MailerGenerator < Base
|
||||
argument :actions, :type => :array, :default => []
|
||||
argument :actions, :type => :array, :default => [], :banner => "method method"
|
||||
|
||||
def create_view_folder
|
||||
empty_directory File.join("app", "views", file_path)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module Rails
|
||||
module Generators
|
||||
class MailerGenerator < NamedBase
|
||||
argument :actions, :type => :array, :default => []
|
||||
argument :actions, :type => :array, :default => [], :banner => "method method"
|
||||
|
||||
def check_class_collision
|
||||
class_collisions class_name
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module TestUnit
|
||||
module Generators
|
||||
class MailerGenerator < Base
|
||||
argument :actions, :type => :array, :default => []
|
||||
argument :actions, :type => :array, :default => [], :banner => "method method"
|
||||
|
||||
def create_test_files
|
||||
template "unit_test.rb", File.join('test', 'unit', class_path, "#{file_name}_test.rb")
|
||||
|
||||
Reference in New Issue
Block a user