stages 0.1.0 → 0.1.1

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 CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -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
- whitespace = Select.new{ |x| x != ' '}
20
- sub_pipeline = get_lyric | each_character | whitespace
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
- generator = EachElement.new sing.keys
24
- subtotals = Map.new { |x| x.values.first }
25
- iterator = EachInput.new
26
- count = Count.new
22
+ each_note = EachElement.new sing.keys
23
+ count_everything = Count.new
27
24
 
28
- generator | process_elements | subtotals | iterator | count
25
+ each_note | count_letters_in_line | count_everything
29
26
  end
30
27
 
31
28
  puts setup_pipeline.run.inspect
@@ -0,0 +1,12 @@
1
+ module Stages
2
+ class Emit < Stage
3
+ def initialize(thing)
4
+ @thing = thing
5
+ super()
6
+ end
7
+
8
+ def process
9
+ output @thing
10
+ end
11
+ end
12
+ end
@@ -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 handle_value(value)
9
- results = []
10
- subpipe = (EachElement.new([value]) | @pipeline)
11
- while v = subpipe.run
12
- results << v
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.0"
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({ 'foo' => { :f => 1, :o => 2}}, result)
85
+ assert_equal({ :f => 1, :o => 2}, result)
86
86
  result = pipeline.run
87
- assert_equal({ 'bar' => { :b => 1, :a => 1, :r => 1}}, result)
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.0
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: 1745323606775845054
75
+ hash: 4250500444924917482
75
76
  segments:
76
77
  - 0
77
78
  version: "0"