aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorMichael S. Klishin <michael@novemberain.com>2008-12-28 11:26:57 +0300
committerMichael S. Klishin <michael@novemberain.com>2008-12-28 11:26:57 +0300
commit133925804f24d716a3836698dbe5a7d8b30de0b5 (patch)
tree6bda3a3dd217199af29a684933325ab6a2473ddd /activesupport
parent9fd35fc2d892393386ca9f522d25ba0bcb9c6764 (diff)
downloadrails-133925804f24d716a3836698dbe5a7d8b30de0b5.tar.gz
rails-133925804f24d716a3836698dbe5a7d8b30de0b5.tar.bz2
rails-133925804f24d716a3836698dbe5a7d8b30de0b5.zip
Introduce minimalistic package for ActiveSupport.
To simplify using of ActiveSupport in 3rd party libraries, a simple way to require only minimum of commonly used extensions (multibyte, inflections, array and hash extensions, #blank?, and a few others) is needed. For exactly this reason some out-of-Rails-space libraries adopted Extlib, originally from DataMapper. To keep it 2067% backwards compatible, and still available to everyone even in 2.x releases, active_support/minimalistic.rb was added. Use it like this: gem 'active_support', '>=2.3' require 'active_support/minimalistic' instead of require 'activesupport' Right now this package with RubyGems uses about 10 megs of RAM (10.01 or so). It can be further slimmed down though, once we simplify multibyte implementation that right now uses advanced accessors from Module extensions. To compare RAM usage with previous ActiveSupport versions and Extlib, at the time of writing, see http://gist.github.com/40401.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/string/multibyte.rb6
-rw-r--r--activesupport/lib/active_support/minimalistic.rb15
2 files changed, 20 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/multibyte.rb b/activesupport/lib/active_support/core_ext/string/multibyte.rb
index a4caa83b74..8f8f0968fd 100644
--- a/activesupport/lib/active_support/core_ext/string/multibyte.rb
+++ b/activesupport/lib/active_support/core_ext/string/multibyte.rb
@@ -55,7 +55,11 @@ module ActiveSupport #:nodoc:
unless '1.8.7 and later'.respond_to?(:chars)
def chars
- ActiveSupport::Deprecation.warn('String#chars has been deprecated in favor of String#mb_chars.', caller)
+ # FIXME:
+ # ActiveSupport::Deprecation refers to RAILS_ENV
+ # and is a show stopper for 3rd party applications
+ # that only want ActiveSupport
+ ActiveSupport::Deprecation.warn('String#chars has been deprecated in favor of String#mb_chars.', caller) if defined?(ActiveSupport::Deprecation)
mb_chars
end
end
diff --git a/activesupport/lib/active_support/minimalistic.rb b/activesupport/lib/active_support/minimalistic.rb
new file mode 100644
index 0000000000..ecb5de9eaa
--- /dev/null
+++ b/activesupport/lib/active_support/minimalistic.rb
@@ -0,0 +1,15 @@
+$LOAD_PATH.unshift File.dirname(__FILE__)
+
+require "core_ext/blank"
+# whole object.rb pulls up rare used introspection extensions
+require "core_ext/object/metaclass"
+require 'core_ext/array'
+require 'core_ext/hash'
+require 'core_ext/module/attribute_accessors'
+require 'multibyte'
+require 'core_ext/string/multibyte'
+require 'core_ext/string/inflections'
+
+class String
+ include ActiveSupport::CoreExtensions::String::Multibyte
+end