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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33dc358ef4d7c116477605b28b24a83c6a9f902a
4
- data.tar.gz: 91ac07dd9c7f7ed253c80aa3a638ba600cb2c0a0
3
+ metadata.gz: 5cecaee8660e212274a61072f434341d20318afd
4
+ data.tar.gz: 953e06c5e5beb1bca606f7a6c95ab399d7967a46
5
5
  SHA512:
6
- metadata.gz: 395e9429d2ddddf3367cb2ff35d64b1f0d5456ffad14f7c41e0679206c9c4a85fb7a46b93af08d14088755c22cd693d8c0b7b302f59c2e2c7e852615a0828685
7
- data.tar.gz: 92b0eaf5eef204f3612f1069e8c8c7facdbcb6f468b542a9516d0042c5d84dd22f84b203e8e525a2434caf34db84e07d3ca3726526bc52622fcbf48fd63af8e8
6
+ metadata.gz: e41bd66e2621550a7132d7b8e4f092a713cc6cab2cae3d29e4cd9b0f230d03bd914e5396bc5cfd070b446c06a37dafaa29dab322175234ee0221f68769171542
7
+ data.tar.gz: ed7b14c899dba6e8c9ccc5b1142017f69b37bc5271867299ea06822a453fd0c4b111ca8141ae7b6db5c1844d87eb91a472b84f9c080e970e85a4f068fbb8ee55
@@ -56,3 +56,7 @@ Metrics/PerceivedComplexity:
56
56
  # It does not make sense to enforce everything to have documentation.
57
57
  Style/Documentation:
58
58
  Enabled: false
59
+
60
+ # This does not always make sense
61
+ Style/GuardClause:
62
+ Enabled: false
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  group :devel do
8
+ gem 'codecov', require: false
8
9
  gem 'fuubar'
9
10
  gem 'pry'
10
11
  gem 'rake'
data/NEWS.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # SlowEnumeratorTools news
2
2
 
3
+ ## 1.0.0 (2017-10-21)
4
+
5
+ Changes:
6
+
7
+ * Renamed buffer to batch
8
+
3
9
  ## 1.0.0a1 (2017-10-08)
4
10
 
5
11
  Initial release.
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.buffer`: given an enumerable, creates a new enumerable that yields batches containing all elements currently available.
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.buffer`
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
- # Buffer
82
- buffer_enum = SlowEnumeratorTools.buffer(enum)
81
+ # Batch
82
+ batch_enum = SlowEnumeratorTools.batch(enum)
83
83
 
84
84
  # Wait until first batch is available
85
85
  # … prints [0]
86
- p buffer_enum.next
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 buffer_enum.next
91
+ p batch_enum.next
92
92
 
93
93
  # Wait until final batch is available
94
94
  # … prints [3]
95
- p buffer_enum.next
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.buffer(es)
9
- SlowEnumeratorTools::Bufferer.buffer(es)
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/bufferer'
14
+ require_relative 'slow_enumerator_tools/batcher'
15
15
  require_relative 'slow_enumerator_tools/merger'
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SlowEnumeratorTools
4
- module Bufferer
5
- def self.buffer(enum)
4
+ module Batcher
5
+ def self.batch(enum)
6
6
  q = Queue.new
7
7
  stop = Object.new
8
8
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SlowEnumeratorTools
4
- VERSION = '1.0.0a1'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -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
- $stderr.puts 'Answer was not Y; release aborted.'
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
- $stderr.puts 'Answer was not Y; release aborted.'
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
- $stderr.puts 'No proper release date found!'
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
- $stderr.puts 'Release already exists!'
60
- $stderr.puts 'ABORTED!'
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::Bufferer do
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.buffer(wrapped)
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 .buffer shorthand' do
14
- expect(SlowEnumeratorTools.buffer([1, 2]).to_a)
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
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ require 'codecov'
7
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
8
+
3
9
  require 'slow_enumerator_tools'
4
10
 
5
11
  require 'fuubar'
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.0a1
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-08 00:00:00.000000000 Z
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/bufferer.rb
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/bufferer_spec.rb
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: 1.3.1
71
+ version: '0'
72
72
  requirements: []
73
73
  rubyforge_project:
74
- rubygems_version: 2.6.13
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