totally_lazy 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/VERSION +1 -1
- data/lib/pair.rb +1 -1
- data/lib/sequence.rb +3 -3
- data/spec/sequence_spec.rb +2 -2
- data/totally_lazy.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3229a338c39916c91506f35facbbfb43f2c95147
|
4
|
+
data.tar.gz: c4f0b6ffa654e6360b0dc57268b17329b1ccdfed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bea2ee197eddc5241277684ed67678c757a31256e261b5d488d876df66a54e42be56e6ec04ada9c5e414e4261ee6f0b090aa12691c1e74533e334500cd9c4541
|
7
|
+
data.tar.gz: 6dd14258d2aecb4081a33ae6fc6086144fd9d798807abed81a557ba642cf346a02ca311788bf5606b799d8152fdb0d18c22956f914be015b2bbc551805eb62df
|
data/README.md
CHANGED
@@ -53,6 +53,11 @@ sequence(1, 2, 3, 4, 5).filter(where(is greater_than 2).and(is odd)) # lazily re
|
|
53
53
|
sequence(pair(1, 2), pair(3, 4)).filter(where(key:odd)) # lazily returns 1,3
|
54
54
|
```
|
55
55
|
|
56
|
+
#### Sequences
|
57
|
+
|
58
|
+
* sequence wraps whatever is passed without modification - e.g. sequence([1,2,3]).head returns the array [1,2,3]
|
59
|
+
* sequence1 modifies what is passed if it's a single item - e.g. sequence1([1,2,3]).head returns the first element of 1
|
60
|
+
|
56
61
|
#### Generators
|
57
62
|
|
58
63
|
There are 2 types of generators:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.14
|
data/lib/pair.rb
CHANGED
data/lib/sequence.rb
CHANGED
@@ -44,7 +44,7 @@ module Sequences
|
|
44
44
|
# end
|
45
45
|
# end
|
46
46
|
|
47
|
-
def
|
47
|
+
def sequence1(*items)
|
48
48
|
if items.size == 1
|
49
49
|
if [Range, Hash, Array, Set].include?(items.first.class)
|
50
50
|
Sequence.new(items.first)
|
@@ -57,7 +57,7 @@ module Sequences
|
|
57
57
|
Sequence.new(items)
|
58
58
|
end
|
59
59
|
end
|
60
|
-
module_function :
|
60
|
+
module_function :sequence1
|
61
61
|
|
62
62
|
def sequence(*items)
|
63
63
|
if items.first.nil?
|
@@ -82,7 +82,7 @@ module Sequences
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def deserialize(data)
|
85
|
-
|
85
|
+
sequence1(data).deserialize
|
86
86
|
end
|
87
87
|
|
88
88
|
class Sequence < Enumerator
|
data/spec/sequence_spec.rb
CHANGED
@@ -42,7 +42,7 @@ describe 'Sequence' do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should lazily shuffle the elements - throws NoSuchElementException if empty' do
|
45
|
-
expect(
|
45
|
+
expect(sequence1(1..50).shuffle.entries).not_to eq(sequence1(1..50).entries)
|
46
46
|
expect { empty.shuffle.first }.to raise_error(NoSuchElementException)
|
47
47
|
end
|
48
48
|
|
@@ -214,7 +214,7 @@ describe 'Sequence' do
|
|
214
214
|
end
|
215
215
|
|
216
216
|
it 'should convert sequence to a map' do
|
217
|
-
expect(
|
217
|
+
expect(sequence1(oops('apple',1,'pear',2)).to_map).to eq({apple:1,pear:2})
|
218
218
|
end
|
219
219
|
|
220
220
|
def oops(*values)
|
data/totally_lazy.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.14 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.14"
|
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"]
|