= Backports Library Essential backports that make it possible to use some of the really nice features of Ruby 1.8.7, Ruby 1.9 and rails from Ruby 1.8.x Conditions for inclusion: 1. Standard in either Ruby or Rails 2. Won't break older code 3. Simple and self-contained The first and second rules avoids conflicts in future and the past respectively. Because of the second rule, incompatibilities between 1.8 and 1.9 methods are left alone. For example, <tt>Module::instance_methods</tt> returns strings in 1.8 and symbols in 1.9; no change can be made without the risk of breaking existing code. More complex features of active-support (even things like <tt>String::pluralize</tt>), won't be included. <tt>require 'activesupport'</tt> if you need them and are not in rails! I've added these backports as I need them; pull requests welcome (with tests for Ruby 1.9 backports) == Installation & compatibility +backports+ is mirrored on Rubyforge and can thus be installed with: sudo gem install backports To use: require 'rubygems' require 'backports' # and off you go! Compatible with Ruby 1.8 & 1.9. = List of backports == Ruby 1.8.7 Complete Ruby 1.8.7 backporting. Refer to the official list of changes[http://svn.ruby-lang.org/repos/ruby/tags/v1_8_7/NEWS]. All builtin classes are compatible with Ruby 1.8.7: * Array * Binding * Dir * Enumerable * Enumerator * Fixnum * Hash * Integer * IO (& ARGF) * Method * Numeric * Object * ObjectSpace * Range * Regexp * Symbol * UnboundMethod Only exceptions: * String#gsub * GC.stress= * Process.exec * recursive data handling (Array and Hash) As in Ruby 1.8.7+, there is no need to <tt>require 'enumerator'</tt> in older Ruby, and +Enumerator+ can be accessed directly (instead of <tt>Enumerable::Enumerator</tt>) == Ruby 1.9 Additionally, the following Ruby 1.9 have been backported: * Array * +sample+ * Enumerable * +each_with_object+ * +reverse_each+ * Enumerator * +new+ (with block) * Hash * <tt>Hash[[[:foo, :bar],[:hello, "world"]]] ==> {:foo => :bar, :hello => "world"}</tt> (see _note_) * <tt>default_proc=</tt> * Kernel * +require_relative+ * Object * +define_singleton_method+ * Proc * +yield+ * String * +try_convert+ * <tt>ascii_only?</tt> * +chr+ * +clear+ * +codepoints+, +each_codepoint+ _note_: This usage of <tt>Hash::[]</tt> is not yet documented[http://redmine.ruby-lang.org/issues/show/1385]. == Rails Some generic methods from Rails methods have been copied: * Enumerable * +sum+ * Hash * +symbolize_keys+, <tt>symbolize_keys!</tt> * +reverse_merge+, <tt>reverse_merge!</tt> * Module * +alias_method_chain+ * Object * +try+ * +returning+ * String * +camelize+, +underscore+ * +dasherize+, +demodulize+ * +constantize+ = License +backports+ is released under the terms of the MIT License, see the included LICENSE file. Author:: Marc-André Lafortune