enumerating 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,8 +7,10 @@ Lazy "filtering" and transforming
7
7
  Enumerating extends Enumerable with "lazy" versions of various common operations:
8
8
 
9
9
  * `#selecting` selects elements that pass a test block (like `Enumerable#select`)
10
+ * `#finding_all` is an alias for `#selecting` (like `Enumerable#find_all`)
10
11
  * `#rejecting` selects elements that fail a test block (like `Enumerable#reject`)
11
12
  * `#collecting` applies a transforming block to each element (like `Enumerable#collect`)
13
+ * `#mapping` is an alias for `#collecting` (like `Enumerable#map`)
12
14
  * `#uniqing` discards duplicates (like `Enumerable#uniq`)
13
15
  * `#taking`, `#taking_while`, `#dropping` and `#dropping_while` also do what you expect
14
16
 
@@ -28,7 +30,7 @@ Perhaps an example would help. Consider the following snippet:
28
30
  9^2 = 81
29
31
  10^2 = 100
30
32
  => [1, 4, 9, 16]
31
-
33
+
32
34
  Here we use plain old `#collect` to square a bunch of numbers, and then grab the ones less than 20. We can do the same thing using `#collecting`, rather than `#collect`:
33
35
 
34
36
  >> (1..10).collecting { |x| puts "#{x}^2 = #{x*x}"; x*x }.take_while { |x| x < 20 }
@@ -21,7 +21,7 @@ module Enumerating
21
21
  end
22
22
 
23
23
  module Enumerable
24
-
24
+
25
25
  def collecting
26
26
  Enumerating::Filter.new do |output|
27
27
  each do |element|
@@ -29,7 +29,9 @@ module Enumerable
29
29
  end
30
30
  end
31
31
  end
32
-
32
+
33
+ alias mapping collecting
34
+
33
35
  def selecting
34
36
  Enumerating::Filter.new do |output|
35
37
  each do |element|
@@ -37,7 +39,9 @@ module Enumerable
37
39
  end
38
40
  end
39
41
  end
40
-
42
+
43
+ alias finding_all selecting
44
+
41
45
  def rejecting
42
46
  Enumerating::Filter.new do |output|
43
47
  each do |element|
@@ -45,7 +49,7 @@ module Enumerable
45
49
  end
46
50
  end
47
51
  end
48
-
52
+
49
53
  def uniqing
50
54
  Enumerating::Filter.new do |output|
51
55
  seen = Set.new
@@ -63,18 +67,18 @@ module Enumerable
63
67
  end
64
68
  end
65
69
  end
66
-
70
+
67
71
  def taking(n)
68
72
  Enumerating::Filter.new do |output|
69
73
  if n > 0
70
74
  each_with_index do |element, index|
71
- output.call(element)
75
+ output.call(element)
72
76
  break if index + 1 == n
73
77
  end
74
78
  end
75
79
  end
76
80
  end
77
-
81
+
78
82
  def taking_while
79
83
  Enumerating::Filter.new do |output|
80
84
  each do |element|
@@ -83,7 +87,7 @@ module Enumerable
83
87
  end
84
88
  end
85
89
  end
86
-
90
+
87
91
  def dropping(n)
88
92
  Enumerating::Filter.new do |output|
89
93
  each_with_index do |element, index|
@@ -92,7 +96,7 @@ module Enumerable
92
96
  end
93
97
  end
94
98
  end
95
-
99
+
96
100
  def dropping_while
97
101
  Enumerating::Filter.new do |output|
98
102
  taking = false
@@ -102,6 +106,6 @@ module Enumerable
102
106
  end
103
107
  end
104
108
  end
105
-
109
+
106
110
  end
107
111
 
@@ -1,3 +1,3 @@
1
1
  module Enumerating
2
- VERSION = "1.1.0".freeze
2
+ VERSION = "1.1.1".freeze
3
3
  end
metadata CHANGED
@@ -1,27 +1,24 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: enumerating
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.1
4
5
  prerelease:
5
- version: 1.1.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Mike Williams
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-26 00:00:00 Z
12
+ date: 2011-08-25 00:00:00.000000000Z
14
13
  dependencies: []
15
-
16
- description: Enumerating extends Enumerable with "lazy" versions of various operations, allowing streamed processing of large (or even infinite) collections. Even in Ruby 1.8.x.
14
+ description: Enumerating extends Enumerable with "lazy" versions of various operations,
15
+ allowing streamed processing of large (or even infinite) collections. Even in Ruby
16
+ 1.8.x.
17
17
  email: mdub@dogbiscuit.org
18
18
  executables: []
19
-
20
19
  extensions: []
21
-
22
20
  extra_rdoc_files: []
23
-
24
- files:
21
+ files:
25
22
  - .gitignore
26
23
  - Gemfile
27
24
  - README.markdown
@@ -42,35 +39,37 @@ files:
42
39
  - spec/spec_helper.rb
43
40
  homepage: http://github.com/mdub/enumerating
44
41
  licenses: []
45
-
46
42
  post_install_message:
47
43
  rdoc_options: []
48
-
49
- require_paths:
44
+ require_paths:
50
45
  - lib
51
- required_ruby_version: !ruby/object:Gem::Requirement
46
+ required_ruby_version: !ruby/object:Gem::Requirement
52
47
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
57
- required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ segments:
53
+ - 0
54
+ hash: -2370472515613642162
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
56
  none: false
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: "0"
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ segments:
62
+ - 0
63
+ hash: -2370472515613642162
63
64
  requirements: []
64
-
65
65
  rubyforge_project:
66
- rubygems_version: 1.7.2
66
+ rubygems_version: 1.8.6
67
67
  signing_key:
68
68
  specification_version: 3
69
69
  summary: Lazy filtering/transforming of Enumerable collections
70
- test_files:
70
+ test_files:
71
71
  - spec/enumerating/concatenating_spec.rb
72
72
  - spec/enumerating/filtering_spec.rb
73
73
  - spec/enumerating/merging_spec.rb
74
74
  - spec/enumerating/zipping_spec.rb
75
75
  - spec/spec_helper.rb
76
- has_rdoc: