-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new generator framework that informs about its doings on genera…
…tion 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
- Loading branch information
Showing
61 changed files
with
1,850 additions
and
644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new(STDOUT) | ||
Rails::Generator::Base.use_application_sources! | ||
Rails::Generator::Scripts::Generate.new.run(ARGV, :generator => 'app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +0,0 @@ | ||
GENERATOR | ||
model - create model stub files | ||
|
||
SYNOPSIS | ||
generate model ModelName | ||
|
||
DESCRIPTION | ||
The model generator takes a model name and generates an empty model in | ||
app/models, a test suite in test/unit with one passing test case, and a | ||
fixtures YAML file in the test/fixtures directory. | ||
|
||
EXAMPLE | ||
./script/generate model Account | ||
|
||
This will generate an Account class in app/models/account.rb, an | ||
AccountTest in test/unit/account_test.rb, and the fixtures file | ||
test/fixtures/account.yml. | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.