Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
The latest features of Ruby backported to older versions.
Ruby

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.document
.gitignore
CHANGELOG.rdoc
LICENSE
README.rdoc
Rakefile
VERSION.yml
backports.gemspec

README.rdoc

Backports Library

Would you like to use features of Ruby 1.8.7 without the need of having 1.8.7 installed? Simply

require 'backports/1.8.7'

All 1.8.7 features are now available! Some of the features of 1.9 are also available with

require 'backports/1.9'

Finally, some features of rails' active-support are also available with

require 'backports/rails'

If you want them all:

require 'backports'

What's inside

All features of 1.8.7 are backported (well, almost all, see the exception list bellow).

Conditions for inclusion of ruby 1.9 and activesupport features:

  1. Won't break older code

  2. Simple and self-contained

For example, Module::instance_methods returns strings in 1.8 and symbols in 1.9; no change can be made without the risk of breaking existing code. Such incompatibilities between 1.8 and 1.9 methods are left unchanged.

More complex features of active-support (even things like String::pluralize), won't be included. require 'activesupport' if you need them and are not in rails!

Installation & compatibility

backports is mirrored on Rubyforge and can thus be installed with:

sudo gem install backports

To use:

require 'rubygems'
require 'backports'   # or a subset like "backports/1.8.7"
# and off you go!

Compatible with Ruby 1.8 & 1.9, jruby and rubinius.

Complete List of backports

Ruby 1.8.7

Complete Ruby 1.8.7 backporting. Refer to the official list of changes.

Only exceptions:

  • String#gsub

  • GC.stress=

  • Process.exec

  • Array#choice (use Array#sample instead)

  • recursive data handling (Array and Hash)

Ruby 1.9

Additionally, the following Ruby 1.9 have been backported:

  • Array

    • try_convert

  • Enumerable

    • each_with_object

  • Enumerator

    • new (with block)

  • Hash

    • try_convert

    • default_proc=

  • Kernel

    • require_relative

  • Object

    • define_singleton_method

  • Proc

    • yield

  • String

    • try_convert

    • ascii_only?

    • chr

    • clear

    • codepoints, each_codepoint

Enumerator can be accessed directly (instead of Enumerable::Enumerator)

Rails

Some generic methods from Rails methods have been copied:

  • Enumerable

    • sum

  • Hash

    • symbolize_keys, symbolize_keys!

    • reverse_merge, reverse_merge!

  • 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

Something went wrong with that request. Please try again.