1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Added a generator file responsable for loading generator files.

This commit is contained in:
José Valim 2009-06-23 16:19:23 +02:00
parent 1845675822
commit 301c48c15c
7 changed files with 40 additions and 18 deletions

View file

@ -14,8 +14,10 @@ else ARGV.size == 1
ARGV << "--help"
end
Dir[File.dirname(__FILE__) + '/../lib/generator/generators/*/*_generator.rb'].each do |file|
require file
require File.dirname(__FILE__) + '/../lib/generator'
Rails::Generators.builtin.each do |name|
require "generator/generators/#{name}/#{name}_generator"
end
name = ARGV.shift

View file

@ -9,5 +9,7 @@ end
ARGV << "--help" if ARGV.empty?
require File.dirname(__FILE__) + '/../lib/generator/generators/app/app_generator'
require File.dirname(__FILE__) + '/../lib/generator'
require 'generator/generators/app/app_generator'
Rails::Generators::AppGenerator.start

24
railties/lib/generator.rb Normal file
View file

@ -0,0 +1,24 @@
activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
$:.unshift(activesupport_path) if File.directory?(activesupport_path)
require 'active_support/all'
# TODO Use vendored Thor
require 'rubygems'
gem 'josevalim-thor'
require 'thor'
$:.unshift(File.dirname(__FILE__))
require 'rails/version' unless defined?(Rails::VERSION)
require 'generator/base'
require 'generator/named_base'
module Rails
module Generators
def self.builtin
Dir[File.dirname(__FILE__) + '/generator/generators/*'].collect do |file|
File.basename(file)
end
end
end
end

View file

@ -1,15 +1,4 @@
# Load ActiveSupport mini
activesupport_path = "#{File.dirname(__FILE__)}/../../../activesupport/lib"
$:.unshift(activesupport_path) if File.directory?(activesupport_path)
require 'active_support/all'
# TODO Use vendored Thor
require 'rubygems'
gem 'josevalim-thor'
require 'thor'
require File.dirname(__FILE__) + '/../rails/version' unless defined?(Rails::VERSION)
require File.dirname(__FILE__) + '/actions'
require 'generator/actions'
module Rails
module Generators

View file

@ -1,4 +1,3 @@
require File.dirname(__FILE__) + '/../../base'
require 'digest/md5'
require 'active_support/secure_random'

View file

@ -1,5 +1,3 @@
require File.dirname(__FILE__) + '/../../base'
module Rails::Generators
class MetalGenerator < Base
argument :file_name, :type => :string

View file

@ -0,0 +1,8 @@
require 'generator/base'
module Rails
module Generators
class NamedBase < Base
end
end
end