Commit 632a9faf authored by David Suárez's avatar David Suárez

Imported Upstream version 3.6.1

parent 4c57661e
......@@ -10,6 +10,7 @@ group :test do
gem "rake"
gem 'mspec', :git => 'git://github.com/rubyspec/mspec.git'
gem 'activesupport'
gem 'minitest', '< 5.0.0', :require => false
end
# Declare any dependencies that are still in development here instead of in
......
......@@ -7,7 +7,7 @@ GIT
PATH
remote: .
specs:
backports (3.6.0)
backports (3.6.1)
GEM
remote: http://rubygems.org/
......@@ -16,6 +16,7 @@ GEM
i18n (= 0.6.1)
multi_json (~> 1.0)
i18n (0.6.1)
minitest (4.7.5)
multi_json (1.7.2)
rake (10.1.0)
......@@ -26,5 +27,6 @@ PLATFORMS
DEPENDENCIES
activesupport
backports!
minitest (< 5.0.0)
mspec!
rake
......@@ -142,6 +142,8 @@ Compatible with Ruby 1.8.6, 1.8.7, 1.9.1, 1.9.2, 1.9.3, 2.0, 2.1, JRuby and Rubi
* Random (new class)
*Note*: The methods of +Random+ can't be required individually; the class can only be required whole with <tt>require 'backports/1.9.2/random'</tt>. The implementation is also available with <tt>require 'backports/random/implementation'</tt>.
== Ruby 1.9.1 backports
Additionally, the following Ruby 1.9 features have been backported:
......@@ -237,9 +239,9 @@ Only exceptions:
== Libraries
Libraries are slowly being backported. You simply require them as usual, ideally (but not necessarily) after requiring backports.
Libraries are slowly being backported. You simply require them as usual after requiring 'backports/std_lib'. Requiring 'backports/std_lib' after the standard libraries is also supported.
require "backports"
require "backports/std_lib"
require "prime"
42.prime? # => false, even in Ruby 1.8.x
......@@ -257,6 +259,8 @@ I am aware of the following backport gem, which probably won't make it into this
* Net::SMTP for Ruby 1.8.6: smtp_tls[http://seattlerb.rubyforge.org/smtp_tls/]
Requiring the whole of 'backports', or all backports for a given version of Ruby will also load 'backports/std_lib'.
== Forcing incompatibilities
Some backports would create incompatibilities in their current Ruby version but could be useful in some projects. It is possible to request such incompatible changes. Backports currently supports the following:
......
......@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
gem.version = Backports::VERSION
gem.authors = ["Marc-André Lafortune"]
gem.email = ["github@marc-andre.ca"]
gem.description = %q{Essential backports that enable many of the nice features of Ruby 1.8.7 up to 2.0.0 for earlier versions.}
gem.description = %q{Essential backports that enable many of the nice features of Ruby 1.8.7 up to 2.1.0 for earlier versions.}
gem.summary = %q{Backports of Ruby features for older Ruby.}
gem.homepage = "http://github.com/marcandre/backports"
......
# require this file to load all the backports of Ruby 1.8.7
require "backports/tools"
require "backports/std_lib"
Backports.require_relative_dir
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional ARGF, :each, :force => true if RUBY_VERSION < '1.8.7'
if RUBY_VERSION < '1.8.7'
require 'backports/tools'
require 'backports/tools/make_block_optional'
class << ARGF
Backports.make_block_optional ARGF, :each_byte, :force => true
......
unless ARGF.respond_to? :each_char
require 'backports/tools'
require 'backports/tools/alias_method'
require 'enumerator'
class << ARGF
......
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional ARGF, :each_line, :force => true if RUBY_VERSION < '1.8.7'
require 'backports/tools'
require 'backports/tools/alias_method'
class << ARGF
Backports.alias_method self, :getbyte, :getc
......
require 'backports/tools'
require 'backports/tools/alias_method'
class << ARGF
Backports.alias_method self, :readbyte, :readchar
......
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Array, :collect!, :test_on => [42]
unless Array.method_defined? :combination
require 'backports/tools'
require 'backports/tools/arguments'
require 'enumerator'
class Array
......
unless Array.method_defined? :cycle
require 'backports/tools'
require 'backports/tools/arguments'
class Array
def cycle(n = nil)
......
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Array, :delete_if, :test_on => [42]
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Array, :each, :test_on => [42]
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Array, :each_index, :test_on => [42]
unless ([[]].flatten(1) rescue false)
require 'backports/tools'
require 'backports/tools/alias_method_chain'
require 'backports/tools/arguments'
class Array
# Recursively flatten any contained Arrays into an one-dimensional result.
......
unless ([1].index{true} rescue false)
require 'backports/tools'
require 'backports/tools/alias_method_chain'
require 'enumerator'
class Array
......
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Array, :map!, :test_on => [42]
unless Array.method_defined? :permutation
require 'backports/tools'
require 'backports/tools/arguments'
require 'enumerator'
class Array
......
unless ([1].pop(1) rescue false)
require 'backports/tools'
require 'backports/tools/alias_method_chain'
require 'backports/tools/arguments'
class Array
def pop_with_optional_argument(n = Backports::Undefined)
......
unless Array.method_defined? :product
require 'backports/tools'
require 'backports/tools/arguments'
class Array
def product(*arg)
......
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Array, :reject, :reject!, :test_on => [42]
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Array, :reverse_each, :test_on => [42]
unless ([1].rindex{true} rescue false)
class Array
require 'backports/tools'
require 'backports/tools/alias_method_chain'
require 'enumerator'
def rindex_with_block(*arg)
......
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Array, :select, :test_on => [42]
unless ([1].shift(1) rescue false)
class Array
require 'backports/tools'
require 'backports/tools/alias_method_chain'
require 'backports/tools/arguments'
def shift_with_optional_argument(n = Backports::Undefined)
return shift_without_optional_argument if n == Backports::Undefined
......
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
require 'backports/tools'
require 'backports/tools/make_block_optional'
begin
Backports.make_block_optional Dir, :each, :test_on => Dir.new('.')
......
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
unless Enumerable.method_defined? :count
require 'backports/tools'
require 'backports/tools/arguments'
module Enumerable
def count(item = Backports::Undefined)
......
unless Enumerable.method_defined? :cycle
require 'backports/tools'
require 'backports/tools/arguments'
require 'enumerator'
module Enumerable
......
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Enumerable, :detect, :test_on => 1..2
unless Enumerable.method_defined? :drop
require 'backports/tools'
require 'backports/tools/arguments'
module Enumerable
def drop(n)
......
require 'backports/tools'
require 'backports/tools/make_block_optional'
require 'enumerator' unless Enumerable.method_defined? :each_cons
Backports.make_block_optional Enumerable, :each_cons, :test_on => 1..2, :arg => 1
require 'backports/tools'
require 'backports/tools/make_block_optional'
require 'enumerator' unless Enumerable.method_defined? :each_slice
Backports.make_block_optional Enumerable, :each_slice, :test_on => 1..2, :arg => 1
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Enumerable, :each_with_index, :test_on => 1..2
if Enumerable.instance_method(:entries).arity.zero?
require 'backports/tools'
require 'backports/tools/alias_method_chain'
module Enumerable
def entries_with_optional_arguments(*args)
......
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Enumerable, :find, :test_on => 1..2
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Enumerable, :find_all, :test_on => 1..2
unless Enumerable.method_defined? :find_index
require 'backports/tools'
require 'backports/tools/arguments'
require 'enumerator'
module Enumerable
......
unless Enumerable.method_defined? :first
require 'backports/tools'
require 'backports/tools/arguments'
module Enumerable
def first(n = Backports::Undefined)
......
unless ((1..2).inject(:+) rescue false)
require 'backports/tools'
require 'backports/tools/alias_method'
require 'backports/tools/alias_method_chain'
module Enumerable
def inject_with_symbol(*args, &block)
......
unless Enumerable.method_defined? :max_by
require 'backports/tools'
require 'backports/tools/extreme_object'
require 'enumerator'
module Enumerable
......
unless Enumerable.method_defined? :min_by
require 'backports/tools'
require 'backports/tools/extreme_object'
require 'enumerator'
module Enumerable
......
unless Enumerable.method_defined? :minmax
require 'backports/tools'
require 'backports/tools/arguments'
module Enumerable
def minmax
......
unless Enumerable.method_defined? :minmax_by
require 'backports/tools'
require 'backports/tools/extreme_object'
require 'enumerator'
module Enumerable
......
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Enumerable, :partition, :test_on => 1..2
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Enumerable, :reject, :test_on => 1..2
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Enumerable, :select, :test_on => 1..2
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Enumerable, :sort_by, :test_on => 1..2
if Enumerable.instance_method(:to_a).arity.zero?
require 'backports/tools'
require 'backports/tools/alias_method_chain'
require 'enumerator'
module Enumerable
......
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
unless Object.const_defined? :Enumerator
require 'backports/tools'
require 'backports/tools/make_block_optional'
require 'enumerator'
Backports.make_block_optional Enumerable::Enumerator, :each, :test_on => [42].to_enum
......
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional ENV, :delete_if, :test_on => ENV
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional ENV, :each, :test_on => ENV
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional ENV, :each_key, :test_on => ENV
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional ENV, :each_pair, :test_on => ENV
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional ENV, :each_value, :test_on => ENV
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional ENV, :reject, :test_on => ENV
Backports.make_block_optional ENV, :reject!, :test_on => ENV
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional ENV, :select, :test_on => ENV
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
unless (Hash[[[:test, :test]]] rescue false)
require 'backports/tools'
require 'backports/tools/arguments'
class << Hash
alias_method :constructor_without_key_value_pair_form, :[]
......
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Hash, :delete_if, :test_on => {:hello => "world!"}
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Hash, :each, :test_on => {:hello => "world!"}
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Hash, :each_key, :test_on => {:hello => "world!"}
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Hash, :each_pair, :test_on => {:hello => "world!"}
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Hash, :each_value, :test_on => {:hello => "world!"}
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Hash, :reject, :reject!, :test_on => {:hello => "world!"}
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Hash, :select, :test_on => {:hello => "world!"}
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Integer, :downto, :test_on => 42, :arg => 42
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Integer, :times, :test_on => 42
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional Integer, :upto, :test_on => 42, :arg => 42
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
require 'backports/tools'
require 'backports/tools/make_block_optional'
Backports.make_block_optional IO, :each, :force => true if RUBY_VERSION < '1.8.7'
require 'backports/tools'
require 'backports/tools/make_block_optional'
if RUBY_VERSION < '1.8.7'
Backports.make_block_optional IO, :each_byte, :force => true
......
require 'backports/tools'
require 'backports/tools/make_block_optional'
if RUBY_VERSION < '1.8.7'
Backports.make_block_optional IO, :each_line, :force => true
......
if RUBY_VERSION < '1.8.7'
require 'backports/tools'
require 'backports/tools/make_block_optional'
class << IO
Backports.make_block_optional self, :foreach, :force => true
......
require 'backports/tools'
require 'backports/tools/alias_method'
Backports.alias_method IO, :getbyte, :getc
require 'backports/tools'
require 'backports/tools/alias_method'
Backports.alias_method IO, :readbyte, :readchar
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
require 'backports/tools'
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir
unless Method.method_defined? :name
require 'backports/tools'
require 'backports/tools/alias_method_chain'
class Method
attr_accessor :name, :receiver, :owner
...