Remove 'core' fluff. Hookable ActiveSupport.load_all!

This commit is contained in:
Jeremy Kemper 2009-05-20 17:11:41 -07:00
parent 3694227f24
commit 5f222c524e
19 changed files with 41 additions and 43 deletions

View File

@ -1,6 +1,7 @@
require 'yaml'
require 'set'
require 'active_support/dependencies'
require 'active_support/time'
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext/class/delegating_attributes'
require 'active_support/core_ext/class/inheritable_attributes'
@ -10,7 +11,6 @@ require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/string/behavior'
require 'active_support/core_ext/symbol'
require 'active_support/core/time'
module ActiveRecord #:nodoc:
# Generic Active Record exception class.

View File

@ -22,8 +22,15 @@
#++
module ActiveSupport
def self.load_all!
[Dependencies, Deprecation, Gzip, MessageVerifier, Multibyte, SecureRandom] + Core.load_all!
class << self
attr_accessor :load_all_hooks
def on_load_all(&hook) load_all_hooks << hook end
def load_all!; load_all_hooks.each { |hook| hook.call } end
end
self.load_all_hooks = []
on_load_all do
[Dependencies, Deprecation, Gzip, MessageVerifier, Multibyte, SecureRandom]
end
autoload :BacktraceCleaner, 'active_support/backtrace_cleaner'

View File

@ -0,0 +1,3 @@
require 'active_support'
require 'active_support/time'
require 'active_support/core_ext'

View File

@ -1,7 +0,0 @@
module ActiveSupport
module Core
def self.load_all!
[TimeWithZone]
end
end
end

View File

@ -1,5 +0,0 @@
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')}"
end

View File

@ -1,4 +0,0 @@
require 'active_support/core/time/autoload'
require 'active_support/core_ext/time'
require 'active_support/core_ext/date'
require 'active_support/core_ext/date_time'

View File

@ -1,8 +1,7 @@
require 'date'
require 'active_support/time'
require 'active_support/core_ext/object/conversions'
require 'active_support/core_ext/array/conversions'
require 'active_support/core_ext/hash/reverse_merge'
require 'active_support/core/time'
class Hash
# This module exists to decorate files deserialized using Hash.from_xml with

View File

@ -0,0 +1,14 @@
require 'active_support'
require 'active_support/core_ext/time'
require 'active_support/core_ext/date'
require 'active_support/core_ext/date_time'
module ActiveSupport
autoload :Duration, 'active_support/duration'
autoload :TimeWithZone, 'active_support/time_with_zone'
autoload :TimeZone, 'active_support/values/time_zone'
on_load_all do
[Duration, TimeWithZone, TimeZone]
end
end

View File

@ -1,5 +1,5 @@
require 'abstract_unit'
require 'active_support/core/time'
require 'active_support/time'
class DurationTest < ActiveSupport::TestCase
def test_inspect

View File

@ -1,7 +1,7 @@
require 'abstract_unit'
require 'active_support/time'
require 'active_support/core_ext/numeric'
require 'active_support/core_ext/integer'
require 'active_support/core/time'
class NumericExtTimeAndDateTimeTest < Test::Unit::TestCase
def setup

View File

@ -1,7 +1,7 @@
require 'abstract_unit'
require 'active_support/time'
require 'active_support/core_ext/object'
require 'active_support/core_ext/class/removal'
require 'active_support/core/time'
class ClassA; end
class ClassB < ClassA; end

View File

@ -1,5 +1,5 @@
require 'abstract_unit'
require 'active_support/core/time'
require 'active_support/time'
class TimeExtCalculationsTest < Test::Unit::TestCase
def test_seconds_since_midnight

View File

@ -1,5 +1,5 @@
require 'abstract_unit'
require 'active_support/core/time'
require 'active_support/time'
require 'active_support/core_ext/array/conversions'
class I18nTest < Test::Unit::TestCase

View File

@ -1,5 +1,5 @@
require 'abstract_unit'
require 'active_support/core/time'
require 'active_support/time'
class TimeZoneTest < Test::Unit::TestCase
def test_utc_to_local

View File

@ -1,5 +1,4 @@
require 'active_support'
require 'active_support/core/all'
require 'active_support/all'
require 'active_support/test_case'
require 'action_controller'

View File

@ -263,9 +263,8 @@ module Rails
# list. By default, all frameworks (Active Record, Active Support,
# Action Pack, Action Mailer, and Active Resource) are loaded.
def require_frameworks
require 'active_support'
require 'active_support/all'
configuration.frameworks.each { |framework| require(framework.to_s) }
require 'active_support/core/all'
rescue LoadError => e
# Re-raise as RuntimeError because Mongrel would swallow LoadError.
raise e.to_s

View File

@ -21,16 +21,9 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
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
require 'active_support/core/all'
activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
$:.unshift(activesupport_path) if File.directory?(activesupport_path)
require 'active_support/all'
$:.unshift(File.dirname(__FILE__))
require 'rails_generator/base'

View File

@ -31,7 +31,7 @@ namespace :time do
desc 'Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time'
task :local do
require 'active_support'
require 'active_support/core/time'
require 'active_support/time'
jan_offset = Time.now.beginning_of_year.utc_offset
jul_offset = Time.now.beginning_of_year.change(:month => 7).utc_offset
offset = jan_offset < jul_offset ? jan_offset : jul_offset
@ -41,7 +41,7 @@ namespace :time do
# to find UTC -06:00 zones, OFFSET can be set to either -6, -6:00 or 21600
def build_time_zone_list(method, offset = ENV['OFFSET'])
require 'active_support'
require 'active_support/core/time'
require 'active_support/time'
if offset
offset = if offset.to_s.match(/(\+|-)?(\d+):(\d+)/)
sign = $1 == '-' ? -1 : 1