diff options
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 65 | ||||
-rw-r--r-- | railties/lib/rails/configuration.rb | 21 | ||||
-rw-r--r-- | railties/lib/rails/deprecation.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/application.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/boot.rb | 19 | ||||
-rw-r--r-- | railties/lib/rails/plugin/locator.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/tasks/databases.rake | 2 |
7 files changed, 27 insertions, 98 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 521e1cafb6..943c939757 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -311,31 +311,6 @@ module Rails end end - initializer :check_for_unbuilt_gems do - unbuilt_gems = config.gems.select {|gem| gem.frozen? && !gem.built? } - if unbuilt_gems.size > 0 - # don't print if the gems:build rake tasks are being run - unless $gems_build_rake_task - abort <<-end_error - The following gems have native components that need to be built - #{unbuilt_gems.map { |gemm| "#{gemm.name} #{gemm.requirement}" } * "\n "} - - You're running: - ruby #{Gem.ruby_version} at #{Gem.ruby} - rubygems #{Gem::RubyGemsVersion} at #{Gem.path * ', '} - - Run `rake gems:build` to build the unbuilt gems. - end_error - end - end - end - - initializer :load_gems do - unless $gems_rake_task - config.gems.each { |gem| gem.load } - end - end - # Loads all plugins in <tt>config.plugin_paths</tt>. <tt>plugin_paths</tt> # defaults to <tt>vendor/plugins</tt> but may also be set to a list of # paths, such as @@ -356,49 +331,19 @@ module Rails plugin_loader.load_plugins end - # TODO: Figure out if this needs to run a second time - # load_gems - - initializer :check_gem_dependencies do - unloaded_gems = config.gems.reject { |g| g.loaded? } - if unloaded_gems.size > 0 - configuration.gems_dependencies_loaded = false - # don't print if the gems rake tasks are being run - unless $gems_rake_task - abort <<-end_error - Missing these required gems: - #{unloaded_gems.map { |gemm| "#{gemm.name} #{gemm.requirement}" } * "\n "} - - You're running: - ruby #{Gem.ruby_version} at #{Gem.ruby} - rubygems #{Gem::RubyGemsVersion} at #{Gem.path * ', '} - - Run `rake gems:install` to install the missing gems. - end_error - end - else - configuration.gems_dependencies_loaded = true - end - end - # # bail out if gems are missing - note that check_gem_dependencies will have # # already called abort() unless $gems_rake_task is set # return unless gems_dependencies_loaded - initializer :load_application_initializers do - if config.gems_dependencies_loaded - Dir["#{configuration.root}/config/initializers/**/*.rb"].sort.each do |initializer| - load(initializer) - end + Dir["#{configuration.root}/config/initializers/**/*.rb"].sort.each do |initializer| + load(initializer) end end # Fires the user-supplied after_initialize block (Configuration#after_initialize) initializer :after_initialize do - if config.gems_dependencies_loaded - configuration.after_initialize_blocks.each do |block| - block.call - end + configuration.after_initialize_blocks.each do |block| + block.call end end @@ -440,7 +385,7 @@ module Rails # # # Observers are loaded after plugins in case Observers or observed models are modified by plugins. initializer :load_observers do - if config.gems_dependencies_loaded && configuration.frameworks.include?(:active_record) + if configuration.frameworks.include?(:active_record) ActiveRecord::Base.instantiate_observers end end diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index ce9c899400..1a7483c548 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -4,7 +4,7 @@ require 'rails/plugin/locator' module Rails class Configuration attr_accessor :cache_classes, :load_paths, - :load_once_paths, :gems_dependencies_loaded, :after_initialize_blocks, + :load_once_paths, :after_initialize_blocks, :frameworks, :framework_root_path, :root, :plugin_paths, :plugins, :plugin_loader, :plugin_locators, :gems, :loaded_plugins, :reload_plugins, :i18n, :gems, :whiny_nils, :consider_all_requests_local, @@ -230,25 +230,6 @@ module Rails end end - # Adds a single Gem dependency to the rails application. By default, it will require - # the library with the same name as the gem. Use :lib to specify a different name. - # - # # gem 'aws-s3', '>= 0.4.0' - # # require 'aws/s3' - # config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', \ - # :source => "http://code.whytheluckystiff.net" - # - # To require a library be installed, but not attempt to load it, pass :lib => false - # - # config.gem 'qrp', :version => '0.4.1', :lib => false - def gem(name, options = {}) - gems << Rails::GemDependency.new(name, options) - end - - def gems - @gems ||= [] - end - def environment_path "#{root}/config/environments/#{RAILS_ENV}.rb" end diff --git a/railties/lib/rails/deprecation.rb b/railties/lib/rails/deprecation.rb index 42bba151d6..3c5b8bdec7 100644 --- a/railties/lib/rails/deprecation.rb +++ b/railties/lib/rails/deprecation.rb @@ -14,4 +14,12 @@ RAILS_ROOT = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do msg = "RAILS_ROOT is deprecated! Use Rails.root instead." ActiveSupport::Deprecation.warn(msg, callstack) end -end).new
\ No newline at end of file +end).new + +module Rails + class Configuration + def gem(*args) + ActiveSupport::Deprecation.warn("config.gem has been deprecated in favor of the Gemfile.") + end + end +end
\ No newline at end of file diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index 7ba7c52f9e..bb30136686 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -8,12 +8,6 @@ Rails::Initializer.run do |config| # Add additional load paths for your own custom dirs # config.load_paths += %W( #{root}/extras ) - # Specify gems that this application depends on and have them installed with rake gems:install - # config.gem "bj" - # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" - # config.gem "sqlite3-ruby", :lib => "sqlite3" - # config.gem "aws-s3", :lib => "aws/s3" - # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named # config.plugins = [ :exception_notification, :ssl_requirement, :all ] diff --git a/railties/lib/rails/generators/rails/app/templates/config/boot.rb b/railties/lib/rails/generators/rails/app/templates/config/boot.rb index 3165a4091e..5aa49ca5e6 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/boot.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/boot.rb @@ -1,15 +1,16 @@ -# Package management -# Choose one - # Use Bundler (preferred) environment = File.expand_path('../../vendor/gems/environment', __FILE__) -require environment if File.exist?(environment) +if File.exist?("#{environment}.rb") + require environment -# Use 2.x style vendor/rails directory -vendor_rails = File.expand_path('../../vendor/rails', __FILE__) -Dir["#{vendor_rails}/*/lib"].each { |path| $:.unshift(path) } if File.exist?(vendor_rails) +# 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 -# Load Rails from traditional RubyGems -require 'rubygems' + require 'rubygems' +end require 'rails' diff --git a/railties/lib/rails/plugin/locator.rb b/railties/lib/rails/plugin/locator.rb index 1057c004e0..56cbaf37c6 100644 --- a/railties/lib/rails/plugin/locator.rb +++ b/railties/lib/rails/plugin/locator.rb @@ -78,7 +78,7 @@ module Rails # a <tt>rails/init.rb</tt> file. class GemLocator < Locator def plugins - gem_index = initializer.configuration.gems.inject({}) { |memo, gem| memo.update gem.specification => gem } + gem_index = {} specs = gem_index.keys specs += Gem.loaded_specs.values.select do |spec| spec.loaded_from && # prune stubs diff --git a/railties/lib/rails/tasks/databases.rake b/railties/lib/rails/tasks/databases.rake index 70b59625f8..a35a6c156b 100644 --- a/railties/lib/rails/tasks/databases.rake +++ b/railties/lib/rails/tasks/databases.rake @@ -295,7 +295,7 @@ namespace :db do if File.exists?(file) load(file) else - abort %{#{file} doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter #{Rails.root}/config/environment.rb to prevent active_record from loading: config.frameworks -= [ :active_record ]} + abort %{#{file} doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter #{Rails.root}/config/application.rb to prevent active_record from loading: config.frameworks -= [ :active_record ]} end end end |