diff options
author | Rizwan Reza <rizwanreza@gmail.com> | 2010-06-05 04:04:49 +0430 |
---|---|---|
committer | Rizwan Reza <rizwanreza@gmail.com> | 2010-06-05 04:04:49 +0430 |
commit | e6f2102178b19ac8d49363b5fa145f22483c30ee (patch) | |
tree | b5dff24210eb3f521087fe66a9b734165ad22967 /railties | |
parent | 1535b02a9f8e0eaa3cd3182a45d2bd7855c3809c (diff) | |
parent | 8e8cb1769f3a78c53e5b79d0ce6a08589045cfca (diff) | |
download | rails-e6f2102178b19ac8d49363b5fa145f22483c30ee.tar.gz rails-e6f2102178b19ac8d49363b5fa145f22483c30ee.tar.bz2 rails-e6f2102178b19ac8d49363b5fa145f22483c30ee.zip |
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/guides/source/3_0_release_notes.textile | 7 | ||||
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 14 | ||||
-rw-r--r-- | railties/guides/source/generators.textile | 14 | ||||
-rw-r--r-- | railties/guides/source/getting_started.textile | 2 | ||||
-rw-r--r-- | railties/guides/source/rails_application_templates.textile | 4 | ||||
-rw-r--r-- | railties/lib/rails/commands.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/commands/application.rb | 7 | ||||
-rw-r--r-- | railties/lib/rails/commands/destroy.rb | 1 | ||||
-rwxr-xr-x | railties/lib/rails/commands/generate.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/generators.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/USAGE | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/app_generator.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/Gemfile | 3 | ||||
-rw-r--r-- | railties/test/application/initializers/frameworks_test.rb | 4 | ||||
-rw-r--r-- | railties/test/generators/generators_test_helper.rb | 7 |
16 files changed, 54 insertions, 35 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 1d76c77ade..fe3ab3cdcf 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,7 +1,7 @@ *Rails 3.0.0 [beta 4/release candidate] (unreleased)* * Version bump - +* Removed Rails Metal [YK & JV]. *Rails 3.0.0 [beta 3] (April 13th, 2010)* diff --git a/railties/guides/source/3_0_release_notes.textile b/railties/guides/source/3_0_release_notes.textile index b7f4fbf35c..75c03be87c 100644 --- a/railties/guides/source/3_0_release_notes.textile +++ b/railties/guides/source/3_0_release_notes.textile @@ -81,7 +81,7 @@ The new installing rails sequence (for the beta) is: <shell> $ gem install rails --prerelease -$ rails myapp +$ rails new myapp $ cd myapp </shell> @@ -98,13 +98,13 @@ h4. Living on the Edge If you want to bundle straight from the Git repository, you can pass the +--edge+ flag: <shell> -$ rails myapp --edge +$ rails new myapp --edge </shell> If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the +--dev+ flag: <shell> -$ ruby /path/to/rails/bin/rails myapp --dev +$ ruby /path/to/rails/bin/rails new myapp --dev </shell> h3. Rails Architectural Changes @@ -512,6 +512,7 @@ These are the main changes in Active Support: * Active Support no longer provides vendored versions of "TZInfo":http://tzinfo.rubyforge.org/, "Memcache Client":http://deveiate.org/projects/RMemCache/ and "Builder":http://builder.rubyforge.org/, these are all included as dependencies and installed via the <tt>bundle install</tt> command. * Safe buffers are implemented in <tt>ActiveSupport::SafeBuffer</tt>. * Added <tt>Array.uniq_by</tt> and <tt>Array.uniq_by!</tt>. +* Removed <tt>Array#rand</tt> and backported <tt>Array#sample</tt> from Ruby 1.9. * Fixed bug on +TimeZone.seconds_to_utc_offset+ returning wrong value. * Added <tt>ActiveSupport::Notifications</tt> middleware. * <tt>ActiveSupport.use_standard_json_time_format</tt> now defaults to true. diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index de82e871a6..30b2099be4 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1927,13 +1927,21 @@ Similarly, +from+ returns the tail from the element at the passed index on: The methods +second+, +third+, +fourth+, and +fifth+ return the corresponding element (+first+ is builtin). Thanks to social wisdom and positive constructiveness all around, +forty_two+ is also available. -You can pick a random element with +random_element+: +NOTE: Defined in +active_support/core_ext/array/access.rb+. + +h4. Random Access + +Active Support backports +sample+ from Ruby 1.9: <ruby> -shape_type = [Circle, Square, Triangle].random_element +shape_type = [Circle, Square, Triangle].sample +# => Square, for example + +shape_types = [Circle, Square, Triangle].sample(2) +# => [Triangle, Circle], for example </ruby> -NOTE: Defined in +active_support/core_ext/array/access.rb+. +NOTE: Defined in +active_support/core_ext/array/random_access.rb+. h4. Options Extraction diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index d3757e9733..704a8793b2 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -20,7 +20,7 @@ h3. First contact When you create an application using the +rails+ command, you are in fact using a Rails generator. After that, you can get a list of all available generators by just invoking +rails generate+: <shell> -$ rails myapp +$ rails new myapp $ cd myapp $ rails generate </shell> @@ -322,14 +322,10 @@ config.generators do |g| g.template_engine :erb g.test_framework :shoulda, :fixture => false g.stylesheets false -end -</ruby> - -And at the end of the same file: -<ruby> -require 'rails/generators' -Rails::Generators.fallbacks[:shoulda] = :test_unit + # Add a fallback! + g.fallbacks[:should] = :test_unit +end </ruby> Now, if create a Comment scaffold, you will see that shoulda generators are being invoked, and at the end, they are just falling back to test unit generators: @@ -361,7 +357,7 @@ $ rails generate scaffold Comment body:text create test/unit/helpers/comments_helper_test.rb </shell> -Such tool allows your generators to have single responsibility, increasing the code reuse and reducing the amount of code duplication. +Such tool allows your generators to have single responsibility, increasing the code reuse and reducing the amount of duplication. h3. Changelog diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile index 46e709d0f5..89551a223d 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -160,7 +160,7 @@ The best way to use this guide is to follow each step as it happens, no code or To begin, open a terminal, navigate to a folder where you have rights to create files, and type: <shell> -$ rails blog +$ rails new blog </shell> This will create a Rails application called Blog in a directory called blog. diff --git a/railties/guides/source/rails_application_templates.textile b/railties/guides/source/rails_application_templates.textile index baaa3d6d66..1af6f56957 100644 --- a/railties/guides/source/rails_application_templates.textile +++ b/railties/guides/source/rails_application_templates.textile @@ -14,13 +14,13 @@ h3. Usage To apply a template, you need to provide the Rails generator with the location of the template you wish to apply, using -m option : <shell> -$ rails blog -m ~/template.rb +$ rails new blog -m ~/template.rb </shell> It's also possible to apply a template using a URL : <shell> -$ rails blog -m http://gist.github.com/31208.txt +$ rails new blog -m http://gist.github.com/31208.txt </shell> Alternatively, you can use the rake task +rails:template+ to apply a template to an existing Rails application : diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index de93a87615..aad1170b56 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -38,6 +38,10 @@ when 'dbconsole' when 'application', 'runner' require "rails/commands/#{command}" +when 'new' + puts "Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.\n" + puts "Type 'rails' for help." + when '--version', '-v' ARGV.unshift '--version' require 'rails/commands/application' @@ -53,6 +57,8 @@ The most common rails commands are: server Start the Rails server (short-cut alias: "s") dbconsole Start a console for the database specified in config/database.yml (short-cut alias: "db") + new Create a new Rails application. "rails new my_app" creates a + new application called MyApp in "./my_app" In addition to those, there are: application Generate the Rails application code diff --git a/railties/lib/rails/commands/application.rb b/railties/lib/rails/commands/application.rb index 8a8143e00e..a3a5aed399 100644 --- a/railties/lib/rails/commands/application.rb +++ b/railties/lib/rails/commands/application.rb @@ -4,7 +4,12 @@ if %w(--version -v).include? ARGV.first exit(0) end -ARGV << "--help" if ARGV.empty? +if ARGV.first != "new" || ARGV.empty? + ARGV[0] = "--help" +else + ARGV.shift +end + require 'rubygems' if ARGV.include?("--dev") require 'rails/generators' diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb index 9023c61bf2..db59cd8ad9 100644 --- a/railties/lib/rails/commands/destroy.rb +++ b/railties/lib/rails/commands/destroy.rb @@ -1,4 +1,5 @@ require 'rails/generators' +Rails::Generators.configure! if [nil, "-h", "--help"].include?(ARGV.first) Rails::Generators.help 'destroy' diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index 7d05a30de8..1b3eef504a 100755 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -1,4 +1,5 @@ require 'rails/generators' +Rails::Generators.configure! if [nil, "-h", "--help"].include?(ARGV.first) Rails::Generators.help 'generate' diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index fe8a6c0b94..af92757053 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -68,6 +68,7 @@ module Rails options.deep_merge! config.options fallbacks.merge! config.fallbacks templates_path.concat config.templates + templates_path.uniq! end def self.templates_path @@ -328,10 +329,5 @@ module Rails paths.uniq! paths end - end -end - -# If the application was already defined, configure generators, -# otherwise you have to configure it by hand. -Rails::Generators.configure! if Rails.respond_to?(:application) && Rails.application +end
\ No newline at end of file diff --git a/railties/lib/rails/generators/rails/app/USAGE b/railties/lib/rails/generators/rails/app/USAGE index 36d6061a59..9e7a78d132 100644 --- a/railties/lib/rails/generators/rails/app/USAGE +++ b/railties/lib/rails/generators/rails/app/USAGE @@ -1,9 +1,9 @@ Description: - The 'rails' command creates a new Rails application with a default + The 'rails new' command creates a new Rails application with a default directory structure and configuration at the path you specify. Example: - rails ~/Code/Ruby/weblog + rails new ~/Code/Ruby/weblog This generates a skeletal Rails installation in ~/Code/Ruby/weblog. See the README in the newly created application to get going. diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index cd4a3dce4e..7d50e7da67 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -149,8 +149,7 @@ module Rails # can change in Ruby 1.8.7 when we FileUtils.cd. RAILS_DEV_PATH = File.expand_path("../../../../../..", File.dirname(__FILE__)) - RESERVED_NAMES = %w[generate g console c server s dbconsole db - application destroy benchmarker profiler + RESERVED_NAMES = %w[application destroy benchmarker profiler plugin runner test] class AppGenerator < Base @@ -310,7 +309,7 @@ module Rails protected def self.banner - "rails #{self.arguments.map(&:usage).join(' ')} [options]" + "rails new #{self.arguments.map(&:usage).join(' ')} [options]" end def builder diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index f751c4519d..0b922a89c0 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -23,6 +23,9 @@ gem '<%= gem_for_database %>'<% if require_for_database %>, :require => '<%= req # Deploy with Capistrano # gem 'capistrano' +# To use debugger +# gem 'ruby-debug' + # Bundle the extra gems: # gem 'bj' # gem 'nokogiri', '1.4.1' diff --git a/railties/test/application/initializers/frameworks_test.rb b/railties/test/application/initializers/frameworks_test.rb index fadcc4c025..35ea2729d3 100644 --- a/railties/test/application/initializers/frameworks_test.rb +++ b/railties/test/application/initializers/frameworks_test.rb @@ -47,7 +47,7 @@ module ApplicationTests test "if there's no config.active_support.bare, all of ActiveSupport is required" do use_frameworks [] require "#{app_path}/config/environment" - assert_nothing_raised { [1,2,3].random_element } + assert_nothing_raised { [1,2,3].sample } end test "config.active_support.bare does not require all of ActiveSupport" do @@ -57,7 +57,7 @@ module ApplicationTests Dir.chdir("#{app_path}/app") do require "#{app_path}/config/environment" - assert_raises(NoMethodError) { [1,2,3].random_element } + assert_raises(NoMethodError) { [1,2,3].sample } end end diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb index d8bdb344f2..4a5a9b2932 100644 --- a/railties/test/generators/generators_test_helper.rb +++ b/railties/test/generators/generators_test_helper.rb @@ -1,4 +1,6 @@ require 'abstract_unit' +require 'rails/generators' +require 'rails/generators/test_case' module Rails def self.root @@ -8,8 +10,9 @@ end Rails.application.config.root = Rails.root Rails.application.config.generators.templates = [File.join(Rails.root, "lib", "templates")] -require 'rails/generators' -require 'rails/generators/test_case' +# Call configure to load the settings from +# Rails.application.config.generators to Rails::Generators +Rails::Generators.configure! require 'active_record' require 'action_dispatch' |