diff options
author | José Valim <jose.valim@gmail.com> | 2009-06-23 16:19:23 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-06-23 16:53:47 +0200 |
commit | 301c48c15cc6bf8d8fac3c22356eacce380f6fce (patch) | |
tree | 8000d68f8b2b6b78543c6e897973fcc88a18d1a0 | |
parent | 1845675822fef4ead89b8919da56c4fadb145e56 (diff) | |
download | rails-301c48c15cc6bf8d8fac3c22356eacce380f6fce.tar.gz rails-301c48c15cc6bf8d8fac3c22356eacce380f6fce.tar.bz2 rails-301c48c15cc6bf8d8fac3c22356eacce380f6fce.zip |
Added a generator file responsable for loading generator files.
-rwxr-xr-x | railties/bin/gen | 6 | ||||
-rwxr-xr-x | railties/bin/rails | 4 | ||||
-rw-r--r-- | railties/lib/generator.rb | 24 | ||||
-rw-r--r-- | railties/lib/generator/base.rb | 13 | ||||
-rw-r--r-- | railties/lib/generator/generators/app/app_generator.rb | 1 | ||||
-rw-r--r-- | railties/lib/generator/generators/metal/metal_generator.rb | 2 | ||||
-rw-r--r-- | railties/lib/generator/named_base.rb | 8 |
7 files changed, 40 insertions, 18 deletions
diff --git a/railties/bin/gen b/railties/bin/gen index 0567ab6058..f054d4e853 100755 --- a/railties/bin/gen +++ b/railties/bin/gen @@ -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 diff --git a/railties/bin/rails b/railties/bin/rails index 4d08ca392d..57eb8809ed 100755 --- a/railties/bin/rails +++ b/railties/bin/rails @@ -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 diff --git a/railties/lib/generator.rb b/railties/lib/generator.rb new file mode 100644 index 0000000000..cc3a983d60 --- /dev/null +++ b/railties/lib/generator.rb @@ -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 diff --git a/railties/lib/generator/base.rb b/railties/lib/generator/base.rb index 08f488932b..c1452cdb7f 100644 --- a/railties/lib/generator/base.rb +++ b/railties/lib/generator/base.rb @@ -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 diff --git a/railties/lib/generator/generators/app/app_generator.rb b/railties/lib/generator/generators/app/app_generator.rb index 3eb9b8c79a..45e46aed02 100644 --- a/railties/lib/generator/generators/app/app_generator.rb +++ b/railties/lib/generator/generators/app/app_generator.rb @@ -1,4 +1,3 @@ -require File.dirname(__FILE__) + '/../../base' require 'digest/md5' require 'active_support/secure_random' diff --git a/railties/lib/generator/generators/metal/metal_generator.rb b/railties/lib/generator/generators/metal/metal_generator.rb index 1c59a4e90a..d999bd89f7 100644 --- a/railties/lib/generator/generators/metal/metal_generator.rb +++ b/railties/lib/generator/generators/metal/metal_generator.rb @@ -1,5 +1,3 @@ -require File.dirname(__FILE__) + '/../../base' - module Rails::Generators class MetalGenerator < Base argument :file_name, :type => :string diff --git a/railties/lib/generator/named_base.rb b/railties/lib/generator/named_base.rb new file mode 100644 index 0000000000..1d3de123d5 --- /dev/null +++ b/railties/lib/generator/named_base.rb @@ -0,0 +1,8 @@ +require 'generator/base' + +module Rails + module Generators + class NamedBase < Base + end + end +end |