stages 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/examples/sing_subpipes.rb +5 -8
- data/lib/stages/emit.rb +12 -0
- data/lib/stages/sub_stage.rb +9 -9
- data/stages.gemspec +2 -1
- data/test/test_stages.rb +2 -2
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/examples/sing_subpipes.rb
CHANGED
@@ -16,16 +16,13 @@ end
|
|
16
16
|
def setup_pipeline
|
17
17
|
get_lyric = HashLookup.new sing
|
18
18
|
each_character = EachInput.new{ |x| x.chars }
|
19
|
-
|
20
|
-
|
21
|
-
process_elements = SubStage.new(sub_pipeline)
|
19
|
+
trim_whitespace = Select.new{ |x| x != ' '}
|
20
|
+
count_letters_in_line = SubStage.new(get_lyric | each_character | trim_whitespace)
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
iterator = EachInput.new
|
26
|
-
count = Count.new
|
22
|
+
each_note = EachElement.new sing.keys
|
23
|
+
count_everything = Count.new
|
27
24
|
|
28
|
-
|
25
|
+
each_note | count_letters_in_line | count_everything
|
29
26
|
end
|
30
27
|
|
31
28
|
puts setup_pipeline.run.inspect
|
data/lib/stages/emit.rb
ADDED
data/lib/stages/sub_stage.rb
CHANGED
@@ -2,19 +2,19 @@ module Stages
|
|
2
2
|
class SubStage < Stage
|
3
3
|
def initialize(pipeline)
|
4
4
|
@pipeline = pipeline
|
5
|
+
@cache = []
|
5
6
|
super()
|
6
7
|
end
|
7
8
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def process
|
10
|
+
while value = input
|
11
|
+
subpipe = Emit.new(value) | @pipeline
|
12
|
+
while v = subpipe.run
|
13
|
+
output v
|
14
|
+
end
|
15
|
+
@pipeline.drop_leftmost!
|
16
|
+
@pipeline.continue
|
13
17
|
end
|
14
|
-
@pipeline.drop_leftmost!
|
15
|
-
@pipeline.continue
|
16
|
-
results = results.first if results.length == 1
|
17
|
-
output ({ value => results })
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/stages.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "stages"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
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"]
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/stages/count.rb",
|
30
30
|
"lib/stages/each_element.rb",
|
31
31
|
"lib/stages/each_input.rb",
|
32
|
+
"lib/stages/emit.rb",
|
32
33
|
"lib/stages/evens.rb",
|
33
34
|
"lib/stages/hash_lookup.rb",
|
34
35
|
"lib/stages/map.rb",
|
data/test/test_stages.rb
CHANGED
@@ -82,9 +82,9 @@ class TestStages < MiniTest::Unit::TestCase
|
|
82
82
|
sub = EachInput.new{ |x| x.chars } | Map.new{ |x| x.to_sym} | Count.new
|
83
83
|
pipeline = EachElement.new(%w(foo bar)) | SubStage.new(sub)
|
84
84
|
result = pipeline.run
|
85
|
-
assert_equal({
|
85
|
+
assert_equal({ :f => 1, :o => 2}, result)
|
86
86
|
result = pipeline.run
|
87
|
-
assert_equal({
|
87
|
+
assert_equal({ :b => 1, :a => 1, :r => 1}, result)
|
88
88
|
end
|
89
89
|
|
90
90
|
def sing
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: stages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- The Justice Eight
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- lib/stages/count.rb
|
46
46
|
- lib/stages/each_element.rb
|
47
47
|
- lib/stages/each_input.rb
|
48
|
+
- lib/stages/emit.rb
|
48
49
|
- lib/stages/evens.rb
|
49
50
|
- lib/stages/hash_lookup.rb
|
50
51
|
- lib/stages/map.rb
|
@@ -71,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
72
|
requirements:
|
72
73
|
- - ">="
|
73
74
|
- !ruby/object:Gem::Version
|
74
|
-
hash:
|
75
|
+
hash: 4250500444924917482
|
75
76
|
segments:
|
76
77
|
- 0
|
77
78
|
version: "0"
|