backports 1.16.1 → 1.16.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +2 -1
- data/README.rdoc +1 -0
- data/VERSION.yml +1 -1
- data/backports.gemspec +1 -1
- data/lib/backports/1.8.7/array.rb +1 -1
- data/lib/backports/1.9.2/array.rb +22 -0
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
= Packable --- History
|
2
2
|
|
3
|
-
== Version 1.16.
|
3
|
+
== Version 1.16.2 - April 11th, 2010
|
4
4
|
|
5
5
|
* Added a features of 1.9.2:
|
6
6
|
|
7
7
|
* Array#uniq, #uniq! (with block)
|
8
|
+
* Array#product (with block)
|
8
9
|
* Dir.home
|
9
10
|
* Hash#keep_if, select!
|
10
11
|
* Random (new class)
|
data/README.rdoc
CHANGED
data/VERSION.yml
CHANGED
data/backports.gemspec
CHANGED
@@ -136,7 +136,7 @@ class Array
|
|
136
136
|
#
|
137
137
|
result = []
|
138
138
|
|
139
|
-
arg.map!
|
139
|
+
arg.map!{|ary| Backports.coerce_to_ary(ary)}
|
140
140
|
arg.reverse! # to get the results in the same order as in MRI, vary the last argument first
|
141
141
|
arg.push self
|
142
142
|
|
@@ -5,6 +5,28 @@ class Array
|
|
5
5
|
delete_if{|elem| !yield elem}
|
6
6
|
end unless method_defined? :keep_if
|
7
7
|
|
8
|
+
if [1].product([2]){break false}
|
9
|
+
def product_with_block(*arg, &block)
|
10
|
+
return product_without_block(*arg) unless block_given?
|
11
|
+
# Same implementation as 1.8.7, but yielding
|
12
|
+
arg.map!{|ary| Backports.coerce_to_ary(ary)}
|
13
|
+
arg.reverse! # to get the results in the same order as in MRI, vary the last argument first
|
14
|
+
arg.push self
|
15
|
+
|
16
|
+
outer_lambda = arg.inject(block) do |proc, values|
|
17
|
+
lambda do |partial|
|
18
|
+
values.each do |val|
|
19
|
+
proc.call(partial.dup << val)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
outer_lambda.call([])
|
25
|
+
self
|
26
|
+
end
|
27
|
+
Backports.alias_method_chain self, :product, :block
|
28
|
+
end
|
29
|
+
|
8
30
|
def rotate(n=1)
|
9
31
|
dup.rotate!(n)
|
10
32
|
end unless method_defined? :rotate
|