epitools 0.5.65 → 0.5.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/epitools/core_ext/array.rb +8 -2
- data/spec/core_ext_spec.rb +12 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b21feb448e04c5e66454eb31818b0b78e9d7e36e
|
4
|
+
data.tar.gz: baa845fabc8a02be3239af3b21f8e1149796ccd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f3805e7813acd3582fd6db84925969711e3cda216adfb7f219e6ee2d89ab3a5574a12bb160c60fa2df4f4429d9b87ca6686b1f88baf54113a8caa5591557b95
|
7
|
+
data.tar.gz: c713ea6609db9fe3a257af5b01ea9fddb13f45d5e9ba2bd9f7bc48a3d955b6b141669e4eb23c1f48366216863a34c30dd1dc714b1f7d5c3660d074b2cab8f084
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.66
|
@@ -51,8 +51,14 @@ class Array
|
|
51
51
|
# => [ [:mins, 5], [:secs, 39] ]
|
52
52
|
#
|
53
53
|
def rzip(other)
|
54
|
-
# That's a lotta reverses!
|
55
|
-
|
54
|
+
reverse.zip(other.reverse).reverse # That's a lotta reverses!
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# See: Enumerable#split_at
|
59
|
+
#
|
60
|
+
def split_at(*args, &block)
|
61
|
+
super.to_a
|
56
62
|
end
|
57
63
|
|
58
64
|
#
|
data/spec/core_ext_spec.rb
CHANGED
@@ -470,9 +470,9 @@ describe Enumerable do
|
|
470
470
|
end
|
471
471
|
|
472
472
|
it "splits" do
|
473
|
-
[1,2,3,4,5].split_at {|e| e == 3}.
|
474
|
-
[1,2,3,4,5].split_after {|e| e == 3}.
|
475
|
-
[1,2,3,4,5].split_before {|e| e == 3}.
|
473
|
+
[1,2,3,4,5].split_at {|e| e == 3}.should == [ [1,2], [4,5] ]
|
474
|
+
[1,2,3,4,5].split_after {|e| e == 3}.should == [ [1,2,3], [4,5] ]
|
475
|
+
[1,2,3,4,5].split_before {|e| e == 3}.should == [ [1,2], [3,4,5] ]
|
476
476
|
|
477
477
|
result = "a\nb\n---\nc\nd\n".lines.split_at(/---/)
|
478
478
|
result.map_recursively(&:strip).should == [ %w[a b], %w[c d] ]
|
@@ -485,17 +485,22 @@ describe Enumerable do
|
|
485
485
|
array.split_at("a")
|
486
486
|
}.should_not raise_error
|
487
487
|
|
488
|
-
array.split_at("a").
|
489
|
-
array.split_at([1,2,3]).
|
488
|
+
array.split_at("a").should == [ array[0..1], array[3..3] ]
|
489
|
+
array.split_at([1,2,3]).should == [ array[0..2] ]
|
490
490
|
end
|
491
491
|
|
492
|
-
it "
|
492
|
+
it "splits with arbitrary objects" do
|
493
493
|
arbitrary = Struct.new(:a, :b, :c)
|
494
494
|
|
495
495
|
particular = arbitrary.new(1,2,3)
|
496
496
|
array = [ arbitrary.new, arbitrary.new, particular, arbitrary.new]
|
497
497
|
|
498
|
-
array.split_at(particular).
|
498
|
+
array.split_at(particular).should == [ array[0..1], array[3..3] ]
|
499
|
+
end
|
500
|
+
|
501
|
+
it "splits lazily" do
|
502
|
+
result = "a\nb\nc\nd".each_line.split_at("b")
|
503
|
+
result.is_an?(Enumerator).should == true
|
499
504
|
end
|
500
505
|
|
501
506
|
it "sums" do
|