Commit b9cc9776 authored by Antonio Terceiro's avatar Antonio Terceiro

Update upstream source from tag 'upstream/3.11.1'

Update to upstream version '3.11.1'
with Debian dir ef593a7e8ac84b8458b3e466d5a58d78a285b09f
parents 48ed064f 7b346185
......@@ -6,3 +6,4 @@ rdoc
pkg
assets
rs
Gemfile.lock
[submodule "spec/rubyspec"]
path = spec/rubyspec
url = git://github.com/rubyspec/rubyspec.git
url = git://github.com/ruby/spec.git
[submodule "frozen_old_spec/rubyspec"]
path = frozen_old_spec/rubyspec
url = git://github.com/ruby/spec.git
$:.unshift "./lib"
# frozen_string_literal: true
$LOAD_PATH.unshift './lib'
......@@ -3,21 +3,16 @@ language: ruby
rvm:
- "1.8.7"
- "1.9.2"
- "1.9.3"
- "2.0.0"
- "2.1.0"
- "2.2.0"
- "2.3.0"
- "2.4.0"
- ruby-head
- jruby-18mode
- jruby-19mode
- rbx-18mode
- rbx-19mode
matrix:
allow_failures:
- rvm: jruby-18mode
- rvm: jruby-19mode
- rvm: rbx-18mode
- rvm: rbx-19mode
# matrix:
# allow_failures:
# - rvm: "2.2.0" # Travis suddenly fails to `bundle install`, no idea why
before_install:
- git submodule update --init --recursive
= Backports --- History
== Version 3.11.0 - December 25th, 2017
* New Ruby version 2.5.0
* Array
* +append+, +prepend+
* Dir
* +children+, +each_child+
* Enumerable
* +any?+, +all?+, +none?+, +one?+ (with pattern argument)
* Hash
* +slice+
* +transform_keys+
* Integer
* +sqrt+
* +allbits?+, +anybits?+ and +nobits?+
* Kernel
* +yield_self+
* Module
* +attr+, +attr_accessor+, +attr_reader+, +attr_writer+ (now public)
* +define_method+, +alias_method+, +undef_method+, +remove_method+ (now public)
* String
* +delete_prefix+, +delete_prefix!+
* +delete_suffix+, +delete_suffix!+
* Struct
* +new+ (with <code>keyword_init: true</code>)
* <tt>require 'backports/latest'</tt> is now the right way to require everything
== Version 3.10.0 - October 17, 2017
* Additional features of 2.4.0
* Enumerable
* +uniq+
* +sum+
* Hash
* +compact+
* +transform_values+
== Version 3.9.0 - October 07, 2017
* From 2.4.0: +dup+ for +true+, +false+, +nil+, Numeric
* From 2.2.0: <tt>Method#super_method</tt>
== Version 3.8.0 - April 26, 2017
* From 2.4.0: <tt>String#match?</tt>, <tt>Regexp#match?</tt>
* From 2.3.0:
* unary <tt>String#+</tt>, +-+
* Numeric: +positive?+, +negative?+
* Hash: +to_proc+, +fetch_values+, <tt>></tt>, <tt><</tt>, <tt>>=</tt>, <tt><=</tt>
* Enumerable: +chunk_while+, +grep_v+
* <tt>{Array|Hash|Struct}#dig</tt>
* <tt>Array#bsearch_index</tt>
* From 2.2.0:
* <tt>Method#curry</tt>
* <tt>String#unicode_normalize{|?|!}</tt>
* <tt>Kernel#itself</tt>
* Float: +next_float+, +prev_float+
== Version 3.7.0 - March 28, 2017
* Initiate work on backports of 2.2, 2.3, 2.4
* From 2.4.0:
* <tt>Comparable#clamp</tt>
* From 2.2.0:
* Enumerable: +slice_when+, +slice_after+
== Version 3.6.0 - February 14th, 2014
* Additional features of 2.1.0
......
......@@ -8,10 +8,10 @@ gemspec
# jquery-rails is used by the dummy application
group :test do
gem "rake"
gem 'mspec', :git => 'git://github.com/rubyspec/mspec.git'
gem 'activesupport'
gem 'mspec'
gem 'activesupport', '~>3.2.0'
gem 'minitest', '< 5.0.0', :require => false
gem 'test-unit'
gem 'test-unit', '~>2.1.1.0'
end
# Declare any dependencies that are still in development here instead of in
......
GIT
remote: git://github.com/rubyspec/mspec.git
revision: 69c388b1187789f4996eda7dec4c1404fcd6b742
specs:
mspec (1.5.18)
PATH
remote: .
specs:
backports (3.6.8)
GEM
remote: http://rubygems.org/
specs:
activesupport (3.2.13)
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)
test-unit (2.1.1.0)
PLATFORMS
java
ruby
DEPENDENCIES
activesupport
backports!
minitest (< 5.0.0)
mspec!
rake
test-unit
......@@ -8,6 +8,10 @@ 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.
== Loading backports
=== Explicitly (recommended)
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'
......@@ -15,11 +19,23 @@ For example, if you want to use flat_map, even in Ruby implementations that don'
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:
=== By Module
To bring all the backports for a given Class/Module, you can specify only that Class:
require 'backports/2.3.0/hash'
This will make sure that Hash responds to dig, fetch_values, <, <=, >, >= and to_proc
=== Up to a specific Ruby version
require 'backports'
You can load all backports up to a specific version. For example, to bring any version of Ruby mostly up to Ruby 2.4.0's standards:
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)!
require 'backports/2.4.0'
This will bring in all the features of 1.8.7 and many features of Ruby 1.9.x all the way up to Ruby 2.4.0 (for all versions of Ruby)!
While it is not recommended, you may `require 'backports/latest'` as a shortcut to the latest Ruby version supported. This is equivalent to the deprecated `require 'backports'`.
+Note+: Although I am a Ruby committer, this gem is a personal project and is not endorsed by ruby-core.
......@@ -28,15 +44,11 @@ This will bring in all the features of 1.8.7 and many features of Ruby 1.9.x and
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.
3. Pass ruby/spec[https://github.com/ruby/spec]
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)
Let's be a bit more precise about the "breaking code" business. It is of course entirely possible that code will break. In particular, you may be distinguishing parameters with duck typing, but a builtin class may, in the future, be responding to a particular call. Here's [an exemple from Rails](https://github.com/rails/rails/blob/a4b55827721a5967299f3c1531afb3d6d81e4ac0/activerecord/lib/active_record/associations/association.rb#L155-L159) that is relying on the fact that Proc and Method respond to :to_proc and Hash isn't. That is, until Ruby 2.3... This old version of Rails therefore won't work on Ruby 2.3, or on older Rubies with that the `2.3.0/hash/to_proc` loaded...
All features of 1.8.7 are backported (well, almost all, see the exception list bellow), and many of the following versions up to 2.1
For historical reasons, 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. These will probably be removed in the future, so it's recommended to require those directly from active_support.
For Ruby < 2.0, there are some real incompatibilities. 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).
== Installation & compatibility
......@@ -54,9 +66,6 @@ To use:
# 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:
......@@ -64,11 +73,91 @@ With bundler, add to your Gemfile:
gem 'backports', :require => 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, 2.0, 2.1, JRuby and Rubinius.
Compatible with Ruby itself, JRuby and Rubinius.
= Complete List of backports
== Ruby 2.5 backports
* Array
* +append+, +prepend+
* Dir
* +children+, +each_child+
* Enumerable
* +any?+, +all?+, +none?+, +one?+ (with pattern argument)
* Hash
* +slice+
* +transform_keys+
* Integer
* +sqrt+
* +allbits?+, +anybits?+ and +nobits?+
* Kernel
* +yield_self+
* Module
* +attr+, +attr_accessor+, +attr_reader+, +attr_writer+ (now public)
* +define_method+, +alias_method+, +undef_method+, +remove_method+ (now public)
* String
* +delete_prefix+, +delete_prefix!+
* +delete_suffix+, +delete_suffix!+
* Struct
* +new+ (with <code>keyword_init: true</code>)
== Ruby 2.4 backports
* Comparable
* +clamp+
* Enumerable
* +sum+
* +uniq+
* Hash
* +compact+, +compact!+
* +transform_values+, +transform_values!+
* Regexp
* +match?+
* String
* +match?+
* FalseClass, Fixnum, Float, NilClass, TrueClass
* +dup+
== Ruby 2.3 backports
* Array
* +bsearch_index+
* +dig+
* Enumerable
* +chunk_while+
* +grep_v+
* Hash
* +dig+
* +fetch_values+
* +to_proc+
* <=, <, >=, >
* Numeric
* +negative?+
* +positive?+
* String
* unary + and -
* Struct
* +dig+
== Ruby 2.2 backports
* Enumerable
* +slice_after+
* +slice_when+
* Float
* +prev_float+
* +next_float+
* Kernel
* +itself+
* Method
* +curry+
* +super_method+
* String
* +unicode_normalize+
* +unicode_normalize!+
* +unicode_normalize?+
== Ruby 2.1 backports
* Array
......@@ -142,7 +231,7 @@ 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>.
*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>.
== Ruby 1.9.1 backports
......@@ -259,7 +348,7 @@ 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'.
Requiring backports for a given version of Ruby will also load 'backports/std_lib'.
== Forcing incompatibilities
......@@ -288,7 +377,7 @@ 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:
The best way to submit a patch is to also submit a patch to ruby/spec[https://github.com/ruby/spec] and then a patch to backports that make it pass the spec. To test rubyspec:
git submodule init && git submodule update # => pulls rubyspecs
rake spec[array/bsearch] # => tests Array#bsearch
......
......@@ -11,23 +11,28 @@ Rake::TestTask.new(:test) do |test|
test.verbose = false
end
desc "Run specs, where path can be '*/*' (default), 'class/*' or 'class/method'."
task :spec, :path, :action do |t, args|
args.with_defaults(:path => '*/*', :action => 'ci')
stats = [[0] * 5]
not_found = []
mspec_cmds(args[:path], args[:action]) do |cmd, path|
class SpecRunner
STATS = [:files, :examples, :expectations, :failures, :errors]
attr_reader :stats, :not_found
def initialize
@counts = [0] * 5
@not_found = []
end
def run(cmd, path)
result = `#{cmd}`
match = result.match(/(\d+) files?, (\d+) examples?, (\d+) expectations?, (\d+) failures?, (\d+) errors?/)
if match.nil?
puts "*** mspec returned with unexpected results:"
puts result
puts "Command was:", cmd
fail "Unexpected output from mspec"
end
_, ex, p, f, e = data = match.captures.map{|x| x.to_i}
not_found << path if ex == 0
stats << data
STATS.each_with_index do |_, i|
@counts[i] += data[i]
end
if f + e > 0
puts cmd
puts result
......@@ -36,12 +41,37 @@ task :spec, :path, :action do |t, args|
STDOUT.flush
end
end
$:.unshift 'lib'
require 'backports/rails'
_, ex, p, f, e = stats = stats.transpose.map{|x| x.sum}
puts "*** Overall:", stats.zip(%w[files examples expectations failures errors]).map{|a| a.join(' ')}.join(', ')
puts "No spec found for #{not_found.join(', ')}" unless not_found.empty?
fail unless f + e == 0
def stats
h = {}
STATS.zip(@counts).each{|k, v| h[k]=v}
h
end
def report
puts "*** Overall:", stats.map{|a| a.join(' ')}.join(', ')
puts "No spec found for #{@not_found.join(', ')}" unless @not_found.empty?
end
def success?
stats[:failures] == 0 && stats[:errors] == 0
end
end
desc "Run specs, where path can be '*/*' (default), 'class/*' or 'class/method'."
task :spec, :path, :action do |t, args|
args.with_defaults(:path => '*/*', :action => 'ci')
specs = SpecRunner.new
mspec_cmds(args[:path], 'frozen_old_spec', args[:action]) do |cmd, path|
specs.run(cmd, path)
end
unless RUBY_VERSION < '1.9' # Give up entirely on running new specs in 1.8.x, mainly because of {hash: 'syntax'}
mspec_cmds(args[:path], 'spec', args[:action]) do |cmd, path|
specs.run(cmd, path)
end
end
specs.report
fail unless specs.success?
end
task :all_spec do # Necessary because of argument passing bug in 1.8.7
......@@ -67,7 +97,13 @@ DEPENDENCIES = Hash.new([]).merge!(
'1.9.2/array/select' => 'backports/1.8.7/array/select',
'1.9.2/hash/select' => 'backports/1.8.7/hash/select',
'1.9.2/enumerable/each_entry' => 'backports/1.8.7/enumerable/each_with_index',
'2.0.0/hash/to_h' => 'backports/1.9.1/hash/default_proc'
'2.0.0/hash/to_h' => 'backports/1.9.1/hash/default_proc',
'2.2.0/float/next_float' => 'backports/2.2.0/float/prev_float',
'2.2.0/float/prev_float' => 'backports/2.2.0/float/next_float',
'2.3.0/array/bsearch_index' => ['backports/2.3.0/array/dig', 'backports/2.3.0/hash/dig'],
'2.3.0/array/dig' => ['backports/2.3.0/hash/dig', 'backports/2.3.0/struct/dig'],
'2.3.0/hash/dig' => ['backports/2.3.0/array/dig', 'backports/2.3.0/struct/dig'],
'2.3.0/struct/dig' => ['backports/2.3.0/array/dig', 'backports/2.3.0/hash/dig']
)
{
:each_with_index => %w[enumerable/detect enumerable/find enumerable/find_all enumerable/select enumerable/to_a],
......@@ -76,31 +112,66 @@ DEPENDENCIES = Hash.new([]).merge!(
libs.each{|l| DEPENDENCIES["1.8.7/#{l}"] = "backports/1.8.7/enumerable/#{req}" }
end
# These cause actual errors while loading in 1.8:
IGNORE_IN_18 = %w[
# These **old** specs cause actual errors while loading in 1.8:
OLD_IGNORE_IN_18 = %w[
1.9.1/symbol/length
1.9.1/symbol/size
1.9.3/string/byteslice
1.8.7/proc/yield
1.9.1/proc/case_compare
2.4.0/string/match
2.4.0/regexp/match
2.5.0/module/define_method
]
def mspec_cmds(pattern, action='ci')
# These **new** specs cause actual errors while loading in 1.9:
IGNORE_IN_19 = %w[
2.1.0/enumerable/to_h
2.1.0/array/to_h
2.1.0/module/include
2.5.0/module/define_method
2.5.0/module/alias_method
2.5.0/module/undef_method
2.5.0/module/remove_method
2.5.0/module/attr
2.5.0/module/attr_reader
2.5.0/module/attr_writer
2.5.0/module/attr_accessor
2.5.0/struct/new
]
# These **new** specs cause actual errors while loading in 2.0.0:
IGNORE_IN_200 = %w[
2.4.0/enumerable/sum
]
CLASS_MAP = Hash.new{|k, v| k[v] = v}.merge!(
'match_data' => 'matchdata', # don't ask me why RubySpec uses matchdata instead of match_data
'true_class' => 'true',
'false_class' => 'false',
'nil_class' => 'nil'
)
def mspec_cmds(pattern, spec_folder, action='ci')
pattern = "lib/backports/*.*.*/#{pattern}.rb"
Dir.glob(pattern) do |lib_path|
_match, version, path = lib_path.match(/backports\/(\d\.\d\.\d)\/(.*)\.rb/).to_a
next if path =~ /stdlib/
next if version <= RUBY_VERSION
version_path = "#{version}/#{path}"
next if IGNORE_IN_18.include? version_path if RUBY_VERSION < '1.9'
if RUBY_VERSION < '2.0.0'
next if OLD_IGNORE_IN_18.include? version_path if RUBY_VERSION < '1.9'
next if IGNORE_IN_19.include? version_path
next if spec_folder != 'frozen_old_spec' && version <= '2.0.0' # Don't run new specs for pre 2.0 features & ruby
end
next if RUBY_VERSION < '2.1.0' && IGNORE_IN_200.include?(version_path)
deps = [*DEPENDENCIES[version_path]].map{|p| "-r #{p}"}.join(' ')
klass, method = path.split('/')
path = [klass.gsub('_', ''), method].join('/') # don't ask me why RubySpec uses matchdata instead of match_data
path = [CLASS_MAP[klass], method].join('/')
yield %W[mspec #{action}
-I lib
-r ./set_version/#{version}
#{deps}
-r backports/#{version_path}
spec/rubyspec/core/#{path}_spec.rb
#{spec_folder}/rubyspec/core/#{path}_spec.rb
].join(' '), path
end
end
fails:ARGF.each_line is a public method
fails:ARGF.each_line requires multiple arguments
fails:ARGF.each_line reads each line of files
fails:ARGF.each_line returns self when passed a block
fails:ARGF.each_line returns an Enumerator when passed no block
fails:ARGF.each_line with a separator yields each separated section of all streams
fails:ARGF.each is a public method
fails:ARGF.each requires multiple arguments
fails:ARGF.each reads each line of files
fails:ARGF.each returns self when passed a block
fails:ARGF.each returns an Enumerator when passed no block
fails:ARGF.each with a separator yields each separated section of all streams
fails:ARGF.lines is a public method
fails:ARGF.lines requires multiple arguments
fails:ARGF.lines reads each line of files
fails:ARGF.lines returns self when passed a block
fails:ARGF.lines returns an Enumerator when passed no block
fails:ARGF.lines with a separator yields each separated section of all streams