array_enumerator 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aab5eb33c71ba8c4f8c3522917f0ee5c2c1bdde
4
- data.tar.gz: 08086ebda4167d4ff4c3ca9df66c3fad6f3ec2f2
3
+ metadata.gz: 69448f28caa793c6b65a60b298fe11fa2ac57d7c
4
+ data.tar.gz: ed8e36e4a408788d181f8cc3ac69ec7153dfa3d2
5
5
  SHA512:
6
- metadata.gz: 8446dacab604ccf62bd44f2b5c4d5cdf6b9a63d959c7216dcbcb1647b3880b6972189539b7ea0e6f04bcfe2fcfb674b15728ef2029ce7a7798926b26f078cc62
7
- data.tar.gz: 56abf61e50da49e75d75bb6a28dccce84d49a6768332cfd68db2c865ca4ffe37030055cccdae3aa359429563d6bbd95726b5473763fd6b6e5e3ae913d0285277
6
+ metadata.gz: e3344e03d49a23806f940847ede0411d21b3650fce45875259d2a4fe97cbaf146d815197d50e75f6e9d46f0434702810fe354599d90ee668e7daaff0ecd6820a
7
+ data.tar.gz: fdd8f72373942879ab83ff7f56b1a8b57d6d1a05a7450fb14e742e5b307609ad563b938b7df4d226590933215d927bef915cdc8094d3afdbadd2e7ea010ff145
data/README.md CHANGED
@@ -29,7 +29,7 @@ Call array-methods like you normally would:
29
29
  a_enum.empty? #=> false
30
30
  a_enum.first #=> 1
31
31
  a_enum.shift #=> 2
32
- a_enum[2] => 3
32
+ a_enum[2] #=> 3
33
33
  a_enum.each_index { |count| puts "Count: #{count}" }
34
34
  a_enum.length #=> 3
35
35
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -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 ruby lib
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.5"
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-19"
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 = [
@@ -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.5
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-19 00:00:00.000000000 Z
11
+ date: 2014-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec