slow_enumerator_tools 1.0.0a1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/Gemfile +1 -0
- data/NEWS.md +6 -0
- data/README.md +7 -7
- data/lib/slow_enumerator_tools.rb +3 -3
- data/lib/slow_enumerator_tools/{bufferer.rb → batcher.rb} +2 -2
- data/lib/slow_enumerator_tools/version.rb +1 -1
- data/scripts/release +5 -5
- data/spec/{bufferer_spec.rb → batcher_spec.rb} +2 -2
- data/spec/slow_enumerator_tools_spec.rb +2 -2
- data/spec/spec_helper.rb +6 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cecaee8660e212274a61072f434341d20318afd
|
4
|
+
data.tar.gz: 953e06c5e5beb1bca606f7a6c95ab399d7967a46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e41bd66e2621550a7132d7b8e4f092a713cc6cab2cae3d29e4cd9b0f230d03bd914e5396bc5cfd070b446c06a37dafaa29dab322175234ee0221f68769171542
|
7
|
+
data.tar.gz: ed7b14c899dba6e8c9ccc5b1142017f69b37bc5271867299ea06822a453fd0c4b111ca8141ae7b6db5c1844d87eb91a472b84f9c080e970e85a4f068fbb8ee55
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/NEWS.md
CHANGED
data/README.md
CHANGED
@@ -10,7 +10,7 @@ _SlowEnumeratorTools_ provides tools for transforming Ruby enumerators that prod
|
|
10
10
|
|
11
11
|
* `SlowEnumeratorTools.merge`: given a collection of enumerables, creates a new enumerator that yields elements from any of these enumerables as soon as they become available.
|
12
12
|
|
13
|
-
* `SlowEnumeratorTools.
|
13
|
+
* `SlowEnumeratorTools.batch`: given an enumerable, creates a new enumerable that yields batches containing all elements currently available.
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
@@ -68,7 +68,7 @@ Example output:
|
|
68
68
|
[:a, 4]
|
69
69
|
```
|
70
70
|
|
71
|
-
### `SlowEnumeratorTools.
|
71
|
+
### `SlowEnumeratorTools.batch`
|
72
72
|
|
73
73
|
Given an enumerable, creates a new enumerable that yields batches containing all elements currently available.
|
74
74
|
|
@@ -78,21 +78,21 @@ This is useful for fetching all outstanding events on an event stream, without b
|
|
78
78
|
# Generate a slow enum
|
79
79
|
enum = 4.times.lazy.map { |i| sleep(0.1); i }
|
80
80
|
|
81
|
-
#
|
82
|
-
|
81
|
+
# Batch
|
82
|
+
batch_enum = SlowEnumeratorTools.batch(enum)
|
83
83
|
|
84
84
|
# Wait until first batch is available
|
85
85
|
# … prints [0]
|
86
|
-
p
|
86
|
+
p batch_enum.next
|
87
87
|
|
88
88
|
# Give it enough time for the second batch to have accumulated more elements,
|
89
89
|
# … prints [1, 2]
|
90
90
|
sleep 0.25
|
91
|
-
p
|
91
|
+
p batch_enum.next
|
92
92
|
|
93
93
|
# Wait until final batch is available
|
94
94
|
# … prints [3]
|
95
|
-
p
|
95
|
+
p batch_enum.next
|
96
96
|
```
|
97
97
|
|
98
98
|
## Development
|
@@ -5,11 +5,11 @@ module SlowEnumeratorTools
|
|
5
5
|
SlowEnumeratorTools::Merger.merge(es)
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.
|
9
|
-
SlowEnumeratorTools::
|
8
|
+
def self.batch(es)
|
9
|
+
SlowEnumeratorTools::Batcher.batch(es)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
require_relative 'slow_enumerator_tools/version'
|
14
|
-
require_relative 'slow_enumerator_tools/
|
14
|
+
require_relative 'slow_enumerator_tools/batcher'
|
15
15
|
require_relative 'slow_enumerator_tools/merger'
|
data/scripts/release
CHANGED
@@ -10,7 +10,7 @@ def run(*args)
|
|
10
10
|
print 'Is this correct? [y/N] '
|
11
11
|
res = gets
|
12
12
|
unless res.strip.casecmp('y').zero?
|
13
|
-
|
13
|
+
warn 'Answer was not Y; release aborted.'
|
14
14
|
exit 1
|
15
15
|
end
|
16
16
|
|
@@ -20,7 +20,7 @@ def run(*args)
|
|
20
20
|
print 'Continue? [y/N] '
|
21
21
|
res = gets
|
22
22
|
unless res.strip.casecmp('y').zero?
|
23
|
-
|
23
|
+
warn 'Answer was not Y; release aborted.'
|
24
24
|
exit 1
|
25
25
|
end
|
26
26
|
end
|
@@ -38,7 +38,7 @@ puts
|
|
38
38
|
|
39
39
|
puts '=== Verifying presence of release date…'
|
40
40
|
unless File.readlines('NEWS.md').drop(2).first =~ / \(\d{4}-\d{2}-\d{2}\)$/
|
41
|
-
|
41
|
+
warn 'No proper release date found!'
|
42
42
|
exit 1
|
43
43
|
end
|
44
44
|
puts
|
@@ -56,8 +56,8 @@ puts '=== Verifying that release does not yet exist…'
|
|
56
56
|
releases = client.releases('ddfreyne/slow_enumerator_tools')
|
57
57
|
release = releases.find { |r| r.tag_name == SlowEnumeratorTools::VERSION }
|
58
58
|
if release
|
59
|
-
|
60
|
-
|
59
|
+
warn 'Release already exists!'
|
60
|
+
warn 'ABORTED!'
|
61
61
|
exit 1
|
62
62
|
end
|
63
63
|
puts
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
describe SlowEnumeratorTools::
|
3
|
+
describe SlowEnumeratorTools::Batcher do
|
4
4
|
let(:wrapped) do
|
5
5
|
Enumerator.new do |y|
|
6
6
|
5.times do |i|
|
@@ -11,7 +11,7 @@ describe SlowEnumeratorTools::Bufferer do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
subject do
|
14
|
-
described_class.
|
14
|
+
described_class.batch(wrapped)
|
15
15
|
end
|
16
16
|
|
17
17
|
example do
|
@@ -10,8 +10,8 @@ describe SlowEnumeratorTools do
|
|
10
10
|
.to match_array([1, 2, 3, 4])
|
11
11
|
end
|
12
12
|
|
13
|
-
it 'supports .
|
14
|
-
expect(SlowEnumeratorTools.
|
13
|
+
it 'supports .batch shorthand' do
|
14
|
+
expect(SlowEnumeratorTools.batch([1, 2]).to_a)
|
15
15
|
.to match_array([[1, 2]])
|
16
16
|
end
|
17
17
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slow_enumerator_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,12 +42,12 @@ files:
|
|
42
42
|
- README.md
|
43
43
|
- Rakefile
|
44
44
|
- lib/slow_enumerator_tools.rb
|
45
|
-
- lib/slow_enumerator_tools/
|
45
|
+
- lib/slow_enumerator_tools/batcher.rb
|
46
46
|
- lib/slow_enumerator_tools/merger.rb
|
47
47
|
- lib/slow_enumerator_tools/version.rb
|
48
48
|
- scripts/release
|
49
49
|
- slow_enumerator_tools.gemspec
|
50
|
-
- spec/
|
50
|
+
- spec/batcher_spec.rb
|
51
51
|
- spec/merger_spec.rb
|
52
52
|
- spec/slow_enumerator_tools_spec.rb
|
53
53
|
- spec/spec_helper.rb
|
@@ -66,12 +66,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: '0'
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- - "
|
69
|
+
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
71
|
+
version: '0'
|
72
72
|
requirements: []
|
73
73
|
rubyforge_project:
|
74
|
-
rubygems_version: 2.6.
|
74
|
+
rubygems_version: 2.6.14
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
77
|
summary: provides tools for transforming Ruby enumerators that produce data slowly
|