array_enumerator 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/array_enumerator.gemspec +3 -3
- data/lib/array_enumerator.rb +11 -0
- data/spec/array_enumerator_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69448f28caa793c6b65a60b298fe11fa2ac57d7c
|
4
|
+
data.tar.gz: ed8e36e4a408788d181f8cc3ac69ec7153dfa3d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3344e03d49a23806f940847ede0411d21b3650fce45875259d2a4fe97cbaf146d815197d50e75f6e9d46f0434702810fe354599d90ee668e7daaff0ecd6820a
|
7
|
+
data.tar.gz: fdd8f72373942879ab83ff7f56b1a8b57d6d1a05a7450fb14e742e5b307609ad563b938b7df4d226590933215d927bef915cdc8094d3afdbadd2e7ea010ff145
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/array_enumerator.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: array_enumerator 0.0.
|
5
|
+
# stub: array_enumerator 0.0.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "array_enumerator"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Kasper Johansen"]
|
14
|
-
s.date = "2014-12-
|
14
|
+
s.date = "2014-12-21"
|
15
15
|
s.description = "Enumerator abstraction layer that emulates certain array functionality (methods like empty?, slice, shift and more) by using a small cache and other tricks without loading all the data from the enumerator at the same time."
|
16
16
|
s.email = "k@spernj.org"
|
17
17
|
s.extra_rdoc_files = [
|
data/lib/array_enumerator.rb
CHANGED
@@ -125,6 +125,17 @@ class ArrayEnumerator
|
|
125
125
|
return @length_cache
|
126
126
|
end
|
127
127
|
|
128
|
+
def select
|
129
|
+
result = []
|
130
|
+
|
131
|
+
check_corrupted
|
132
|
+
self.each do |element|
|
133
|
+
result << element if yield(element)
|
134
|
+
end
|
135
|
+
|
136
|
+
return result
|
137
|
+
end
|
138
|
+
|
128
139
|
# Giving slice negaive arguments will force it to cache all elements and crush the memory for big results.
|
129
140
|
def slice(*args)
|
130
141
|
check_corrupted
|
@@ -120,4 +120,15 @@ describe "ArrayEnumerator" do
|
|
120
120
|
expect += 1
|
121
121
|
end
|
122
122
|
end
|
123
|
+
|
124
|
+
it "#select" do
|
125
|
+
enum = ArrayEnumerator.new do |y|
|
126
|
+
10.times do |count|
|
127
|
+
y << count
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
result = enum.select { |element| element == 5}
|
132
|
+
result.should eq [5]
|
133
|
+
end
|
123
134
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: array_enumerator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Johansen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|