totally_lazy 0.1.50 → 0.1.51
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/totally_lazy/enumerators.rb +2 -0
- data/spec/totally_lazy/sequence_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTA2MGMwNjNjMzQyNmIyZjAzZmYxY2NhZTBjNzMyMWZlOTdjOTVjYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGM4MDZkNDVhNDU5OGRlYzI5NDFlMWIyYWY4NjkxMmFlZTEzMzdiZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmRhNjQyZGVhMjU1OGE4OGQ5MzNlMzQyYmY0NjM2MWI3YTI0YTI5YWIwYmY4
|
10
|
+
ZDUyMGU2MmI5OWYwYjkyNzczNTczYTA3MTI3ODg2YmYwMzE1MzEzNDZjZjc0
|
11
|
+
NmQ1YWJkNzYxYjAyOWE3MjE4ZjlhMTY3OTJjNjU0ZWJmYmZlYzU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OGM3MzBlYjZiZTY0ZTA2YTY1NTEyYjE2OTU2M2JmMjlmMmYwNWU2Mjk0YjI2
|
14
|
+
ZGU0MzhmY2FjMTE4NGM2MWNjMWYxNTFjYjMzZGI2NTM1ZDllOTEzZTg3OTVk
|
15
|
+
ODVmZmYzYzAyN2I2Mjk5NzM3NzlkOTFkMTk3NDU3MzVkMDlmN2I=
|
@@ -48,6 +48,7 @@ module Enumerators
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def flatten_enumerator(enumerator)
|
51
|
+
enumerator.rewind
|
51
52
|
Enumerator.new do |y|
|
52
53
|
current_enumerator = empty_enumerator
|
53
54
|
|
@@ -55,6 +56,7 @@ module Enumerators
|
|
55
56
|
until has_next(current_enumerator)
|
56
57
|
return empty_enumerator unless has_next(enumerator)
|
57
58
|
current_enumerator = enumerator.next.enumerator
|
59
|
+
current_enumerator.rewind
|
58
60
|
end
|
59
61
|
current_enumerator
|
60
62
|
}
|
@@ -211,6 +211,12 @@ describe 'Sequence' do
|
|
211
211
|
expect(sequence(sequence(1)).flatten).to eq(sequence(1))
|
212
212
|
end
|
213
213
|
|
214
|
+
it 'should allow flattening multiple times' do
|
215
|
+
sequence = sequence(sequence('1', '2'), empty, sequence('4', '5'))
|
216
|
+
expect(sequence.flatten).to eq(sequence('1', '2', '4', '5'))
|
217
|
+
expect(sequence.flatten).to eq(sequence('1', '2', '4', '5'))
|
218
|
+
end
|
219
|
+
|
214
220
|
it 'should support drop' do
|
215
221
|
expect(sequence(1, 2, 3).drop(2)).to eq(sequence(3))
|
216
222
|
expect(sequence(1).drop(2)).to eq(empty)
|