Skip to content
This repository
Browse code

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.
  • Loading branch information...
commit 133925804f24d716a3836698dbe5a7d8b30de0b5 1 parent 9fd35fc
Michael Klishin authored December 28, 2008
6  activesupport/lib/active_support/core_ext/string/multibyte.rb
@@ -55,7 +55,11 @@ def is_utf8?
55 55
 
56 56
           unless '1.8.7 and later'.respond_to?(:chars)
57 57
             def chars
58  
-              ActiveSupport::Deprecation.warn('String#chars has been deprecated in favor of String#mb_chars.', caller)
  58
+              # FIXME:
  59
+              # ActiveSupport::Deprecation refers to RAILS_ENV
  60
+              # and is a show stopper for 3rd party applications
  61
+              # that only want ActiveSupport
  62
+              ActiveSupport::Deprecation.warn('String#chars has been deprecated in favor of String#mb_chars.', caller) if defined?(ActiveSupport::Deprecation)
59 63
               mb_chars
60 64
             end
61 65
           end
15  activesupport/lib/active_support/minimalistic.rb
... ...
@@ -0,0 +1,15 @@
  1
+$LOAD_PATH.unshift File.dirname(__FILE__)
  2
+
  3
+require "core_ext/blank"
  4
+# whole object.rb pulls up rare used introspection extensions
  5
+require "core_ext/object/metaclass"
  6
+require 'core_ext/array'
  7
+require 'core_ext/hash'
  8
+require 'core_ext/module/attribute_accessors'
  9
+require 'multibyte'
  10
+require 'core_ext/string/multibyte'
  11
+require 'core_ext/string/inflections'
  12
+
  13
+class String
  14
+  include ActiveSupport::CoreExtensions::String::Multibyte
  15
+end

0 notes on commit 1339258

Please sign in to comment.
Something went wrong with that request. Please try again.