backports 2.6.5 → 2.6.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,7 @@ This gem is for you!
9
9
  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:
10
10
 
11
11
  require 'backports'
12
-
12
+
13
13
  This will bring in all the features of 1.8.7 (for Ruby 1.8.6) and many features of Ruby 1.9.1 (for Ruby 1.8.x), Ruby 1.9.2 and Ruby 1.9.3 (for all earlier versions)!
14
14
 
15
15
  +Note+: Although I am a Ruby committer, this gem is a personal project and is not endorsed by ruby-core.
@@ -51,7 +51,7 @@ Complete Ruby 1.8.7 backporting (core language). Refer to the official list of c
51
51
  Only exceptions:
52
52
  * String#gsub (the form returning an enumerator)
53
53
  * GC.stress= (not implemented)
54
- * Array#choice (removed in 1.8.8, use Array#sample instead)
54
+ * Array#choice (removed in 1.9, use Array#sample instead)
55
55
 
56
56
  To include _only_ these backports, <tt>require "backports/1.8.7"</tt>
57
57
 
@@ -135,7 +135,7 @@ Additionally, the following Ruby 1.9 features have been backported:
135
135
 
136
136
  To include _only_ these backports and those of the 1.8 line, <tt>require "backports/1.9.1"</tt>.
137
137
 
138
- Moreover, a pretty good imitation of BasicObject is available,
138
+ Moreover, a pretty good imitation of +BasicObject+ is available,
139
139
  but since it is only an imitation, it must be required explicitly:
140
140
 
141
141
  require 'backports/basic_object'
@@ -174,7 +174,7 @@ Finally, most of Ruby 1.9.2 features have been backported:
174
174
 
175
175
  * Random (new class)
176
176
 
177
- To include all Ruby backports but not those of Rails, <tt>require "backports/1.9.2"</tt> (or "backports/1.9")
177
+ To include _only_ these backports and earlier, <tt>require "backports/1.9.2"</tt>
178
178
 
179
179
  == Ruby 1.9.3
180
180
 
@@ -189,6 +189,8 @@ Some features of Ruby 1.9.3 have been backported:
189
189
  * +byteslice+
190
190
  * +prepend+
191
191
 
192
+ To include all Ruby backports but not those of Rails, <tt>require "backports/1.9.3"</tt> (or "backports/1.9")
193
+
192
194
  == Rails
193
195
 
194
196
  Some generic methods from Rails methods have been copied:
@@ -261,7 +263,7 @@ Thanks for the bug reports and patches, in particular the repeat offenders:
261
263
 
262
264
  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:
263
265
 
264
- mspec path/to/specs -t path/to/ruby186 --unguarded -r path/to/backports
266
+ mspec path/to/specs -t path/to/ruby186 --unguarded -r path/to/backports
265
267
 
266
268
  You must then check manually for which failures are acceptable and which are not.
267
269
 
@@ -269,4 +271,4 @@ You must then check manually for which failures are acceptable and which are not
269
271
 
270
272
  +backports+ is released under the terms of the MIT License, see the included LICENSE file.
271
273
 
272
- Author:: Marc-André Lafortune
274
+ Author:: Marc-André Lafortune
@@ -12,33 +12,31 @@ module Enumerable
12
12
  end
13
13
  seq
14
14
  end unless method_defined? :count
15
-
15
+
16
16
  # Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
17
17
  def cycle(n = nil)
18
18
  return to_enum(:cycle, n) unless block_given?
19
- if n.nil?
20
- each{|e| yield e } until false
21
- else
22
- n = Backports.coerce_to_int(n)
23
- if n >= 1
24
- cache = []
25
- each do |elem|
26
- cache << elem
27
- yield elem
28
- end
29
- (n-1).times do
30
- cache.each{|e| yield e }
31
- end
19
+ n = n && Backports.coerce_to_int(n)
20
+ if n == nil || n >= 1
21
+ cache = []
22
+ each do |elem|
23
+ cache << elem
24
+ yield elem
32
25
  end
26
+ if n
27
+ (n-1).times { cache.each{|e| yield e } }
28
+ else
29
+ loop { cache.each{|e| yield e } }
30
+ end unless cache.empty?
33
31
  end
34
32
  nil
35
33
  end unless method_defined? :cycle
36
-
34
+
37
35
  # Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
38
36
  Backports.make_block_optional self, :each_cons, :each_slice, :test_on => 1..2, :arg => 1
39
37
 
40
38
  Backports.make_block_optional self, :detect, :find, :find_all, :select, :sort_by, :partition, :reject, :test_on => 1..2
41
-
39
+
42
40
  # Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
43
41
  def drop(n)
44
42
  n = Backports.coerce_to_int(n)
@@ -47,7 +45,7 @@ module Enumerable
47
45
  return [] if n > ary.size
48
46
  ary[n...ary.size]
49
47
  end unless method_defined? :drop
50
-
48
+
51
49
  # Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
52
50
  def drop_while
53
51
  return to_enum(:drop_while) unless block_given?
@@ -58,7 +56,7 @@ module Enumerable
58
56
  end
59
57
  ary
60
58
  end unless method_defined? :drop_while
61
-
59
+
62
60
  # Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
63
61
  if instance_method(:each_with_index).arity.zero?
64
62
  def each_with_index_with_optional_args_and_block(*args)
@@ -85,7 +83,7 @@ module Enumerable
85
83
  end
86
84
  nil
87
85
  end unless method_defined? :find_index
88
-
86
+
89
87
  # Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
90
88
  def first(n = Backports::Undefined)
91
89
  return take(n) unless n == Backports::Undefined
@@ -102,7 +100,7 @@ module Enumerable
102
100
  end
103
101
  end
104
102
  end unless method_defined? :group_by
105
-
103
+
106
104
  # Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
107
105
  unless ((1..2).inject(:+) rescue false)
108
106
  def inject_with_symbol(*args, &block)
@@ -112,7 +110,7 @@ module Enumerable
112
110
  end
113
111
  Backports.alias_method_chain self, :inject, :symbol
114
112
  end
115
-
113
+
116
114
  MOST_EXTREME_OBJECT_EVER = Object.new # :nodoc:
117
115
  class << MOST_EXTREME_OBJECT_EVER
118
116
  def < (whatever)
@@ -162,7 +160,7 @@ module Enumerable
162
160
  end
163
161
  [min, max]
164
162
  end unless method_defined? :minmax
165
-
163
+
166
164
  # Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
167
165
  def minmax_by
168
166
  return to_enum(:minmax_by) unless block_given?
@@ -203,7 +201,7 @@ module Enumerable
203
201
  end unless method_defined? :one?
204
202
 
205
203
  Backports.alias_method self, :reduce, :inject
206
-
204
+
207
205
  # Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
208
206
  def reverse_each
209
207
  return to_enum(:reverse_each) unless block_given?
@@ -211,7 +209,7 @@ module Enumerable
211
209
  to_a.reverse_each{|e| yield e}
212
210
  self
213
211
  end unless method_defined? :reverse_each
214
-
212
+
215
213
  # Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
216
214
  def take(n)
217
215
  n = Backports.coerce_to_int(n)
@@ -223,7 +221,7 @@ module Enumerable
223
221
  end unless n <= 0
224
222
  end
225
223
  end unless method_defined? :take
226
-
224
+
227
225
  # Standard in Ruby 1.8.7+. See official documentation[http://ruby-doc.org/core-1.9/classes/Enumerable.html]
228
226
  def take_while
229
227
  return to_enum(:take_while) unless block_given?
@@ -241,7 +239,7 @@ module Enumerable
241
239
  end
242
240
  Backports.alias_method_chain self, :to_a, :optional_arguments
243
241
  end
244
-
242
+
245
243
  # alias_method gives a warning, so instead copy-paste:
246
244
  if instance_method(:entries).arity.zero?
247
245
  def entries_with_optional_arguments(*args)
@@ -250,5 +248,5 @@ module Enumerable
250
248
  end
251
249
  Backports.alias_method_chain self, :entries, :optional_arguments
252
250
  end
253
-
251
+
254
252
  end
@@ -1,3 +1,3 @@
1
1
  module Backports
2
- VERSION = "2.6.5"
2
+ VERSION = "2.6.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backports
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.5
4
+ version: 2.6.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-01 00:00:00.000000000 Z
12
+ date: 2013-01-15 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Essential backports that enable some of the really nice features of ruby
15
15
  1.8.7, ruby 1.9 and rails from ruby 1.8.6 and earlier.