stages 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/examples/sing_custom_stages.rb +1 -1
- data/examples/sing_subpipes.rb +1 -1
- data/lib/stages/wrap.rb +10 -18
- data/stages.gemspec +1 -1
- data/test/test_stages.rb +3 -3
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
@@ -38,7 +38,7 @@ def setup_pipeline
|
|
38
38
|
|
39
39
|
each_character = Each.new{ |x| x.chars }
|
40
40
|
trim_whitespace = Select.new{ |x| x != ' '}
|
41
|
-
letters_in_each_line = Wrap.new(get_lyric | each_character | trim_whitespace)
|
41
|
+
letters_in_each_line = Wrap.new(get_lyric | each_character | trim_whitespace, :array)
|
42
42
|
each_letter = Each.new
|
43
43
|
each_note = Generator.new(@lyrics.keys)
|
44
44
|
count_everything = Count.new
|
data/examples/sing_subpipes.rb
CHANGED
@@ -31,7 +31,7 @@ puts setup_pipeline.run.inspect
|
|
31
31
|
|
32
32
|
puts "one line at a time"
|
33
33
|
lyrics = Each.new(@lyrics.keys)
|
34
|
-
letters_in_chunks = Wrap.new(Map.new{ |x| @lyrics[x]} | Each.new{ |x| x.chars})
|
34
|
+
letters_in_chunks = Wrap.new(Map.new{ |x| @lyrics[x]} | Each.new{ |x| x.chars})
|
35
35
|
each_letter = Each.new{ |x| x.values.first }
|
36
36
|
count = Count.new
|
37
37
|
|
data/lib/stages/wrap.rb
CHANGED
@@ -1,27 +1,19 @@
|
|
1
1
|
module Stages
|
2
2
|
class Wrap < Stage
|
3
|
-
def initialize(pipeline)
|
3
|
+
def initialize(pipeline, *args)
|
4
4
|
@pipeline = pipeline
|
5
5
|
@output_style = :hash
|
6
|
-
|
6
|
+
unless args.empty?
|
7
|
+
if args.include? :array
|
8
|
+
@output_style = :array
|
9
|
+
elsif args.include? :each
|
10
|
+
@output_style = :each
|
11
|
+
end
|
12
|
+
@aggregated = true if args.include? :aggregated
|
13
|
+
end
|
7
14
|
super()
|
8
15
|
end
|
9
|
-
|
10
|
-
def array
|
11
|
-
@output_style = :array
|
12
|
-
self
|
13
|
-
end
|
14
|
-
|
15
|
-
def each
|
16
|
-
@output_style = :each
|
17
|
-
self
|
18
|
-
end
|
19
|
-
|
20
|
-
def aggregated
|
21
|
-
@aggregated = true
|
22
|
-
self
|
23
|
-
end
|
24
|
-
|
16
|
+
|
25
17
|
def process
|
26
18
|
while value = input
|
27
19
|
subpipe = Emit.new(value) | @pipeline
|
data/stages.gemspec
CHANGED
data/test/test_stages.rb
CHANGED
@@ -78,7 +78,7 @@ class TestStages < MiniTest::Unit::TestCase
|
|
78
78
|
end
|
79
79
|
|
80
80
|
test 'hash/aggregated wrap mode wrap' do
|
81
|
-
pipeline = Each.new(%w(foo bar)) | Wrap.new(Each.new{ |x| x.chars} | Count.new)
|
81
|
+
pipeline = Each.new(%w(foo bar)) | Wrap.new(Each.new{ |x| x.chars} | Count.new, :aggregated)
|
82
82
|
result = pipeline.run
|
83
83
|
assert_equal(2, result['foo']['o'])
|
84
84
|
result = pipeline.run
|
@@ -87,7 +87,7 @@ class TestStages < MiniTest::Unit::TestCase
|
|
87
87
|
|
88
88
|
|
89
89
|
test 'array mode wrap' do
|
90
|
-
pipeline = Each.new(%w(foo bar)) | Wrap.new(Each.new{ |x| x.chars})
|
90
|
+
pipeline = Each.new(%w(foo bar)) | Wrap.new(Each.new{ |x| x.chars}, :array)
|
91
91
|
result = pipeline.run
|
92
92
|
assert_equal(%w(f o o), result)
|
93
93
|
result = pipeline.run
|
@@ -95,7 +95,7 @@ class TestStages < MiniTest::Unit::TestCase
|
|
95
95
|
end
|
96
96
|
|
97
97
|
test 'each mode wrap' do
|
98
|
-
pipeline = Each.new(%w(foo bar)) | Wrap.new(Each.new{ |x| x.chars})
|
98
|
+
pipeline = Each.new(%w(foo bar)) | Wrap.new(Each.new{ |x| x.chars}, :each)
|
99
99
|
expected = %w(r a b o o f)
|
100
100
|
while r = pipeline.run
|
101
101
|
assert_equal(expected.pop, r)
|
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.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- The Justice Eight
|
@@ -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: 940714069352004572
|
74
74
|
segments:
|
75
75
|
- 0
|
76
76
|
version: "0"
|