Permalink
Browse files

No more free lunch

  • Loading branch information...
1 parent 42a06d2 commit ab321268f86d9013cbd4ecd0b5f46e7b05ec55a9 @jeremy jeremy committed Apr 22, 2009
View
1 actionpack/lib/action_controller.rb
@@ -30,6 +30,7 @@
require 'active_support'
end
end
+require 'active_support/core/all'
require File.join(File.dirname(__FILE__), "action_pack")
View
1 actionpack/lib/action_dispatch.rb
@@ -30,6 +30,7 @@
require 'active_support'
end
end
+require 'active_support/core/all'
$:.unshift "#{File.dirname(__FILE__)}/action_dispatch/vendor/rack-1.0"
begin
View
1 actionpack/lib/action_view.rb
@@ -30,6 +30,7 @@
require 'active_support'
end
end
+require 'active_support/core/all'
require File.join(File.dirname(__FILE__), "action_pack")
View
15 activemodel/lib/active_model/core.rb
@@ -1,7 +1,12 @@
-# This file is required by each major ActiveModel component for the core requirements. This allows you to
-# load individual pieces of ActiveModel as needed.
-$LOAD_PATH << File.join(File.dirname(__FILE__), '..', '..', '..', 'activesupport', 'lib')
+begin
+ require 'active_support'
+rescue LoadError
+ activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
+ if File.directory?(activesupport_path)
+ $:.unshift activesupport_path
+ require 'active_support'
+ end
+end
-# premature optimization?
# So far, we only need the string inflections and not the rest of ActiveSupport.
-require 'active_support/inflector'
+require 'active_support/inflector'
View
1 activerecord/lib/active_record.rb
@@ -30,6 +30,7 @@
require 'active_support'
end
end
+require 'active_support/core/all'
module ActiveRecord
# TODO: Review explicit loads to see if they will automatically be handled by the initilizer.
View
1 activeresource/lib/active_resource.rb
@@ -30,6 +30,7 @@
require 'active_support'
end
end
+require 'active_support/core/all'
require 'active_resource/formats'
require 'active_resource/base'
View
2 activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*Edge*
+* require 'active_support' no longer orders the whole menu of core extensions. Ask for just what you need: e.g. require 'active_support/core/time' to use timezones, durations, and stdlib date/time extensions. [Jeremy Kemper]
+
* Removed rarely-used DRb cache store. [Jeremy Kemper]
* TimeWithZone.name returns 'Time', to further thwart type checking [Geoff Buesing]
View
3 activesupport/lib/active_support.rb
@@ -50,10 +50,7 @@ def self.load_all!
autoload :XmlMini, 'active_support/xml_mini'
end
-require 'active_support/core/all'
-
require 'active_support/vendor'
-require 'active_support/core_ext'
require 'active_support/dependencies'
require 'active_support/json'
View
1 activesupport/lib/active_support/core/all.rb
@@ -1,3 +1,4 @@
+require 'active_support/core_ext'
require 'active_support/core'
Dir["#{File.dirname(__FILE__)}/*.rb"].sort.each do |path|
require "active_support/core/#{File.basename(path, '.rb')}"
View
4 activesupport/lib/active_support/core_ext/kernel/requires.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/kernel/reporting'
+
module Kernel
# Require a library with fallback to RubyGems. Warnings during library
# loading are silenced to increase signal/noise for application warnings.
@@ -21,4 +23,4 @@ def require_library_or_gem(library_name)
end
end
end
-end
+end
View
4 railties/Rakefile
@@ -29,12 +29,12 @@ task :default => :test
task :test do
Dir['test/**/*_test.rb'].all? do |file|
ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
- system(ruby, '-Itest', file)
+ system(ruby, '-Itest', "-I#{File.dirname(__FILE__)}/../activesupport/lib", file)
end or raise "Failures"
end
Rake::TestTask.new("regular_test") do |t|
- t.libs << 'test'
+ t.libs << 'test' << "#{File.dirname(__FILE__)}/../activesupport/lib"
t.pattern = 'test/**/*_test.rb'
t.warning = true
t.verbose = true
View
10 railties/lib/rails/plugin.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/kernel/reporting'
+
module Rails
# The Plugin class should be an object which provides the following methods:
#
@@ -35,10 +37,10 @@ def valid?
def load_paths
report_nonexistant_or_empty_plugin! unless valid?
- returning [] do |load_paths|
- load_paths << lib_path if has_lib_directory?
- load_paths << app_paths if has_app_directory?
- end.flatten
+ load_paths = []
+ load_paths << lib_path if has_lib_directory?
+ load_paths << app_paths if has_app_directory?
+ load_paths.flatten
end
# Evaluates a plugin's init.rb file.
View
1 railties/lib/rails/rack/metal.rb
@@ -1,4 +1,5 @@
require 'active_support/ordered_hash'
+require 'active_support/core_ext/class/attribute_accessors'
module Rails
module Rack
View
14 railties/lib/rails_generator.rb
@@ -21,16 +21,18 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
-$:.unshift(File.dirname(__FILE__))
-$:.unshift(File.dirname(__FILE__) + "/../../activesupport/lib")
-
begin
- require 'active_support'
+ require 'active_support'
rescue LoadError
- require 'rubygems'
- gem 'activesupport'
+ activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
+ if File.directory?(activesupport_path)
+ $:.unshift activesupport_path
+ require 'active_support'
+ end
end
+require 'active_support/core/all'
+$:.unshift(File.dirname(__FILE__))
require 'rails_generator/base'
require 'rails_generator/lookup'
require 'rails_generator/commands'

9 comments on commit ab32126

@mislav
Ruby on Rails member

yeah baby!!

@greatseth

nice

@Aupajo

I felt a great disturbance in the Rails, as if millions of core extensions suddenly cried out in terror and were suddenly put to better use.

@norbert

Love where this is going.

@advany

You rule! :)

@darrylring

So, are core extensions being moved into active_support/core and then explicitly loaded?

@darrylring

Duh, the CHANGELOG pretty much says so. Is the goal, though, to get everything from active_support/core_ext into active_support/core?

@NZKoz
Ruby on Rails member

things will move around a lot between now and a final release so I wouldn't worry too much about the naming just yet.

By default new and existing rails apps won't have to do anything different to get all the extensions, however you will be able to explicitly opt-out if you want to.

@darrylring
config.core_ext :all
config.core_ext [:date, :string]
config.core_ext :all, :except => [:date]
Please sign in to comment.