totally_lazy 0.0.9 → 0.0.10
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/README.md +2 -0
- data/VERSION +1 -1
- data/lib/sequence.rb +19 -11
- data/spec/predicate_spec.rb +8 -0
- data/totally_lazy.gemspec +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e34f37ae8c53dd9dce6023c6a3d478cf86df5d1
|
4
|
+
data.tar.gz: 2b8c465f1d922bc1fc84bd8dc10e4053d3317d1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3488513a08f9ab7133e21ff34cc54ab25723c6f3fb1161e67b81a1df2214cb5c858cbbb401e995a3b5580c824c2f0eb4df32ed43f50da02947bc3707c83c051e
|
7
|
+
data.tar.gz: 68c0689495a08940649cf76a299d084293bd9afd313b12db06baa83b179a91cbed1e6abe9b5b8d59a124a8b1aa90002d95f5fde89f8eedd05ac02be7ce503d0f
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# PLEASE NOTE - This project is not being actively maintained at the moment - I am taking a break - not sure when I will return.
|
2
|
+
|
1
3
|
# Totally Lazy for Ruby
|
2
4
|
|
3
5
|
This is a port of the java functional library [Totally Lazy](https://code.google.com/p/totallylazy/) to the ruby language. I've tried to get it as close as I can to the original concepts behind the java version of Totally Lazy but I'm still pretty far away from being happy with it.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.10
|
data/lib/sequence.rb
CHANGED
@@ -85,6 +85,25 @@ module Sequences
|
|
85
85
|
self.entries <=> object.entries
|
86
86
|
end
|
87
87
|
|
88
|
+
def flat_map(predicate=nil, &block)
|
89
|
+
if predicate
|
90
|
+
Sequence.new(self) { |yielder, val|
|
91
|
+
val.each {|x|
|
92
|
+
v = predicate.is_a?(WherePredicate) ? WhereProcessor.new(x).apply(predicate.predicates) : predicate.exec.call(x)
|
93
|
+
yielder << v unless v.nil?
|
94
|
+
}
|
95
|
+
}
|
96
|
+
else
|
97
|
+
Sequence.new(self) { |yielder, val|
|
98
|
+
ary = block.call(val)
|
99
|
+
ary.each { |x|
|
100
|
+
yielder << x
|
101
|
+
}
|
102
|
+
}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
alias collect_concat flat_map
|
106
|
+
|
88
107
|
def map(predicate=nil, &block)
|
89
108
|
if predicate
|
90
109
|
Sequence.new(self) { |yielder, val|
|
@@ -211,17 +230,6 @@ module Sequences
|
|
211
230
|
}
|
212
231
|
end
|
213
232
|
|
214
|
-
def flat_map(&block)
|
215
|
-
Sequence.new(self) { |yielder, val|
|
216
|
-
ary = block.call(val)
|
217
|
-
ary.each { |x|
|
218
|
-
yielder << x
|
219
|
-
}
|
220
|
-
}
|
221
|
-
end
|
222
|
-
|
223
|
-
alias collect_concat flat_map
|
224
|
-
|
225
233
|
def zip(*args, &block)
|
226
234
|
enums = [self] + args
|
227
235
|
Sequence.new(self) { |yielder, val|
|
data/spec/predicate_spec.rb
CHANGED
@@ -14,6 +14,14 @@ describe 'Predicates' do
|
|
14
14
|
expect { sequence(pair(1,2),pair(3,4)).filter(odd).entries }.to raise_error(UnsupportedTypeException)
|
15
15
|
end
|
16
16
|
|
17
|
+
it 'should support map' do
|
18
|
+
expect(sequence(1,2).map(as_string)).to eq(sequence("1","2"))
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should support flat_map' do
|
22
|
+
expect(sequence(sequence(1, 2), sequence(3, 4)).flat_map(as_string).to_a).to eq(sequence("1", "2", "3", "4").to_a)
|
23
|
+
end
|
24
|
+
|
17
25
|
it 'should return content as string' do
|
18
26
|
expect(sequence(1,2).map(as_string)).to eq(sequence("1","2"))
|
19
27
|
expect(sequence(pair(1,2),pair(3,4)).map(as_string).entries).to eq([{'1'=>'2'},{'3'=>'4'}])
|
data/totally_lazy.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: totally_lazy 0.0.
|
5
|
+
# stub: totally_lazy 0.0.10 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "totally_lazy"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.10"
|
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 = ["Kingsley Hendrickse"]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2015-10-29"
|
15
15
|
s.description = "Port of java functional library totally lazy to ruby"
|
16
16
|
s.email = "kingsleyhendrickse@me.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
|
|
59
59
|
]
|
60
60
|
s.homepage = "http://github.com/kingsleyh/totally_lazy"
|
61
61
|
s.licenses = ["MIT"]
|
62
|
-
s.rubygems_version = "2.
|
62
|
+
s.rubygems_version = "2.4.6"
|
63
63
|
s.summary = "Port of java functional library totally lazy to ruby"
|
64
64
|
|
65
65
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: totally_lazy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kingsley Hendrickse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
version: '0'
|
202
202
|
requirements: []
|
203
203
|
rubyforge_project:
|
204
|
-
rubygems_version: 2.
|
204
|
+
rubygems_version: 2.4.6
|
205
205
|
signing_key:
|
206
206
|
specification_version: 4
|
207
207
|
summary: Port of java functional library totally lazy to ruby
|