aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2010-02-02 10:51:19 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2010-02-02 10:51:19 +1100
commitd1eed079e1338249aa3b2881d07029ac4e71f4ed (patch)
tree18088ca9388e1b7bd27fffea8cb41fa52b618c34 /railties/lib
parentddf2b4add33d5e54c5f5e7adacadbb50d3fa7b52 (diff)
parentb9edb0c60c11025311fb06f2e60b3354f1b6cb09 (diff)
downloadrails-d1eed079e1338249aa3b2881d07029ac4e71f4ed.tar.gz
rails-d1eed079e1338249aa3b2881d07029ac4e71f4ed.tar.bz2
rails-d1eed079e1338249aa3b2881d07029ac4e71f4ed.zip
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/generators/rails/app/app_generator.rb12
-rw-r--r--railties/lib/generators/rails/app/templates/Gemfile10
-rw-r--r--railties/lib/generators/rails/app/templates/config/boot.rb25
-rw-r--r--railties/lib/rails/application/configuration.rb6
-rw-r--r--railties/lib/rails/configuration.rb7
-rw-r--r--railties/lib/rails/generators.rb1
-rw-r--r--railties/lib/rails/generators/test_case.rb7
7 files changed, 49 insertions, 19 deletions
diff --git a/railties/lib/generators/rails/app/app_generator.rb b/railties/lib/generators/rails/app/app_generator.rb
index 2e34992b3b..918bb98db8 100644
--- a/railties/lib/generators/rails/app/app_generator.rb
+++ b/railties/lib/generators/rails/app/app_generator.rb
@@ -90,6 +90,18 @@ module Rails::Generators
template "config/boot.rb"
end
+ def gem_for_database
+ # %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
+ case options[:database]
+ when "mysql" then "mysql"
+ when "oracle" then "ruby-oci8"
+ when "postgresql" then "pg"
+ when "sqlite3" then "sqlite3-ruby"
+ when "frontbase" then "ruby-frontbase"
+ when "ibm_db" then "ibm_db"
+ end
+ end
+
def create_activerecord_files
return if options[:skip_activerecord]
template "config/databases/#{options[:database]}.yml", "config/database.yml"
diff --git a/railties/lib/generators/rails/app/templates/Gemfile b/railties/lib/generators/rails/app/templates/Gemfile
index 7b5c89c3e2..50f1a6a414 100644
--- a/railties/lib/generators/rails/app/templates/Gemfile
+++ b/railties/lib/generators/rails/app/templates/Gemfile
@@ -1,4 +1,6 @@
# Edit this Gemfile to bundle your application's dependencies.
+source :gemcutter
+
<% if !dev_or_edge? %>
gem "rails", "<%= Rails::VERSION::STRING %>"
<% end -%>
@@ -11,6 +13,14 @@ gem "rails", "<%= Rails::VERSION::STRING %>"
<%= "# " unless options.edge? %>gem "rails", :git => "git://github.com/rails/rails.git"
<%- end -%>
+<% unless options[:skip_activerecord] -%>
+<% if options[:database] == 'sqlite3' -%>
+# ActiveRecord requires a database adapter. By default,
+# Rails has selected sqlite3.
+<% end -%>
+gem "<%= gem_for_database %>"
+<% end -%>
+
## Bundle the gems you use:
# gem "bj"
# gem "hpricot", "0.6"
diff --git a/railties/lib/generators/rails/app/templates/config/boot.rb b/railties/lib/generators/rails/app/templates/config/boot.rb
index 7fc1aeaeb8..70bd40bc4c 100644
--- a/railties/lib/generators/rails/app/templates/config/boot.rb
+++ b/railties/lib/generators/rails/app/templates/config/boot.rb
@@ -1,16 +1,19 @@
# Use Bundler (preferred)
-environment = File.expand_path('../../vendor/gems/environment', __FILE__)
-if File.exist?("#{environment}.rb")
- require environment
-
-# Use 2.x style vendor/rails and RubyGems
-else
- vendor_rails = File.expand_path('../../vendor/rails', __FILE__)
- if File.exist?(vendor_rails)
- Dir["#{vendor_rails}/*/lib"].each { |path| $:.unshift(path) }
- end
-
+begin
+ require File.expand_path('../../vendor/environment', __FILE__)
+rescue LoadError
require 'rubygems'
+ require 'bundler'
+ Bundler.setup
+
+ # To use 2.x style vendor/rails and RubyGems
+ #
+ # vendor_rails = File.expand_path('../../vendor/rails', __FILE__)
+ # if File.exist?(vendor_rails)
+ # Dir["#{vendor_rails}/*/lib"].each { |path| $:.unshift(path) }
+ # end
+ #
+ # require 'rubygems'
end
<% unless options[:skip_activerecord] -%>
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 31787b5cc9..d6ad045294 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -5,7 +5,7 @@ module Rails
class Configuration < ::Rails::Engine::Configuration
include ::Rails::Configuration::Deprecated
- attr_accessor :cache_classes, :cache_store, :colorize_logging,
+ attr_accessor :allow_concurrency, :cache_classes, :cache_store, :colorize_logging,
:consider_all_requests_local, :dependency_loading,
:filter_parameters, :log_level, :logger, :metals,
:plugins, :preload_frameworks, :reload_engines, :reload_plugins,
@@ -13,11 +13,13 @@ module Rails
def initialize(*)
super
+ @allow_concurrency = false
@colorize_logging = true
@filter_parameters = []
@dependency_loading = true
@serve_static_assets = true
@time_zone = "UTC"
+ @consider_all_requests_local = true
end
def paths
@@ -50,7 +52,7 @@ module Rails
self.preload_frameworks = true
self.cache_classes = true
self.dependency_loading = false
- self.action_controller.allow_concurrency = true if respond_to?(:action_controller)
+ self.allow_concurrency = true
self
end
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb
index 6a4ebe883b..7887a5d25f 100644
--- a/railties/lib/rails/configuration.rb
+++ b/railties/lib/rails/configuration.rb
@@ -8,10 +8,10 @@ module Rails
def middleware
@@default_middleware_stack ||= ActionDispatch::MiddlewareStack.new.tap do |middleware|
middleware.use('::ActionDispatch::Static', lambda { Rails.public_path }, :if => lambda { Rails.application.config.serve_static_assets })
- middleware.use('::Rack::Lock', :if => lambda { !ActionController::Base.allow_concurrency })
+ middleware.use('::Rack::Lock', :if => lambda { !Rails.application.config.allow_concurrency })
middleware.use('::Rack::Runtime')
middleware.use('::Rails::Rack::Logger')
- middleware.use('::ActionDispatch::ShowExceptions', lambda { ActionController::Base.consider_all_requests_local })
+ middleware.use('::ActionDispatch::ShowExceptions', lambda { Rails.application.config.consider_all_requests_local })
middleware.use('::ActionDispatch::Callbacks', lambda { !Rails.application.config.cache_classes })
middleware.use('::ActionDispatch::Cookies')
middleware.use(lambda { ActionController::Base.session_store }, lambda { ActionController::Base.session_options })
@@ -88,11 +88,12 @@ module Rails
end
class Generators #:nodoc:
- attr_accessor :aliases, :options, :colorize_logging
+ attr_accessor :aliases, :options, :fallbacks, :colorize_logging
def initialize
@aliases = Hash.new { |h,k| h[k] = {} }
@options = Hash.new { |h,k| h[k] = {} }
+ @fallbacks = {}
@colorize_logging = true
end
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index 90b513fcb4..8c54014fcb 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -67,6 +67,7 @@ module Rails
no_color! unless config.colorize_logging
aliases.deep_merge! config.aliases
options.deep_merge! config.options
+ fallbacks.merge! config.fallbacks
end
def self.aliases #:nodoc:
diff --git a/railties/lib/rails/generators/test_case.rb b/railties/lib/rails/generators/test_case.rb
index 38a3cbb035..6b97c69d8d 100644
--- a/railties/lib/rails/generators/test_case.rb
+++ b/railties/lib/rails/generators/test_case.rb
@@ -1,4 +1,5 @@
-require 'active_support/core_ext/class/inheritable_attributes'
+require 'active_support/core_ext/class/attribute'
+require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/hash/reverse_merge'
require 'rails/generators'
require 'fileutils'
@@ -28,8 +29,8 @@ module Rails
class TestCase < ActiveSupport::TestCase
include FileUtils
- extlib_inheritable_accessor :destination_root, :current_path, :generator_class,
- :default_arguments, :instance_writer => false
+ class_attribute :destination_root, :current_path, :generator_class, :default_arguments
+ delegate :destination_root, :current_path, :generator_class, :default_arguments, :to => :'self.class'
# Generators frequently change the current path using +FileUtils.cd+.
# So we need to store the path at file load and revert back to it after each test.