Skip to content

Commit

Permalink
Use Rails generators files organization.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jun 23, 2009
1 parent 04eb5b6 commit f03890e
Show file tree
Hide file tree
Showing 65 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion railties/bin/rails
Expand Up @@ -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
17 changes: 10 additions & 7 deletions railties/lib/generator/base.rb
@@ -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
Expand All @@ -18,11 +24,8 @@ class Base < Thor::Group
#
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

Expand All @@ -31,7 +34,7 @@ def self.source_root
# 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
Expand Down
File renamed without changes.
@@ -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'

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions railties/test/generator/generator_test_helper.rb
Expand Up @@ -4,13 +4,13 @@
$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
Expand Down

0 comments on commit f03890e

Please sign in to comment.