datapipes 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/README.md +2 -2
- data/lib/datapipes/sink.rb +2 -2
- data/lib/datapipes/source.rb +2 -2
- data/lib/datapipes/tube.rb +4 -2
- data/lib/datapipes/version.rb +1 -1
- data/spec/composable_spec.rb +24 -0
- 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: 5da9524d54bee9ddd9316b41e8b0aae7a39b2515
|
4
|
+
data.tar.gz: bf301fe6740d050cb879137c47be2e0232b998e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 541820467ba42ecb78f51359554457c4e09dc7c5896e39ba784dcd52a83f26f750d3ddc8f3af4a6740ed7793f2e7a871e0efd935d62a1f2427ba9cf657139b65
|
7
|
+
data.tar.gz: a2378d84a6e3192a737c0dccabc2a19d6fce8d2653bcf96f56689fe8cf871d1fc4a8e998f5ba7727ec881b12dbc4adea34a4f7816f5c55c8fbae8a7048a880dd
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
datapipes [![Build Status](https://travis-ci.org/taiki45/datapipes.svg?branch=master)](https://travis-ci.org/taiki45/datapipes)
|
1
|
+
datapipes [![Build Status](https://travis-ci.org/taiki45/datapipes.svg?branch=master)](https://travis-ci.org/taiki45/datapipes) [![Gem Version](https://badge.fury.io/rb/datapipes.svg)](http://badge.fury.io/rb/datapipes) [![Code Climate](https://codeclimate.com/github/taiki45/datapipes.png)](https://codeclimate.com/github/taiki45/datapipes)
|
2
2
|
=========
|
3
3
|
datapipes is an asynchronous multi streaming library.
|
4
4
|
|
@@ -142,7 +142,7 @@ TODO...
|
|
142
142
|
|
143
143
|
## Contributing
|
144
144
|
|
145
|
-
1. Fork it ( http://github.com
|
145
|
+
1. Fork it ( http://github.com/taiki45/datapipes/fork )
|
146
146
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
147
147
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
148
148
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/datapipes/sink.rb
CHANGED
@@ -4,8 +4,8 @@ class Datapipes
|
|
4
4
|
include Composable
|
5
5
|
|
6
6
|
def run_all(data)
|
7
|
-
accumulated ||= [self]
|
8
|
-
accumulated.each {|sink| sink.run(data) if sink.accept? data }
|
7
|
+
@accumulated ||= [self]
|
8
|
+
@accumulated.each {|sink| sink.run(data) if sink.accept? data }
|
9
9
|
end
|
10
10
|
|
11
11
|
def accept?(data)
|
data/lib/datapipes/source.rb
CHANGED
data/lib/datapipes/tube.rb
CHANGED
@@ -3,10 +3,12 @@ class Datapipes
|
|
3
3
|
#
|
4
4
|
# Build your own tube logic in `run` method.
|
5
5
|
class Tube
|
6
|
+
include Composable
|
7
|
+
|
6
8
|
def run_all(data)
|
7
|
-
accumulated ||= [self]
|
9
|
+
@accumulated ||= [self]
|
8
10
|
|
9
|
-
accumulated.reduce(data) do |d, tube|
|
11
|
+
@accumulated.reduce(data) do |d, tube|
|
10
12
|
if tube.accept? d
|
11
13
|
tube.run(d)
|
12
14
|
else
|
data/lib/datapipes/version.rb
CHANGED
data/spec/composable_spec.rb
CHANGED
@@ -42,4 +42,28 @@ describe Datapipes::Composable do
|
|
42
42
|
expect(subject.exec).to eq [1, 5]
|
43
43
|
end
|
44
44
|
end
|
45
|
+
|
46
|
+
context 'with tube' do
|
47
|
+
let(:tube_a) do
|
48
|
+
Class.new(Datapipes::Tube) do
|
49
|
+
def run(data)
|
50
|
+
data + 2
|
51
|
+
end
|
52
|
+
end.new
|
53
|
+
end
|
54
|
+
|
55
|
+
let(:tube_b) do
|
56
|
+
Class.new(Datapipes::Tube) do
|
57
|
+
def run(data)
|
58
|
+
data * 3
|
59
|
+
end
|
60
|
+
end.new
|
61
|
+
end
|
62
|
+
|
63
|
+
subject { tube_a + tube_b }
|
64
|
+
|
65
|
+
it 'generates new tube' do
|
66
|
+
expect(subject.run_all(4)).to eq 18
|
67
|
+
end
|
68
|
+
end
|
45
69
|
end
|