From 1a4d909c6845c091a04e2533ab89502de4130c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 29 Dec 2009 11:52:06 +0100 Subject: Add rails app --edge and rails app --dev --- .../rails/generators/rails/app/app_generator.rb | 24 ++++++++++++++++------ .../rails/generators/rails/app/templates/Gemfile | 9 ++++++-- 2 files changed, 25 insertions(+), 8 deletions(-) (limited to 'railties/lib/rails') 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" -- cgit v1.2.3