stages 0.2.2 → 0.2.3
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.
- data/VERSION +1 -1
- data/lib/stages/wrap.rb +8 -2
- data/stages.gemspec +2 -2
- data/test/test_stages.rb +9 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/lib/stages/wrap.rb
CHANGED
@@ -2,8 +2,8 @@ module Stages
|
|
2
2
|
class Wrap < Stage
|
3
3
|
def initialize(pipeline)
|
4
4
|
@pipeline = pipeline
|
5
|
-
@cache = []
|
6
5
|
@output_style = :hash
|
6
|
+
@aggregated = false
|
7
7
|
super()
|
8
8
|
end
|
9
9
|
|
@@ -17,13 +17,19 @@ module Stages
|
|
17
17
|
self
|
18
18
|
end
|
19
19
|
|
20
|
+
def aggregated
|
21
|
+
@aggregated = true
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
20
25
|
def process
|
21
26
|
while value = input
|
22
27
|
subpipe = Emit.new(value) | @pipeline
|
23
28
|
results = []
|
24
29
|
while v = subpipe.run
|
25
30
|
@output_style == :each ? output(v) : results << v
|
26
|
-
end
|
31
|
+
end
|
32
|
+
results = results.first if @aggregated
|
27
33
|
output results if @output_style == :array
|
28
34
|
output({ value => results}) if @output_style == :hash
|
29
35
|
@pipeline.drop_leftmost!
|
data/stages.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "stages"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["The Justice Eight"]
|
12
|
-
s.date = "2012-01-
|
12
|
+
s.date = "2012-01-17"
|
13
13
|
s.description = "pipeline builder"
|
14
14
|
s.email = "support@igodigital.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/test/test_stages.rb
CHANGED
@@ -77,6 +77,15 @@ class TestStages < MiniTest::Unit::TestCase
|
|
77
77
|
assert_equal(%w(b a r), result['bar'])
|
78
78
|
end
|
79
79
|
|
80
|
+
test 'hash/aggregated wrap mode wrap' do
|
81
|
+
pipeline = Each.new(%w(foo bar)) | Wrap.new(Each.new{ |x| x.chars} | Count.new).aggregated
|
82
|
+
result = pipeline.run
|
83
|
+
assert_equal(2, result['foo']['o'])
|
84
|
+
result = pipeline.run
|
85
|
+
assert_equal(3, result['bar'].keys.length)
|
86
|
+
end
|
87
|
+
|
88
|
+
|
80
89
|
test 'array mode wrap' do
|
81
90
|
pipeline = Each.new(%w(foo bar)) | Wrap.new(Each.new{ |x| x.chars}).array
|
82
91
|
result = pipeline.run
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: stages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- The Justice Eight
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-01-
|
13
|
+
date: 2012-01-17 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -70,7 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
hash:
|
73
|
+
hash: 1416732163094176544
|
74
74
|
segments:
|
75
75
|
- 0
|
76
76
|
version: "0"
|