Skip to content
Gorillib: infochimps lightweight subset of ruby convenience methods
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
fiddle
lib
spec
test
.document
.gitignore
.rspec
LICENSE.textile
README.textile
Rakefile
VERSION
gorillib.gemspec

README.textile

Gorillib: infochimps’ lightweight subset of ruby convenience methods

  • No creep: include only what you need
  • No dependencies unless audaciously advertised.
  • Compatibile with active_record and extlib
  • NO COMMITS UNLESS JACOB SAYS OK

require ‘gorillib’

  • require ‘gorrillib/base’

require ‘gorillib/base’

requires the following libraries:

  • gorillib/object/blank
  • gorillib/array/extract_options
  • gorillib/hash/reverse_merge
  • gorillib/hash/compact
  • gorillib/array/compact

require ‘gorillib/some’

requires gorillib/base and the following additional libraries:

  • set
  • time
  • date
  • gorillib/enumerable/sum
  • gorillib/datetime/flat
  • gorillib/datetime/parse_safely
  • gorillib/hash/zip
  • gorillib/hash/slice
  • gorillib/hash/keys
  • gorillib/metaprogramming/singleton_class
  • gorillib/metaprogramming/remove_method
  • gorillib/metaprogramming/class_attribute
  • gorillib/metaprogramming/cattr_accessor

gorillib/array

  • gorrillib/array/extract_options
    – Array extract_options!
    – Hash extractable_options? (helper method)
  • gorrillib/array/compact_blank
    – Array compact_blank, compact_blank!

gorillib/datetime

  • gorillib/datetime/flat
    – Date, Time to_flat
  • gorillib/datetime/parse
    – Date, Time parse_safely

gorillib/enumerable

  • gorillib/enumerable/sum
    – Enumerable sum

gorillib/hash

  • gorillib/hash/compact
    – Hash compact, compact!, compact_blank, compact_blank!
  • gorrilib/hash/deep_merge
    – Hash deep_merge, deep_merge!
  • gorillib/hash/keys
    – Hash stringify_keys, stringify_keys!, symbolize_keys, symbolize_keys!
    – Hash assert_valid_keys
  • gorillib/hash/reverse_merge
    – Hash reverse_merge, reverse_merge!
  • gorillib/hash/slice
    – Hash slice, slice!, extract!
  • gorillib/hash/zip
    – Hash Hash.zip

gorillib/logger

  • gorillib/logger/log
    – Unless the top-level constant ::Log has been defined, opens a new Logger to STDERR and assigns it to ::Log

gorillib/metaprogramming

  • gorillib/metaprogramming/aliasing
    – alias_method_chain
  • gorillib/metaprogramming/class_attribute
    – 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
  • gorillib/metaprogramming/cattr_accessor
    – Class# cattr_reader, cattr_writer, cattr_accessor
  • gorillib/metaprogramming/mattr_accessor
    – Class# mattr_reader, mattr_writer, mattr_accessor
  • gorillib/metaprogramming/delegation
    – Module# delegate

gorillib/object

  • gorillib/object/blank
    – Object blank?, present? (and specialized for all other classes)

gorillib/string

  • gorillib/string/constantize
    – String constantize
  • gorillib/string/inflections:
    – String camelize
    – String snakeize
    – String underscore
    – String demodulize
  • gorillib/string/human
    – String titleize
    – String humainze
    – Array as_sentence
  • gorillib/string/truncate
    – String truncate

Maybe and No

Maybe

  • Mash
  • Receiver
  • Struct
  • gorillib/string/escaping: DEPENDENCIES_: htmlentities, addressable/uri
    – String xml_escape
    – String url_escape
    – String escape_regexp, unescape
    regexp
  • extlib/module/find_const
    – Module find_const

No

  • 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

Credits & Copyright

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.

Something went wrong with that request. Please try again.