We love the conveniences provided by active_support and extlib, we just don’t love them at the same time and on top of each other. active_support is slow to load, has many dependencies, and is all intertwingled. We had too many collisions between active_support 2.x and 3.x and extlib.
What gorillib gives you is clarity over what features are brought in. If you want to just get
require 'gorillib/object/blank'. No dependencies, no codependents.
- No creep: include only what you need
- No dependencies unless audaciously advertised.
- Upwards compatible with active_record and extlib
– the active_support components have significantly more robust internationalization, and some functions have rich option sets in active_support vs. basic functionality in gorillib. So the rule is if you were happy with gorillib you’ll be happy with active_support, but not vice-versa.
Gorillib has at least one powerful addition to the canon: the receiver mixin.
- gives you weak type safety but doesn’t jack around with setters/getters.
- object/hash semantics
- require ‘gorrillib/base’
requires the following libraries:
gorillib/base and the following additional libraries:
– Array extract_options!
– Hash extractable_options? (helper method)
– Array compact_blank, compact_blank!
– Array deep_compact, deep_compact!
– Date, Time to_flat
– Time parse_safely
– Enumerable sum
– Hash compact, compact!, compact_blank, compact_blank!
– Hash deep_compact, deep_compact!
– Hash deep_merge, deep_merge!
– Hash stringify_keys, stringify_keys!, symbolize_keys, symbolize_keys!
– Hash assert_valid_keys
– Hash reverse_merge, reverse_merge!
– Hash slice, slice!, extract!
– Hash Hash.zip
– Unless the top-level constant ::Log has been defined, opens a new Logger to STDERR and assigns it to ::Log
– Class class_attribute
gorillib/metaprogramming/remove_method required with class_attribute
– Module remove_possible_method, redefine_method
gorillib/metaprogramming/singleton_class required with class_attribute
– Kernel singleton_class
– Class# cattr_reader, cattr_writer, cattr_accessor
– Class# mattr_reader, mattr_writer, mattr_accessor
– Module# delegate
– Numeric clamp — coerce a number to lie within a certain min/max
– Object blank?, present? (and specialized for all other classes)
– Object try
– Object try_dup
– String constantize
– String camelize
– String snakeize
– String underscore
– String demodulize
– String titleize
– String humainze
– Array as_sentence
– String truncate
gorillib/string/escaping: DEPENDENCIES_: htmlentities, addressable/uri
– String xml_escape
– String url_escape
– String escape_regexp, unescaperegexp
– Module find_const
- String classify — this singularizes. You want camelize unless you’re in ActiveSupport
- Object tap isn’t necessary — included in 1.8.7+
- Symbol to_proc isn’t necessary — included in 1.8.7+
- Class class_inheritable_attribute — use class_attribute instead
- Object to_flat on anything but Time and Date — poorly-defined
- Object returning — deprecated in favor of #tap
Most of this code is ripped from active_support and extlib — their license
carries over. Everything else is Copyright © 2011 Infochimps. See LICENSE.txt
for further details.