ddbuffer 1.0.0 → 1.0.1

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
- SHA1:
3
- metadata.gz: 18a7511205723f69c3f1975f528b5c7c77478cf7
4
- data.tar.gz: 4cbd691685cc43fb2f8cd7500647497871224a12
2
+ SHA256:
3
+ metadata.gz: aaa9bbb025759cb2843a1958a0a145ba5e6fd14970b12077da0eef7bfc0fc7e5
4
+ data.tar.gz: 29a34a8d792e38b08d23e70b36f4d3f9fff5ae193bf3192c98a35cd943a8cf84
5
5
  SHA512:
6
- metadata.gz: 4e436cecf19bdd288fa688bacd4b05ff0b46abb7e02c9e1082073102be4c7d516dcfbb584a65f7b455d077206e45febd00f50589fa3879e091ff5aa82c64cc93
7
- data.tar.gz: 228c9d71c3aee58d6206cd249a46d844bfeac8385dedf16f1e19b842257497f5c3597233c0f28963900c60bf18b3064fb3d897f2f5f6cbb8ef6720cdd177cbea
6
+ metadata.gz: 512e43cb24a634a925ad4bcab5f81ecf515025d03b293d642a9bb250981fcafdd2c077f8a558eff1fb373f69d43366fc149e9866ca490452d80802a45f615c71
7
+ data.tar.gz: c1ef5243c60cecd9de8fe06187fed2678498be28e546828846b571a9db6138c8ce7cd016c87c95c842757f83c2213f91d5e96081805733ed3aaded99900f2d7c
data/NEWS.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # DDBuffer release notes
2
2
 
3
+ ## 1.0.1 (2017-11-08)
4
+
5
+ Marked as deprecated in favor of slow_enumerator_tools (https://github.com/ddfreyne/slow_enumerator_tools).
6
+
3
7
  ## 1.0.0 (2017-10-21)
4
8
 
5
9
  No changes (first stable release).
data/README.md CHANGED
@@ -1,54 +1,15 @@
1
- [![Gem version](http://img.shields.io/gem/v/ddbuffer.svg)](http://rubygems.org/gems/ddbuffer)
2
- [![Build status](http://img.shields.io/travis/ddfreyne/ddbuffer.svg)](https://travis-ci.org/ddfreyne/ddbuffer)
3
- [![Code Climate](http://img.shields.io/codeclimate/github/ddfreyne/ddbuffer.svg)](https://codeclimate.com/github/ddfreyne/ddbuffer)
4
- [![Code Coverage](https://img.shields.io/codecov/c/github/ddfreyne/ddbuffer.svg)](https://codecov.io/gh/ddfreyne/ddbuffer)
5
-
6
1
  # DDBuffer
7
2
 
8
- Provides a way to buffer Ruby enumerables/enumerators.
3
+ **Deprecated** in favor of [slow_enumerator_tools](https://github.com/ddfreyne/slow_enumerator_tools).
9
4
 
10
- This is particularly useful when reading from a slow source and reading to a slow sink, because the two will be able to work concurrently. For example:
5
+ Replace
11
6
 
12
7
  ```ruby
13
- # Read articles (an Enumerator)
14
- articles = my_web_service.each_article
15
-
16
- # Buffer 100 articles at a time
17
- articles = DDBuffer.new(100).call(articles)
18
-
19
- # Write buffered articles
20
- articles.each_slice(50) do |slice|
21
- my_slow_db.insert_articles(slice)
22
- end
8
+ DDBuffer.new(size).call(enum)
23
9
  ```
24
10
 
25
- ## Usage
26
-
27
- To install, add the `ddbuffer` gem to your Gemfile, and run `bundle`.
28
-
29
- To buffer an enumerable `enum` with a buffer size of `size`:
11
+ with
30
12
 
31
13
  ```ruby
32
- buffered_enum = DDBuffer.new(size).call(enum)
33
- ```
34
-
35
- ## Development
36
-
37
- To run the tests:
38
-
39
- ```
40
- bundle install
41
- bundle exec rake
14
+ SlowEnumeratorTools.buffer(enum, size)
42
15
  ```
43
-
44
- ## Contributing
45
-
46
- Bug reports and pull requests are welcome on GitHub at https://github.com/ddfreyne/ddbuffer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
47
-
48
- ## License
49
-
50
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
51
-
52
- ## Code of Conduct
53
-
54
- Everyone interacting in the DDBuffer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ddfreyne/ddbuffer/blob/master/CODE_OF_CONDUCT.md).
@@ -15,5 +15,6 @@ Gem::Specification.new do |spec|
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
16
  spec.require_paths = ['lib']
17
17
 
18
+ spec.add_runtime_dependency 'slow_enumerator_tools', '~> 1.1'
18
19
  spec.add_development_dependency 'bundler', '~> 1.15'
19
20
  end
@@ -2,48 +2,14 @@
2
2
 
3
3
  require 'ddbuffer/version'
4
4
 
5
- class DDBuffer
6
- module Impl
7
- STOP_OK = Object.new
8
- STOP_ERR = Object.new
9
-
10
- def self.gen_collector_thread(enum, queue)
11
- Thread.new do
12
- begin
13
- enum.each { |e| queue << e }
14
- queue << STOP_OK
15
- rescue StandardError => e
16
- queue << STOP_ERR
17
- queue << e
18
- end
19
- end
20
- end
21
-
22
- def self.gen_enumerator(queue, collector_thread)
23
- Enumerator.new do |y|
24
- loop do
25
- e = queue.pop
26
-
27
- if STOP_OK.equal?(e)
28
- break
29
- elsif STOP_ERR.equal?(e)
30
- raise queue.pop
31
- end
32
-
33
- y << e
34
- end
35
- collector_thread.join
36
- end.lazy
37
- end
38
- end
5
+ require 'slow_enumerator_tools'
39
6
 
7
+ class DDBuffer
40
8
  def initialize(size)
41
9
  @size = size
42
10
  end
43
11
 
44
12
  def call(enum)
45
- queue = SizedQueue.new(@size)
46
- thread = Impl.gen_collector_thread(enum, queue)
47
- Impl.gen_enumerator(queue, thread)
13
+ SlowEnumeratorTools.buffer(enum, @size)
48
14
  end
49
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class DDBuffer
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddbuffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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-21 00:00:00.000000000 Z
11
+ date: 2017-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: slow_enumerator_tools
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
81
  version: '0'
68
82
  requirements: []
69
83
  rubyforge_project:
70
- rubygems_version: 2.6.14
84
+ rubygems_version: 2.7.1
71
85
  signing_key:
72
86
  specification_version: 4
73
87
  summary: Buffer enumerables