datapipes 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +14 -13
- data/datapipes.gemspec +1 -0
- data/lib/datapipes/sink.rb +4 -1
- data/lib/datapipes/version.rb +1 -1
- data/lib/datapipes.rb +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffc7cfd9159486b30bc40027879b31fcf40ab87c
|
4
|
+
data.tar.gz: cf48ec612f2c42485caaee94d9699d1f5e55154d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccbbdcce3c53b5d31299a04416cd17949288e811c2cf5a6b86207af8f2e66ef4fec3e9695099aa280db55d68533a9a64400e3371a40fefca9af58fc6a0650174
|
7
|
+
data.tar.gz: 1743f71987fdbc62052204ebb5ce7868330fd41893752858f13ec313a3af148ddbbd8b69cab1bc6e0eab53c7f5c3684432db2f6e45501635a929bc08c55669f5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -25,24 +25,22 @@ To handle multi streamings, datapipes offers composabiliy. Source, Tube and Sink
|
|
25
25
|
are composable individually. So the diagram above will be:
|
26
26
|
|
27
27
|
```
|
28
|
-
Composed Source works
|
28
|
+
Composed Source works concurrently.
|
29
29
|
|
30
30
|
[Source Source Source]
|
31
31
|
|
|
32
|
-
| pipe handles asynchronous
|
32
|
+
| pipe handles asynchronous.
|
33
33
|
|
|
34
34
|
Tube
|
35
|
-
Tube Composed Tube has individual tube in series
|
35
|
+
Tube Composed Tube has individual tube in series.
|
36
36
|
Tube
|
37
37
|
Tube
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
|
42
|
-
Sink
|
43
|
-
Sink
|
41
|
+
[Sink Sink Sink]
|
44
42
|
|
45
|
-
Composed Sink works
|
43
|
+
Composed Sink works concurrently.
|
46
44
|
```
|
47
45
|
|
48
46
|
## Installation
|
@@ -81,7 +79,11 @@ Define `accept?` to recieve the data or skip this.
|
|
81
79
|
```ruby
|
82
80
|
class Triple < Datapipes::Tube
|
83
81
|
def run(data)
|
84
|
-
|
82
|
+
if accept? data
|
83
|
+
[data, data, data]
|
84
|
+
else
|
85
|
+
data
|
86
|
+
end
|
85
87
|
end
|
86
88
|
|
87
89
|
def accept?(data)
|
@@ -95,7 +97,7 @@ Sink consumes piped data. A typical sink is printing data.
|
|
95
97
|
```ruby
|
96
98
|
class Print < Datapipes::Sink
|
97
99
|
def run(data)
|
98
|
-
puts data
|
100
|
+
puts data if accept? data
|
99
101
|
end
|
100
102
|
|
101
103
|
def accept?(data)
|
@@ -108,10 +110,9 @@ You can make your own datapipe with your objects.
|
|
108
110
|
|
109
111
|
```ruby
|
110
112
|
datapipe = Datapipes.new(
|
111
|
-
List.new,
|
112
|
-
|
113
|
-
|
114
|
-
Datapipes::Pipe.new # A pipe
|
113
|
+
List.new, # A source
|
114
|
+
Print.new, # A sink
|
115
|
+
tube: Triple.new,
|
115
116
|
)
|
116
117
|
```
|
117
118
|
|
data/datapipes.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
+
spec.add_dependency 'parallel', '~> 1.0'
|
21
22
|
spec.add_development_dependency 'bundler', '~> 1.5'
|
22
23
|
spec.add_development_dependency 'rake'
|
23
24
|
spec.add_development_dependency 'rspec'
|
data/lib/datapipes/sink.rb
CHANGED
@@ -6,7 +6,10 @@ class Datapipes
|
|
6
6
|
# TODO: parallel
|
7
7
|
def run_all(data)
|
8
8
|
@accumulated ||= [self]
|
9
|
-
|
9
|
+
count = Parallel.processor_count
|
10
|
+
Parallel.each(@accumulated, in_threads: count) do |sink|
|
11
|
+
sink.run(data)
|
12
|
+
end
|
10
13
|
end
|
11
14
|
end
|
12
15
|
end
|
data/lib/datapipes/version.rb
CHANGED
data/lib/datapipes.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datapipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taiki ONO
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2014-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: parallel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|