Skip to content
Browse files

v3.1.0: Backports can be required individually.

  • Loading branch information...
1 parent 7011553 commit d3cbc3aead6efe7c27c071f944454c85fc873c47 @marcandre committed Mar 5, 2013
Showing with 42 additions and 9 deletions.
  1. +6 −0 CHANGELOG.rdoc
  2. +35 −8 README.rdoc
  3. +1 −1 lib/backports/version.rb
View
6 CHANGELOG.rdoc
@@ -1,5 +1,11 @@
= Backports --- History
+== Version 3.1.0 - March 5th, 2013
+
+* Backports can now be loaded separately!
+
+* Small tweaks and fixes for many methods to pass more RubySpecs
+
== Version 3.0.0 - February 24th, 2013
* Features of 2.0.0 are now required when requiring 'backports'.
View
43 README.rdoc
@@ -6,7 +6,16 @@
This gem is for you!
-The goal of 'backports' is to make it easier to write ruby code that runs across different versions of Ruby. All you need to bring any version of Ruby up to today's standards:
+The goal of 'backports' is to make it easier to write ruby code that runs across different versions of Ruby.
+
+For example, if you want to use flat_map, even in Ruby implementations that don't include it, as well as the new bsearch method:
+
+ require 'backports/1.9.2/enumerable/flat_map'
+ require 'backports/2.0.0/array/bsearch'
+
+This will enable Enumerable#flat_map and Array#bsearch, using the native versions if available or otherwise provide a pure Ruby version.
+
+You can load many backports at once. For example, any version of Ruby up to today's standards:
require 'backports'
@@ -16,7 +25,7 @@ This will bring in all the features of 1.8.7 and many features of Ruby 1.9.x and
== What's inside
-Features in this gem:
+Goals for backported features:
1. Won't break older code
2. Pure Ruby (no C extensions)
3. Pass RubySpec[http://github.com/rubyspec/rubyspec]
@@ -38,15 +47,31 @@ Some generic and self-contained features of active-support are also included. By
To use:
require 'rubygems'
- require 'backports' # or a subset, see next section
+ # For only specific backports:
+ require 'backports/1.9.1/kernel/require_relative'
+ require 'backports/2.0.0/enumerable/lazy'
+
+ # For all backports up to a given version
+ require 'backports/1.9.2' # All backports for Ruby 1.9.2 and below
+
+ # Or for all backports
+ require 'backports'
+
+Note: about a dozen of backports have a dependency that will be also loaded. For example, the backport of Enumerable#flat_map uses flatten(1), so if required from Ruby 1.8.6 (where Array#flatten does not accept an argument), the backport for Ruby's 1.8.7 flatten with an argument will also be loaded.
+
+With bundler, add to your Gemfile:
+
+ gem 'backports', :load => false
+
+Run <tt>bundle install</tt> and require the desired backports.
Compatible with Ruby 1.8.6, 1.8.7, 1.9.1, 1.9.2, 1.9.3, JRuby and Rubinius.
= Complete List of backports
== Ruby 1.8.7
-Complete Ruby 1.8.7 backporting (core language). Refer to the official list of changes[https://github.com/ruby/ruby/blob/ruby_1_8_7/NEWS].
+Complete Ruby 1.8.7 backporting (core language). Refer to the official list of changes[https://github.com/ruby/ruby/blob/ruby_1_8_7/NEWS]. That's about 130 backports!
Only exceptions:
* String#gsub (the form returning an enumerator)
@@ -276,7 +301,6 @@ Some backports would create incompatibilities in their current Ruby version but
These must be imported in addition to the backports gem, for example:
- require "backports"
require "backports/force/hash_select"
{}.select{} # => {}, even in Ruby 1.8
@@ -288,11 +312,14 @@ Thanks for the bug reports and patches, in particular the repeat offenders:
* Konstantin Haase ( rkh[https://github.com/rkh])
* Roger Pack ( rdp[http://github.com/rdp] )
-The best way to submit a patch is to also submit a patch to RubySpec[https://github.com/rubyspec/rubyspec] and then a patch to backports that make it pass the spec. To test rubyspec along with backports, one way to test this is:
+The best way to submit a patch is to also submit a patch to RubySpec[https://github.com/rubyspec/rubyspec] and then a patch to backports that make it pass the spec. To test rubyspec:
- mspec path/to/specs -t path/to/ruby186 --unguarded -r path/to/backports
+ git submodule init && git submodule update # => pulls rubyspecs
+ rake spec[array/bsearch] # => tests Array#bsearch
+ rake spec[array/*] # => tests all backported Array methods
+ rake spec (or rake spec[*/*]) # => all rubyspecs for backported methods
-You must then check manually for which failures are acceptable and which are not.
+Failures that are acceptable are added the to `tags` file.
= License
View
2 lib/backports/version.rb
@@ -1,3 +1,3 @@
module Backports
- VERSION = "3.0.3" unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
+ VERSION = "3.1.0" unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
end

0 comments on commit d3cbc3a

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