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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b69f0bd0a67b11610394bb01fe5d5e3dccb5da8b
4
- data.tar.gz: 1f171ea4c6f63989795bfb1cb22da5cbbb732cc5
3
+ metadata.gz: 5da9524d54bee9ddd9316b41e8b0aae7a39b2515
4
+ data.tar.gz: bf301fe6740d050cb879137c47be2e0232b998e3
5
5
  SHA512:
6
- metadata.gz: b283617335d62edffd27f34c69deca578481788e381766f9dc54adbc7742495bffa7f132c0b769f79c922d660b4e775744e6c8b14e87cc619deefc96e34a51e5
7
- data.tar.gz: a1cfdeadae7ba85c47cc2c2cbbdb1ff2b594e186bd0391913a546ec0b0e8ceadf175d632856b7bce74403050088dc7b3e52707a127f58df3481d719ae38d6e12
6
+ metadata.gz: 541820467ba42ecb78f51359554457c4e09dc7c5896e39ba784dcd52a83f26f750d3ddc8f3af4a6740ed7793f2e7a871e0efd935d62a1f2427ba9cf657139b65
7
+ data.tar.gz: a2378d84a6e3192a737c0dccabc2a19d6fce8d2653bcf96f56689fe8cf871d1fc4a8e998f5ba7727ec881b12dbc4adea34a4f7816f5c55c8fbae8a7048a880dd
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
3
+ - 2.1
4
+ - 2.0
4
5
  - 1.9.3
5
6
  branches:
6
7
  only:
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/<my-github-username>/datapipes/fork )
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`)
@@ -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)
@@ -13,8 +13,8 @@ class Datapipes
13
13
  attr_accessor :pipe
14
14
 
15
15
  def run_all
16
- accumulated ||= [self]
17
- accumulated.map {|s| Thread.new { s.run } }
16
+ @accumulated ||= [self]
17
+ @accumulated.map {|s| Thread.new { s.run } }
18
18
  end
19
19
 
20
20
  private
@@ -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
@@ -1,3 +1,3 @@
1
1
  class Datapipes
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -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
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.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taiki ONO