Commit 392cb515 authored by Jérémy Bobbio's avatar Jérémy Bobbio

Imported Upstream version 3.1.1

parents
lib/**/*.rb
bin/*
features/**/*.feature
-
README.rdoc
LICENSE.txt
*.sw?
*.rbc
.DS_Store
coverage
rdoc
pkg
assets
rs
[submodule "rubyspec"]
path = rubyspec
url = git://github.com/rubyspec/rubyspec.git
$:.unshift "./lib"
---
language: ruby
rvm:
- "1.8.7"
- "1.9.2"
- "1.9.3"
- "2.0.0"
- jruby-18mode
- jruby-19mode
- rbx-18mode
- rbx-19mode
matrix:
allow_failures:
- rvm: "2.0.0" # Must wait for 2.0.0p0...
- rvm: jruby-18mode
- rvm: jruby-19mode
- rvm: rbx-18mode
- rvm: rbx-19mode
before_install:
- git submodule update --init --recursive
= 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'.
* Additional features of 2.0.0
* Struct#to_h, NilClass#to_h, Hash#to_h
* Hash#default_proc = nil
* OpenStruct lib
* 1.8.7's Enumerator#with_index (it wasn't in the 1.8.7 NEWS file...)
== Version 2.8.0 - February 3rd, 2013
* Added some features of 2.0.0 (must be required explicitly until official release):
* Array#bsearch
* Range#bsearch
== Version 2.7.0 - January 14th, 2013
* Added some features of 2.0.0 (must be required explicitly until official release):
* Enumerable#lazy
* Enumerator::Lazy
== Version 2.6.0 - May 29th, 2012
* Removed Enumerable#join
== Version 2.5.0 - March 25th, 2012
* Added some features of 1.9.3:
* IO::NULL
* IO#advise
* String#byteslice
* String#prepend
== Version 2.4.0 - March 24th, 2012
* Add backporting for libraries
* Bring libraries up to date:
* Matrix
* Prime
* Set
* Added some features of 1.9.3:
* IO.write, IO.binwrite
* Add forcing backports (must be required explicitly):
* Hash#select (returns a Hash instead of an Array)
* Enumerable / Array#map (returns an enumerator when called without a block)
* String#length, size (for UTF-8 support)
== Version 2.3.0 - May 13th, 2011
* Added Enumerator::Yielder#<<
== Version 2.2.0 - May 13th, 2011
* Ruby 1.8.8 was officially cancelled; code was moved to Ruby 1.9.1 and README updated.
* <tt>"".ord</tt> now raises an error.
== Version 2.1.0 - April 16th, 2011
* Proc#curry, #lambda (thanks Konstantine Haase)
== Version 2.0.0 - December 5th, 2010
Change of major version because of two small changes that are not quite compatible and because the minor version was getting quite high!
* Remove attempt at faking the new method missing. Unless you used `respond_to_missing` *and* `method(:some_method_handled_with_method_missing)`, you won't see a difference, except better performance (see issue #32) and this fixes some errors (see issue #34)
* Change behavior of array.flatten(0) to match Ruby 1.9 (i.e. return a dup of array, instead of array itself)
== Version 1.18.0 - June 19th, 2010
* Added some features of 1.9.1:
* Math#log2, Math#log with base
* Also fixed Enumerator#each in 1.8.6.
== Version 1.17.0 - May 17th, 2010
* Added some features of 1.9.2:
* Array#repeated_combination, #repeated_permutation
== Version 1.16.2 - April 11th, 2010
* Added some features of 1.9.2:
* Array#uniq, #uniq! (with block)
* Array#product (with block)
* Dir.home
* Hash#keep_if, select!
* Random (new class)
== Version 1.15.0 - March 23rd, 2010
* Added a features of 1.9.2:
* Object#singleton_class
== Version 1.14.0 - March 3rd, 2010
* Added some features of 1.9.2:
* Array#rotate, rotate!
* Array#keep_if, select!
* Array#sort_by!
* Enumerable#join
* Enumerable#slice_before
* Float::INFINITY, NAN
* MatchData#==
== Version 1.13.0 - January 20th, 2010
* Missing for 1.8.7 were
* Array#permutation
* Hash#hash (was only inherited)
* Hash#eql? (was only inherited)
== Version 1.12.0 - December 4th, 2009
* Finer grain includes (see README)
require "backports/1.9" # requires all ruby backports
require "backports/1.9.1" # requires all ruby backports up to 1.9.1 (but not 1.9.2)
* Backported all builtin methods of 1.8.8 (most of which where moved from the 1.9 backports)
* Refreshed README
== Version 1.11.0 - November 4th, 2009
* Added Enumerable#flat_map / collect_concat (Ruby 1.9)
* Added Object#public_send (Ruby 1.9)
* Added Object#public_method (Ruby 1.9)
* bug fixes
== Version 1.10.0 - September 29th, 2009
* Added Enumerable#chunk (Ruby 1.9)
* Added Kernel#respond_to_missing? (Ruby 1.9)
* Completed Process.exec (Ruby 1.8.7)
== Version 1.9.0 - September 4th, 2009
* In Ruby 1.9, most class methods of File accept filenames as String, or convertible via #to_str or #to_path.
File#to_path is also an alias to File#path. These have been backported.
* File.binread (actually IO.binread)
* BasicObject available via "require 'backports/basic_object"
== Version 1.8.4 - September 3rd, 2009
Added Dir.mktmpdir for older version of 1.8.6
== Version 1.8.1 - September 1st, 2009
Added the alias String#lines (Ruby 1.8.7)
== Version 1.8 - August 30, 2009
Backports can be required selectively:
* backports/1.8.7
* backports/1.9 (which include 1.8.7)
* rails
== Version 1.8 - August 30, 2009
Backports can be required selectively:
* backports/1.8.7
* backports/1.9 (which include 1.8.7)
* rails
== Version 1.7.1 - August 20, 2009
Enumerable#take and Enumerable#first(n) are now returning as soon as possible. Previously, #each was yielding one element too many. See redmine issue #1554.
== Version 1.7 - May 27, 2009
Porting all 1.8.7 features to rubinius was quite enlightening (http://blog.marc-andre.ca/2009/05/schizo-ruby-puzzle.html ).
Many improvements were made to be consistent with MRI, e.g. converting arguments using to_int if needed, etc...
The changes are now reflected in 'backports'.
Some IO and ARGF methods were missing and are now complete.
== Version 1.6.6 - April 30, 2009
Important bug fix. String#gsub is left alone until I find a good way to modify it.
== Version 1.6 - April 29, 2009
Completed backport to 1.8.7.
* Array
* <tt>extract_options!</tt>
* Binding
* +eval+
* Dir
* +each+, +foreach+
* Enumerator
* +new+
* +with_object+
* +next+, +rewind+
* Hash
* Optional block for <tt>delete_if, each, each_key, each_pair, each_value, reject!, select</tt> (and ENV)
* Integer
* moved stuff out of Fixnum
* Optional block for +downto+, +times+, +upto+
* IO
* Optional block for +each+, +each_line+, +each_byte+, +foreach+ (and ARGF)
* Kernel
* +loop+, +StopIteration+
* +__method__+, +__callee__+
* Method
* +name+, +owner+, +receiver+
* Module
* +class_exec+, +module_exec+
* Numeric
* +step+
* Object
* +define_singleton_method+
* +instance_exec+
* ObjectSpace
* +each_object+
* Range
* Optional block for +each+, +step+
* Regexp
* +union+
* String
* +try_convert+
* <tt>ascii_only?</tt>
* +bytesize+
* +chr+
* +clear+
* +codepoints+, +each_codepoint+
* +stringify_keys+, +stringify_keys!+
* +each+, +each_line+, +each_byte+
* +gsub+
* +upto+
* Struct
* +each+, +each_pair+
* Symbol
* <tt><=></tt>, +casecmp+
* +capitalize+, +downcase+, +next+, +succ+, +swapcase+, +upcase+
* <tt>=~, [], empty?, length, match, size</tt>
* UnboundMethod
* +name+, +owner+
== Version 1.5 - April 24, 2009
* Array (completed)
* +combination+
* +try_convert+
* Optional block for <tt>collect!, :map!, :each, :each_index, :reject, :reject!, :delete_if</tt>
* +pop+, +shift+
* +product+
* Fixnum (completed)
* +div+, +fdiv+
* +succ+
* +magnitude+
* Enumerable (completed)
* +each_with_object+
* +inject+
* +max_by+, +min_by+, +minmax+, +minmax_by+
* +reduce+
* +to_a+
== Version 1.4 - April 21, 2009
* String
* +rpartition+
* Proc
* +yield+
== Version 1.3 - April 17, 2009
* Enumerable
* <tt>none?</tt>
* Array
* +sample+, +shuffle+, +shuffle!+
* String
* +each_char+, +chars+
* +partition+
Tests and fixes for <tt>String#start_with?</tt> and <tt>String#end_with?</tt>
== Version 1.2 - April 12, 2009
* Array
* +reverse_each+
* +cycle+
* Enumerable
* +reverse_each+
* +each_slice+, +each_cons+
* +count+
* +cycle+
* +group_by+
* Hash
* <tt>default_proc=</tt>
== Version 1.1 - April 11, 2009
* Array
* +flatten+, <tt>flatten!</tt>
* +find_index+, +index+
* Hash
* +reverse_merge+, <tt>reverse_merge!</tt>
== Version 1.0 - April 2nd, 2009
=== Initial release.
source "http://rubygems.org"
# Declare your gem's dependencies in backports.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# jquery-rails is used by the dummy application
group :test do
gem "rake"
gem 'mspec', :git => 'git://github.com/rubyspec/mspec.git'
end
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
GIT
remote: git://github.com/rubyspec/mspec.git
revision: 69c388b1187789f4996eda7dec4c1404fcd6b742
specs:
mspec (1.5.18)
PATH
remote: .
specs:
backports (3.1.1)
GEM
remote: http://rubygems.org/
specs:
rake (10.0.3)
PLATFORMS
java
ruby
DEPENDENCIES
backports!
mspec!
rake
Copyright (c) 2009 Marc-Andre Lafortune
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
= Backports Library {<img src="https://travis-ci.org/marcandre/backports.png?branch=master">}[https://travis-ci.org/marcandre/backports]
* Yearning to use some of the new cool features in Ruby 2.0.0 while using 1.8.6?
* One of your client is stuck with Ruby 1.8.6 but you want to use a gem using some features of 1.8.7?
* Can't remember if you can use Array#sample or String#each_char on a friend's box?
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.
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'
This will bring in all the features of 1.8.7 and many features of Ruby 1.9.x and even Ruby 2.0.0 (for all versions of Ruby)!
+Note+: Although I am a Ruby committer, this gem is a personal project and is not endorsed by ruby-core.
== What's inside
Goals for backported features:
1. Won't break older code
2. Pure Ruby (no C extensions)
3. Pass RubySpec[http://github.com/rubyspec/rubyspec]
Let's be a bit more precise about the "breaking code" business. It is of course entirely possible that code will break, for example some core methods are monkeypatched or if the code relies on a certain call raising an exception. Example: <tt>[42].sample rescue "dum example"</tt> will return <tt>"dum example"</tt> without this gem and <tt>42</tt> with it.
A real incompatibility is, for example, <tt>Module::instance_methods</tt> which returns strings in 1.8 and symbols in 1.9. No change can be made without the risk of breaking existing code. Such incompatibilities are left unchanged, although you can require some of these changes in addition (see below)
All features of 1.8.7 are backported (well, almost all, see the exception list bellow), and many of 1.9 are also. Some features of 2.0.0 are backported too.
Some generic and self-contained features of active-support are also included. By simple I mean that String#camelcase is there, but #pluralize isn't.
== Installation & compatibility
+backports+ is can be installed with:
(sudo) gem install backports
To use:
require 'rubygems'
# 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]. That's about 130 backports!
Only exceptions:
* String#gsub (the form returning an enumerator)
* GC.stress= (not implemented)
* Array#choice (removed in 1.9, use 1.9.1's Array#sample instead)
To include _only_ these backports, <tt>require "backports/1.8.7"</tt>
== Ruby 1.8.8
<