pull_stream 1.0.0
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 +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +120 -0
- data/Rakefile +6 -0
- data/lib/pull.rb +38 -0
- data/lib/pull/helper.rb +37 -0
- data/lib/pull/sink/collect.rb +28 -0
- data/lib/pull/sink/drain.rb +29 -0
- data/lib/pull/sink/log.rb +16 -0
- data/lib/pull/sink/reduce.rb +26 -0
- data/lib/pull/source/infinity.rb +26 -0
- data/lib/pull/source/values.rb +46 -0
- data/lib/pull/through/filter.rb +27 -0
- data/lib/pull/through/map.rb +26 -0
- data/lib/pull/through/take.rb +25 -0
- data/lib/pull/version.rb +3 -0
- data/pull_stream.gemspec +37 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 27794f863308351d25448a43ee44c0fa158a2740
|
4
|
+
data.tar.gz: 518bcddb9fc1d33c96136cd10a9711eda4a0f7e1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c3f21bcc1a1bbfdc40c9c9731a6a5b8ebe91fc281f2d72b864f46d282637b12ac70defc2b543eb5695de893509d20e9ca66b4853a786948c35d1445843a49958
|
7
|
+
data.tar.gz: 8f64b2481efaf3a74c3f081dcde8b182c6aa01abb109f979ea1662c6436f4c7f19fe73d22b9710068f25855838cbcafdbf6d357bc1b002ce81c7d06157214b78
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at kieran.a.gibb@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Kieran
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# Ruby Pull Stream
|
2
|
+
|
3
|
+
A minimal pull based data streaming client for Ruby.
|
4
|
+
|
5
|
+

|
6
|
+
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'pull_stream'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install pull_stream
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
In classic-streams, streams _push_ data to the next stream in the pipeline. With pull streams, data is pulled out of the source stream, into the destination. `pull_stream` is a Ruby implementation of a Javascript module [pull-stream](https://github.com/pull-stream/pull-stream) used by the [Scuttlebutt](http://scuttlebutt.nz/) community. It has been built as a means to improve my knowledge of pull-streams in Node. It may prove to be useful in Ruby though I am yet to conceive of an application.
|
27
|
+
|
28
|
+
`pull_stream` opens up a `pull` method that takes any number of arguments. The first must be a _source_. The last must be a _sink_. Any number of _through_'s can be added in the middle.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
pull(
|
32
|
+
source,
|
33
|
+
map,
|
34
|
+
filter,
|
35
|
+
take,
|
36
|
+
sink
|
37
|
+
)
|
38
|
+
```
|
39
|
+
|
40
|
+
Simply include the `Pull` module into any class and begin pulling streams
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
include Pull
|
44
|
+
|
45
|
+
ducks = ["Alice the Duck", "Gary the Gopher", "Bob the Duck", "Grace the Duck", "Elvis the Duck"]
|
46
|
+
|
47
|
+
pull(
|
48
|
+
pull.values(ducks),
|
49
|
+
# Lets objectify our ducks
|
50
|
+
pull.map do |duck|
|
51
|
+
name, type = duck.split(" the ")
|
52
|
+
OpenStruct.new(name: name, type: type)
|
53
|
+
end,
|
54
|
+
# Lets make sure we've only got ducks, this filters out Gary, sorry Gary
|
55
|
+
pull.filter { |duck| duck.type == "Duck" },
|
56
|
+
# Turns out these ducks are actually Pochards
|
57
|
+
pull.map do |duck|
|
58
|
+
duck.tap { |d| d.type = "Pochard" }
|
59
|
+
end,
|
60
|
+
# Spit out each duck one at a time...
|
61
|
+
pull.drain do |duck|
|
62
|
+
puts duck
|
63
|
+
end
|
64
|
+
)
|
65
|
+
|
66
|
+
#<OpenStruct name="Alice", type="Pochard">
|
67
|
+
#<OpenStruct name="Bob", type="Pochard">
|
68
|
+
#<OpenStruct name="Grace", type="Pochard">
|
69
|
+
#<OpenStruct name="Elvis", type="Pochard">
|
70
|
+
```
|
71
|
+
|
72
|
+
If a _sink_ is not provided, pull returns itself as a source, and can be used in another pull stream.
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
source = pull(
|
76
|
+
pull.values([1, 2, 3, 4, 5]),
|
77
|
+
pull.map { |value| value ** 2 }
|
78
|
+
)
|
79
|
+
|
80
|
+
pull(
|
81
|
+
source,
|
82
|
+
# Apply more throughs and a sink
|
83
|
+
)
|
84
|
+
```
|
85
|
+
|
86
|
+
### Pull Stream's API
|
87
|
+
|
88
|
+
```
|
89
|
+
pull.values # source
|
90
|
+
pull.keys # source
|
91
|
+
pull.infinity # source
|
92
|
+
|
93
|
+
pull.map # through
|
94
|
+
pull.filter # through
|
95
|
+
pull.take # through
|
96
|
+
|
97
|
+
pull.drain # sink
|
98
|
+
pull.collect # sink
|
99
|
+
pull.log # sink
|
100
|
+
pull.reduce # sink
|
101
|
+
```
|
102
|
+
|
103
|
+
|
104
|
+
## Development
|
105
|
+
|
106
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
107
|
+
|
108
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
109
|
+
|
110
|
+
## Contributing
|
111
|
+
|
112
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kgibb8/ruby_pull_stream. 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.
|
113
|
+
|
114
|
+
## License
|
115
|
+
|
116
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
117
|
+
|
118
|
+
## Code of Conduct
|
119
|
+
|
120
|
+
Everyone interacting in the Pull Stream project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pull/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/lib/pull.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pull/version"
|
4
|
+
|
5
|
+
require "pull/source/values"
|
6
|
+
require "pull/source/infinity"
|
7
|
+
|
8
|
+
require "pull/through/map"
|
9
|
+
require "pull/through/filter"
|
10
|
+
require "pull/through/take"
|
11
|
+
|
12
|
+
require "pull/sink/drain"
|
13
|
+
require "pull/sink/collect"
|
14
|
+
require "pull/sink/log"
|
15
|
+
require "pull/sink/reduce"
|
16
|
+
|
17
|
+
require "pull/helper"
|
18
|
+
|
19
|
+
module Pull
|
20
|
+
def pull(*args)
|
21
|
+
return Pull::Helper.new if args.empty?
|
22
|
+
recurse(nil, args)
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def recurse(streamer, args)
|
29
|
+
return if args.empty?
|
30
|
+
arg = args.shift
|
31
|
+
raise TypeError unless arg.respond_to?(:call)
|
32
|
+
|
33
|
+
recurse(
|
34
|
+
streamer.nil? ? arg.() : arg.(streamer),
|
35
|
+
args
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
data/lib/pull/helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pull
|
4
|
+
class Helper
|
5
|
+
def values(args)
|
6
|
+
Pull::Values.new(args)
|
7
|
+
end
|
8
|
+
|
9
|
+
def infinity
|
10
|
+
Pull::Infinity.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def drain(&block)
|
14
|
+
Pull::Drain.new(&block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def collect(&block)
|
18
|
+
Pull::Collect.new(&block)
|
19
|
+
end
|
20
|
+
|
21
|
+
def map(&block)
|
22
|
+
Pull::Map.new(&block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def filter(&block)
|
26
|
+
Pull::Filter.new(&block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def take(limit)
|
30
|
+
Pull::Take.new(limit)
|
31
|
+
end
|
32
|
+
|
33
|
+
def log
|
34
|
+
Pull::Log.new
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pull
|
4
|
+
class Collect
|
5
|
+
DEFAULT_DONE_CALLBACK = -> () {
|
6
|
+
puts "DONE"
|
7
|
+
}
|
8
|
+
|
9
|
+
def initialize(&block)
|
10
|
+
@block = block
|
11
|
+
@collection = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(read, done = DEFAULT_DONE_CALLBACK)
|
15
|
+
raise TypeError unless read.respond_to?(:call)
|
16
|
+
drained = Pull::Drain.new do |value|
|
17
|
+
@collection << value
|
18
|
+
end
|
19
|
+
drained.(read)
|
20
|
+
block.call(@collection)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :block
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pull
|
4
|
+
class Drain
|
5
|
+
DEFAULT_DONE_CALLBACK = -> () {
|
6
|
+
puts "DONE"
|
7
|
+
}
|
8
|
+
|
9
|
+
def initialize(&block)
|
10
|
+
@block = block
|
11
|
+
@continuing = true
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(read, done = DEFAULT_DONE_CALLBACK)
|
15
|
+
raise TypeError unless read.respond_to?(:call)
|
16
|
+
while @continuing
|
17
|
+
return done.() && break if !@continuing
|
18
|
+
@continuing = read.(nil, -> (value) {
|
19
|
+
block.call(value)
|
20
|
+
})
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :block
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pull
|
4
|
+
class Log
|
5
|
+
DEFAULT_DONE_CALLBACK = -> () {
|
6
|
+
puts "DONE"
|
7
|
+
}
|
8
|
+
|
9
|
+
def call(read, done = DEFAULT_DONE_CALLBACK)
|
10
|
+
raise TypeError unless read.respond_to?(:call)
|
11
|
+
Pull::Drain.new do |value|
|
12
|
+
puts value
|
13
|
+
end.(read)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pull
|
4
|
+
class Reduce
|
5
|
+
DEFAULT_DONE_CALLBACK = -> () {
|
6
|
+
puts "DONE"
|
7
|
+
}
|
8
|
+
|
9
|
+
def initialize(accumulator, &block)
|
10
|
+
@accumulator = accumulator
|
11
|
+
@block = block
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(read, done = DEFAULT_DONE_CALLBACK)
|
15
|
+
raise TypeError unless read.respond_to?(:call)
|
16
|
+
drained = Pull::Drain.new do |value|
|
17
|
+
@accumulator = block.call(@accumulator, value)
|
18
|
+
end
|
19
|
+
drained.(read)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :block
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pull
|
4
|
+
class Infinity
|
5
|
+
DEFAULT_ABORT_PROC = -> () {
|
6
|
+
puts "abort abort"
|
7
|
+
}
|
8
|
+
|
9
|
+
def initialize(on_abort = DEFAULT_ABORT_PROC)
|
10
|
+
@index = 0
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
-> (finish, callback) {
|
15
|
+
if finish
|
16
|
+
on_abort.()
|
17
|
+
return nil
|
18
|
+
end
|
19
|
+
|
20
|
+
callback.(@index)
|
21
|
+
@index += 1
|
22
|
+
return true
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pull
|
4
|
+
class Values
|
5
|
+
DEFAULT_ABORT_PROC = -> () {
|
6
|
+
puts "abort abort"
|
7
|
+
}
|
8
|
+
|
9
|
+
def initialize(array, on_abort = DEFAULT_ABORT_PROC)
|
10
|
+
array = objectify(array) unless array.kind_of?(Array)
|
11
|
+
|
12
|
+
@array = array
|
13
|
+
@index = 0
|
14
|
+
@on_abort = on_abort
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
-> (finish, callback) {
|
19
|
+
if finish
|
20
|
+
on_abort.()
|
21
|
+
return nil
|
22
|
+
end
|
23
|
+
|
24
|
+
return false if !array[@index]
|
25
|
+
|
26
|
+
callback.(array[@index])
|
27
|
+
@index += 1
|
28
|
+
return true
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :array, :on_abort
|
35
|
+
|
36
|
+
def objectify(object)
|
37
|
+
if object.kind_of?(Hash)
|
38
|
+
object.map { |k, v| v }
|
39
|
+
else
|
40
|
+
object.pretty_print_instance_variables.inject([]) do |coll, iv|
|
41
|
+
coll << object.instance_variable_get(iv)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pull
|
4
|
+
class Filter
|
5
|
+
def initialize(&block)
|
6
|
+
@block = block
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(read)
|
10
|
+
-> (finish, callback) {
|
11
|
+
if finish
|
12
|
+
on_abort.()
|
13
|
+
return nil
|
14
|
+
end
|
15
|
+
|
16
|
+
read.(nil, -> (value) {
|
17
|
+
pass = block.call(value)
|
18
|
+
callback.(value) if pass
|
19
|
+
})
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :block
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pull
|
4
|
+
class Map
|
5
|
+
def initialize(&block)
|
6
|
+
@block = block
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(read)
|
10
|
+
-> (finish, callback) {
|
11
|
+
if finish
|
12
|
+
on_abort.()
|
13
|
+
return nil
|
14
|
+
end
|
15
|
+
|
16
|
+
read.(nil, -> (value) {
|
17
|
+
callback.(block.call(value))
|
18
|
+
})
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :block
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pull
|
4
|
+
class Take
|
5
|
+
def initialize(limit)
|
6
|
+
@limit = limit
|
7
|
+
@index = 0
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(read)
|
11
|
+
-> (finish, callback) {
|
12
|
+
if finish
|
13
|
+
on_abort.()
|
14
|
+
return nil
|
15
|
+
end
|
16
|
+
|
17
|
+
read.(nil, -> (value) {
|
18
|
+
return nil if @index >= @limit
|
19
|
+
callback.(value)
|
20
|
+
@index += 1
|
21
|
+
})
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/pull/version.rb
ADDED
data/pull_stream.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "pull/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pull_stream"
|
8
|
+
spec.version = Pull::VERSION
|
9
|
+
spec.authors = ["Kieran"]
|
10
|
+
spec.email = ["kieran@tenthousandthings.org.uk"]
|
11
|
+
|
12
|
+
spec.summary = %q{A minimal pull based data streaming client}
|
13
|
+
spec.description = %q{A minimal pull based data streaming client}
|
14
|
+
spec.homepage = "https://ruby-pull-stream.github.io"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_development_dependency "pry-byebug"
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pull_stream
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kieran
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A minimal pull based data streaming client
|
70
|
+
email:
|
71
|
+
- kieran@tenthousandthings.org.uk
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CODE_OF_CONDUCT.md
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- lib/pull.rb
|
85
|
+
- lib/pull/helper.rb
|
86
|
+
- lib/pull/sink/collect.rb
|
87
|
+
- lib/pull/sink/drain.rb
|
88
|
+
- lib/pull/sink/log.rb
|
89
|
+
- lib/pull/sink/reduce.rb
|
90
|
+
- lib/pull/source/infinity.rb
|
91
|
+
- lib/pull/source/values.rb
|
92
|
+
- lib/pull/through/filter.rb
|
93
|
+
- lib/pull/through/map.rb
|
94
|
+
- lib/pull/through/take.rb
|
95
|
+
- lib/pull/version.rb
|
96
|
+
- pull_stream.gemspec
|
97
|
+
homepage: https://ruby-pull-stream.github.io
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
metadata:
|
101
|
+
allowed_push_host: https://rubygems.org
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 2.6.8
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: A minimal pull based data streaming client
|
122
|
+
test_files: []
|