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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7320f603074b6f0907667850275091622de079d
4
- data.tar.gz: f5c9b51dac1c2c63f7b8703ea7144eaecf5cee85
3
+ metadata.gz: ffc7cfd9159486b30bc40027879b31fcf40ab87c
4
+ data.tar.gz: cf48ec612f2c42485caaee94d9699d1f5e55154d
5
5
  SHA512:
6
- metadata.gz: 0b98bee8388e04ff8f841e9d9cd5f9f07fc3faaed18d2513630cb38b060fc2e9f9d46b64373d6275af06c657ba80891512ef32ea58d86111f907718a6c3ddf1e
7
- data.tar.gz: fdcd53dcc0be76ac8603bcf58a265753d496a60f0d45e5befef68a592a5cd4adf6957453134bc949dfb7123a083e5ab9617a97c97f0da92d2076b60797ba8937
6
+ metadata.gz: ccbbdcce3c53b5d31299a04416cd17949288e811c2cf5a6b86207af8f2e66ef4fec3e9695099aa280db55d68533a9a64400e3371a40fefca9af58fc6a0650174
7
+ data.tar.gz: 1743f71987fdbc62052204ebb5ce7868330fd41893752858f13ec313a3af148ddbbd8b69cab1bc6e0eab53c7f5c3684432db2f6e45501635a929bc08c55669f5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.1.2
2
+ - Sinks runs in parallel.
3
+
1
4
  ## 0.1.1
2
5
  - Drop Ruby 1.9 supports.
3
6
  - Tube and Pipe are optional in making datapipe.
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 asynchronously
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
- Sink
42
- Sink
43
- Sink
41
+ [Sink Sink Sink]
44
42
 
45
- Composed Sink works synchronously
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
- [data, data, data]
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, # A source
112
- Triple.new, # A tube
113
- Print.new, # A sink
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'
@@ -6,7 +6,10 @@ class Datapipes
6
6
  # TODO: parallel
7
7
  def run_all(data)
8
8
  @accumulated ||= [self]
9
- @accumulated.each {|sink| sink.run(data) }
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
@@ -1,3 +1,3 @@
1
1
  class Datapipes
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/lib/datapipes.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'parallel'
1
2
  require 'datapipes/composable'
2
3
  require 'datapipes/source'
3
4
  require 'datapipes/tube'
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.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