stages 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.8
1
+ 0.2.9
data/lib/stage_base.rb CHANGED
@@ -1,67 +1,67 @@
1
1
  module Stages
2
2
  class Stage
3
3
  attr_accessor :source
4
-
4
+
5
5
  def initialize(&block)
6
6
  @block = block
7
7
  initialize_loop
8
8
  end
9
-
9
+
10
10
  def initialize_loop
11
11
  @fiber_delegate = Fiber.new do
12
12
  process
13
13
  die
14
14
  end
15
15
  end
16
-
16
+
17
17
  def run
18
- @fiber_delegate.resume
18
+ @fiber_delegate.resume
19
19
  end
20
-
20
+
21
21
  #seperate from reset! for restrict/resume purposes.
22
22
  def reset
23
23
  initialize_loop
24
24
  @source.reset if @source
25
25
  end
26
-
26
+
27
27
  def reset!
28
28
  initialize_loop
29
29
  @source.reset! if @source
30
30
  end
31
-
31
+
32
32
  def die
33
33
  loop do
34
34
  output nil
35
35
  end
36
36
  end
37
-
37
+
38
38
  def process
39
39
  while value = input
40
40
  handle_value value
41
41
  end
42
42
  end
43
-
43
+
44
44
  def handle_value(value)
45
45
  output value
46
46
  end
47
-
47
+
48
48
  def input
49
- source.run
49
+ source.nil? ? nil : source.run
50
50
  end
51
-
51
+
52
52
  def output(value)
53
53
  Fiber.yield value
54
54
  end
55
-
55
+
56
56
  def |(other)
57
57
  other.root_source.source = self
58
58
  other
59
59
  end
60
-
60
+
61
61
  def root_source
62
62
  source.nil? ? self : source.root_source
63
63
  end
64
-
64
+
65
65
  def drop_leftmost!
66
66
  if @source.end?
67
67
  @source = nil
@@ -69,11 +69,11 @@ module Stages
69
69
  @source.drop_leftmost!
70
70
  end
71
71
  end
72
-
72
+
73
73
  def end?
74
74
  @source.nil?
75
75
  end
76
-
76
+
77
77
  def length
78
78
  if source
79
79
  source.length + 1
@@ -81,6 +81,6 @@ module Stages
81
81
  1
82
82
  end
83
83
  end
84
- end
85
- end
86
-
84
+ end
85
+ end
86
+
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.2.8"
8
+ s.version = "0.2.9"
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"]
data/test/test_stages.rb CHANGED
@@ -114,6 +114,11 @@ class TestStages < MiniTest::Unit::TestCase
114
114
  assert_equal({ a: 5}, pipeline.run)
115
115
  end
116
116
 
117
+ test 'trying to pull from nil returns nil, not an excemption' do
118
+ pipeline = Unique.new
119
+ assert_equal(nil, pipeline.run)
120
+ end
121
+
117
122
  def sing
118
123
  { :do => 'doe a deer a female deer',
119
124
  :re => 'ray a drop of golden sun',
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: stages
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.8
5
+ version: 0.2.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - The Justice Eight
@@ -73,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- hash: 534278270114761516
76
+ hash: -169923303030114075
77
77
  segments:
78
78
  - 0
79
79
  version: "0"