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

Use Rails generators files organization.

This commit is contained in:
José Valim 2009-06-21 10:06:02 +02:00
parent 04eb5b6e34
commit f03890e151
65 changed files with 14 additions and 12 deletions

View file

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

View file

@ -1,10 +1,16 @@
require File.dirname(__FILE__) + '/actions'
# 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'
module Rails
module Generators
class Error < Thor::Error
@ -18,11 +24,8 @@ module Rails
#
def self.source_root
@source_root ||= begin
klass_name = self.name
klass_name.gsub!(/^Rails::Generators::/, '')
klass_name.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
klass_name.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
File.expand_path(File.join(File.dirname(__FILE__), 'templates', klass_name.downcase))
klass_name = self.name.gsub(/^Rails::Generators::/, '')
File.expand_path(File.join(File.dirname(__FILE__), 'generators', klass_name.underscore, 'templates'))
end
end
@ -31,7 +34,7 @@ module Rails
# Use Rails default banner.
#
def self.banner
"#{$0} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
"#{$0} #{self.arguments.map(&:usage).join(' ')} [options]"
end
# Small macro to ruby as an option to the generator with proper default

View file

@ -1,5 +1,4 @@
require File.dirname(__FILE__) + '/../../rails/version' unless defined?(Rails::VERSION)
require File.dirname(__FILE__) + '/../base'
require File.dirname(__FILE__) + '/../../base'
require 'digest/md5'
require 'active_support/secure_random'

View file

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View file

@ -4,13 +4,13 @@ require 'fileutils'
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib"
# For this while, let's load all generators by hand
require 'generator/generators/app'
require 'generator/generators/app/app_generator'
class GeneratorTestCase < Test::Unit::TestCase
include FileUtils
def destination_root
@destinartion_root ||= File.expand_path("#{File.dirname(__FILE__)}/../fixtures/tmp")
@destination_root ||= File.expand_path("#{File.dirname(__FILE__)}/../fixtures/tmp")
end
def setup