stages 0.3.2 → 0.3.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 CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
data/lib/stage_base.rb CHANGED
@@ -54,6 +54,7 @@ module Stages
54
54
  end
55
55
 
56
56
  def |(other)
57
+ return self if other.nil?
57
58
  other.root_source.source = self
58
59
  other
59
60
  end
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.3.2"
8
+ s.version = "0.3.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-03-05"
12
+ s.date = "2012-03-12"
13
13
  s.description = "pipeline builder"
14
14
  s.email = "support@igodigital.com"
15
15
  s.extra_rdoc_files = [
@@ -2,30 +2,30 @@ require 'helper'
2
2
  include Stages
3
3
 
4
4
  class TestPipeline < MiniTest::Unit::TestCase
5
-
5
+
6
6
  test 'simple basic pipeline' do
7
7
  evens = Evens.new
8
8
  mx3 = Select.new{ |x| x % 3 == 0}
9
9
  mx7 = Select.new{ |x| x % 7 == 0}
10
- mx3.source = evens
10
+ mx3.source = evens
11
11
  mx7.source = mx3
12
-
12
+
13
13
  result = (0..2).map{ mx7.run }
14
14
  assert_equal([0, 42, 84], result)
15
15
  end
16
-
16
+
17
17
  test 'pipeline pipe syntax works' do
18
18
  pipeline = Evens.new | Select.new{ |x| x % 3 == 0} | Select.new{ |x| x % 7 == 0}
19
19
  result = (0..2).map{ pipeline.run }
20
20
  assert_equal([0, 42, 84], result)
21
21
  end
22
-
22
+
23
23
  test 'block stages work' do
24
24
  pipeline = Evens.new | Map.new{ |x| x * 3} | Select.new{ |x| x % 7 == 0}
25
25
  result = (0..2).map{ pipeline.run }
26
26
  assert_equal([0, 42, 84], result)
27
27
  end
28
-
28
+
29
29
  test 'exceptions do what you expect' do
30
30
  begin
31
31
  pipeline = Evens.new | Map.new{ |val| throw Exception.new "exception!" } | Select.new{ |v| v > 2}
@@ -33,17 +33,17 @@ class TestPipeline < MiniTest::Unit::TestCase
33
33
  assert false
34
34
  rescue Exception => e
35
35
  end
36
- end
37
-
36
+ end
37
+
38
38
  test 'nil kills it' do
39
39
  pipeline = Each.new([1, 2, nil, 3])
40
40
  result = []
41
41
  while v = pipeline.run
42
42
  result << v
43
43
  end
44
- assert_equal([1, 2], result)
45
- end
46
-
44
+ assert_equal([1, 2], result)
45
+ end
46
+
47
47
  test 'complex substage hash example' do
48
48
  sub = Each.new{ |x| x.chars } | Map.new{ |x| x.to_sym} | Count.new
49
49
  pipeline = Each.new(%w(foo bar)) | Wrap.new(sub) | Map.new{ |x| { x.keys.first => x.values.first.first}}
@@ -52,7 +52,7 @@ class TestPipeline < MiniTest::Unit::TestCase
52
52
  result = pipeline.run
53
53
  assert_equal({ 'bar' => { :b => 1, :a => 1, :r => 1}}, result)
54
54
  end
55
-
55
+
56
56
  test 'reset! resets everything' do
57
57
  pipeline = Each.new([1, 2, 3])
58
58
  assert_equal(1, pipeline.run)
@@ -61,4 +61,9 @@ class TestPipeline < MiniTest::Unit::TestCase
61
61
  assert_equal(2, pipeline.run)
62
62
  end
63
63
 
64
+ test 'nil stages are skipped/no-ops' do
65
+ pipeline = Evens.new | nil | Select.new{ |x| x > 3}
66
+ assert_equal(4, pipeline.run)
67
+ assert_equal(6, pipeline.run)
68
+ end
64
69
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: stages
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.2
5
+ version: 0.3.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-03-05 00:00:00 Z
13
+ date: 2012-03-12 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -75,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
75
  requirements:
76
76
  - - ">="
77
77
  - !ruby/object:Gem::Version
78
- hash: -10193837750712847
78
+ hash: 3232589023381470153
79
79
  segments:
80
80
  - 0
81
81
  version: "0"