aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-12-29 11:52:06 +0100
committerJosé Valim <jose.valim@gmail.com>2009-12-29 23:58:34 +0100
commit1a4d909c6845c091a04e2533ab89502de4130c1b (patch)
tree4022fad3a8d6a34aa0c6b3565b440caafb5be04e /railties/lib/rails/generators
parent66604b2e0e8d3aba25cab673c7a3d7831a68490c (diff)
downloadrails-1a4d909c6845c091a04e2533ab89502de4130c1b.tar.gz
rails-1a4d909c6845c091a04e2533ab89502de4130c1b.tar.bz2
rails-1a4d909c6845c091a04e2533ab89502de4130c1b.zip
Add rails app --edge and rails app --dev
Diffstat (limited to 'railties/lib/rails/generators')
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb24
-rw-r--r--railties/lib/rails/generators/rails/app/templates/Gemfile9
2 files changed, 25 insertions, 8 deletions
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index ef5399e48f..22a27fdac2 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -3,6 +3,10 @@ require 'active_support/secure_random'
require 'rails/version' unless defined?(Rails::VERSION)
module Rails::Generators
+ # We need to store the RAILS_DEV_PATH in a constant, otherwise the path
+ # can change in Ruby 1.8.7 when we FileUtils.cd.
+ RAILS_DEV_PATH = File.expand_path("../../../../../..", File.dirname(__FILE__))
+
class AppGenerator < Base
DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
add_shebang_option!
@@ -15,17 +19,22 @@ module Rails::Generators
class_option :template, :type => :string, :aliases => "-m",
:desc => "Path to an application template (can be a filesystem path or URL)."
+ class_option :dev, :type => :boolean, :default => false,
+ :desc => "Setup the application with Gemfile pointing to your Rails checkout"
+
+ class_option :edge, :type => :boolean, :default => false,
+ :desc => "Setup the application with Gemfile pointing to Rails repository"
+
class_option :skip_activerecord, :type => :boolean, :aliases => "-O", :default => false,
- :desc => "Skip ActiveRecord files"
+ :desc => "Skip ActiveRecord files"
class_option :skip_testunit, :type => :boolean, :aliases => "-T", :default => false,
- :desc => "Skip TestUnit files"
+ :desc => "Skip TestUnit files"
class_option :skip_prototype, :type => :boolean, :aliases => "-J", :default => false,
- :desc => "Skip Prototype files"
+ :desc => "Skip Prototype files"
- # Add Rails options
- #
+ # Add bin/rails options
class_option :version, :type => :boolean, :aliases => "-v", :group => :rails,
:desc => "Show Rails version number and quit"
@@ -173,7 +182,6 @@ module Rails::Generators
end
# Define file as an alias to create_file for backwards compatibility.
- #
def file(*args, &block)
create_file(*args, &block)
end
@@ -190,6 +198,10 @@ module Rails::Generators
ActiveSupport::SecureRandom.hex(64)
end
+ def dev_or_edge?
+ options.dev? || options.edge?
+ end
+
def self.banner
"#{$0} #{self.arguments.map(&:usage).join(' ')} [options]"
end
diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile
index 8e851a64e7..59c6d333e2 100644
--- a/railties/lib/rails/generators/rails/app/templates/Gemfile
+++ b/railties/lib/rails/generators/rails/app/templates/Gemfile
@@ -1,9 +1,14 @@
# Edit this Gemfile to bundle your application's dependencies.
-
+<% if !dev_or_edge? %>
gem "rails", "<%= Rails::VERSION::STRING %>"
+<% end -%>
## Bundle edge rails:
-# gem "rails", :git => "git://github.com/rails/rails.git"
+<%- if options.dev? -%>
+gem "rails", :path => "<%= Rails::Generators::RAILS_DEV_PATH %>"
+<%- else -%>
+<%= "# " unless options.edge? %>gem "rails", :git => "git://github.com/rails/rails.git"
+<%- end -%>
## Bundle the gems you use:
# gem "bj"