diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-07 13:14:05 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-07 13:14:05 +0000 |
commit | daee6fd92ac16878f6806c3382a9e74592aa9656 (patch) | |
tree | d477c6502960cb141403f8b4640dd483b487e5df /railties/bin | |
parent | 838c5a3d82367977d13ced01f9e28c22ccff32ef (diff) | |
download | rails-daee6fd92ac16878f6806c3382a9e74592aa9656.tar.gz rails-daee6fd92ac16878f6806c3382a9e74592aa9656.tar.bz2 rails-daee6fd92ac16878f6806c3382a9e74592aa9656.zip |
Added new generator framework that informs about its doings on generation and enables updating and destruction of generated artifacts. See the new script/destroy and script/update for more details #487 [bitsweat]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@518 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/bin')
-rw-r--r-- | railties/bin/destroy | 8 | ||||
-rwxr-xr-x | railties/bin/generate | 73 | ||||
-rwxr-xr-x | railties/bin/rails | 33 | ||||
-rw-r--r-- | railties/bin/update | 8 |
4 files changed, 26 insertions, 96 deletions
diff --git a/railties/bin/destroy b/railties/bin/destroy new file mode 100644 index 0000000000..6c1848ce1e --- /dev/null +++ b/railties/bin/destroy @@ -0,0 +1,8 @@ +#!/usr/local/bin/ruby +require File.dirname(__FILE__) + '/../config/environment' +require 'rails_generator' +require 'rails_generator/simple_logger' +require 'rails_generator/scripts/destroy' + +Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new(STDOUT) +Rails::Generator::Scripts::Destroy.new.run(ARGV) diff --git a/railties/bin/generate b/railties/bin/generate index 42698f8be7..8bce002510 100755 --- a/railties/bin/generate +++ b/railties/bin/generate @@ -1,73 +1,8 @@ #!/usr/local/bin/ruby require File.dirname(__FILE__) + '/../config/environment' require 'rails_generator' +require 'rails_generator/simple_logger' +require 'rails_generator/scripts/generate' -ARGV.shift unless ARGV.empty? or not ['--help', '-h'].include?(ARGV[0]) - -def find_synonyms(word) - require 'open-uri' - require 'timeout' - - uri = "http://wordnet.princeton.edu/cgi-bin/webwn2.0?stage=2" + - "&word=%s&posnumber=1&searchtypenumber=2&senses=&showglosses=1" - - timeout(5) do - open(uri % word) do |stream| - data = stream.read.gsub(" ", " ").gsub("<BR>", "") - data.scan(/^Sense \d+\n.+?\n\n/m) - end - end -rescue Timeout::Error, Exception - return nil -end - -unless ARGV.empty? - begin - name = ARGV.shift - generator = Rails::Generator.instance(name, ARGV) - - if msg = generator.collision_with_builtin? then - $stderr.puts msg - - if synonyms = find_synonyms(generator.class_name) then - $stderr.puts( - "", "Here are a few synonyms from WordNet. Maybe they will help you find an alternative name.", - "", synonyms - ) - end - else - generator.generate - end - rescue Rails::Generator::UsageError => e - puts e.message - end -else - builtin_generators = Rails::Generator.builtin_generators.join(', ') - contrib_generators = Rails::Generator.contrib_generators.join(', ') - - $stderr.puts <<end_usage - #{$0} generator [args] - - Rails comes with #{builtin_generators} generators. - #{$0} controller Login login logout - #{$0} model Account - #{$0} mailer AccountMailer - #{$0} scaffold Account action another_action - -end_usage - - unless contrib_generators.empty? - $stderr.puts " Installed generators (in #{RAILS_ROOT}/script/generators):" - $stderr.puts " #{contrib_generators}" - $stderr.puts - end - - $stderr.puts <<end_usage - More generators are available at http://rubyonrails.org/show/Generators - 1. Download, for example, login_generator.tar.gz - 2. Unzip to directory #{RAILS_ROOT}/script/generators/login - 3. Generate without args for usage information - #{$0} login -end_usage - exit 0 -end +Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new(STDOUT) +Rails::Generator::Scripts::Generate.new.run(ARGV) diff --git a/railties/bin/rails b/railties/bin/rails index 7b3eebea82..da9b2af041 100755 --- a/railties/bin/rails +++ b/railties/bin/rails @@ -1,28 +1,7 @@ -if ARGV[0] - ENV["RAILS_PKG_DESTINATION"] = File.expand_path(ARGV[0]) - if RUBY_PLATFORM =~ /mswin32/ - Dir.chdir File.dirname(__FILE__) - system %{rake.cmd fresh_gem_rails} - else - system %{ cd #{File.dirname(__FILE__)}; rake fresh_gem_rails } - end -else - puts <<-HELP +require File.dirname(__FILE__) + '/../lib/rails_generator' +require 'rails_generator/simple_logger' +require 'rails_generator/scripts/generate' -NAME - rails - creates a new Rails installation - -SYNOPSIS - rails [full path] - -DESCRIPTION - This generator will create a suggested directory structure, lots of minor helper - files, and a default configuration for creating a new Rails application. Once the - generator is done, you're advised to look at the README in the root of the folder. - -EXAMPLE - rails ~/Code/Ruby/weblog - - This will generate a new Rails installation in the ~/Code/Ruby/weblog folder. -HELP -end
\ No newline at end of file +Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new(STDOUT) +Rails::Generator::Base.use_application_sources! +Rails::Generator::Scripts::Generate.new.run(ARGV, :generator => 'app') diff --git a/railties/bin/update b/railties/bin/update new file mode 100644 index 0000000000..64cc49cf02 --- /dev/null +++ b/railties/bin/update @@ -0,0 +1,8 @@ +#!/usr/local/bin/ruby +require File.dirname(__FILE__) + '/../config/environment' +require 'rails_generator' +require 'rails_generator/simple_logger' +require 'rails_generator/scripts/update' + +Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new(STDOUT) +Rails::Generator::Scripts::Update.new.run(ARGV) |