stages 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -0,0 +1,15 @@
1
+ module Stages
2
+ class Cache < Stage
3
+ def initialize()
4
+ super()
5
+ end
6
+
7
+ def process
8
+ cache = []
9
+ while i = input
10
+ cache << i
11
+ end
12
+ cache.each{ |x| output x}
13
+ end
14
+ end
15
+ end
data/lib/sugar.rb CHANGED
@@ -43,5 +43,9 @@ module Stages
43
43
  def emit(*args, &block)
44
44
  Emit.new(*args, &block)
45
45
  end
46
+
47
+ def cache(*args, &block)
48
+ Cache.new(*args, &block)
49
+ end
46
50
  end
47
51
  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.1"
8
+ s.version = "0.3.2"
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-01-29"
12
+ s.date = "2012-03-05"
13
13
  s.description = "pipeline builder"
14
14
  s.email = "support@igodigital.com"
15
15
  s.extra_rdoc_files = [
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "examples/sing_subpipes.rb",
28
28
  "lib/stage_base.rb",
29
29
  "lib/stages.rb",
30
+ "lib/stages/cache.rb",
30
31
  "lib/stages/count.rb",
31
32
  "lib/stages/each.rb",
32
33
  "lib/stages/emit.rb",
@@ -48,7 +49,7 @@ Gem::Specification.new do |s|
48
49
  ]
49
50
  s.homepage = "https://github.com/iGoDigital-LLC/stages"
50
51
  s.require_paths = ["lib"]
51
- s.rubygems_version = "1.8.11"
52
+ s.rubygems_version = "1.8.17"
52
53
  s.summary = "pipeline builder"
53
54
 
54
55
  if s.respond_to? :specification_version then
data/test/test_stages.rb CHANGED
@@ -109,11 +109,17 @@ class TestStages < MiniTest::Unit::TestCase
109
109
  assert_equal(%w(foo bar zut), pipeline.run)
110
110
  end
111
111
 
112
- test 'exhaust count' do
112
+ test 'exhaust count' do
113
113
  pipeline = Each.new(%w(foo bar zut)) | ExhaustCount.new
114
114
  assert_equal(3, pipeline.run)
115
115
  end
116
116
 
117
+ test 'cache' do order = []
118
+ pipeline = Each.new([1, 3, 2, 3, 2, 1]) | Map.new{|x| order << 'a'; x} | Cache.new | Map.new{|x| order << 'b'; x} | Exhaust.new
119
+ assert_equal([1, 3, 2, 3, 2, 1], pipeline.run)
120
+ assert_equal(%w(a a a a a a b b b b b b), order)
121
+ end
122
+
117
123
  test 'count aggregates from prevous counts' do
118
124
  pipeline = Each.new([{ a: 2}, { a: 3}]) | Count.new
119
125
  assert_equal({ a: 5}, pipeline.run)
data/test/test_syntax.rb CHANGED
@@ -36,8 +36,15 @@ class TestSyntax < MiniTest::Unit::TestCase
36
36
  assert_equal([1, 3, 2], pipeline.run)
37
37
  end
38
38
 
39
- test 'exhaustcount' do
39
+ test 'exhaustcount' do
40
40
  pipeline = each([1, 3, 2, 3, 2, 1]) | unique | exhaust_and_count
41
41
  assert_equal(3, pipeline.run)
42
42
  end
43
+
44
+ test 'cache' do
45
+ order = []
46
+ pipeline = each([1, 3, 2, 3, 2, 1]) | map{|x| order << 'a'; x} | cache | map{|x| order << 'b'; x} | run_until_exhausted
47
+ assert_equal([1, 3, 2, 3, 2, 1], pipeline.run)
48
+ assert_equal(%w(a a a a a a b b b b b b), order)
49
+ end
43
50
  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.1
5
+ version: 0.3.2
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-01-29 00:00:00 Z
13
+ date: 2012-03-05 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -43,6 +43,7 @@ files:
43
43
  - examples/sing_subpipes.rb
44
44
  - lib/stage_base.rb
45
45
  - lib/stages.rb
46
+ - lib/stages/cache.rb
46
47
  - lib/stages/count.rb
47
48
  - lib/stages/each.rb
48
49
  - lib/stages/emit.rb
@@ -74,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
75
  requirements:
75
76
  - - ">="
76
77
  - !ruby/object:Gem::Version
77
- hash: 233601987303344530
78
+ hash: -10193837750712847
78
79
  segments:
79
80
  - 0
80
81
  version: "0"
@@ -87,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
88
  requirements: []
88
89
 
89
90
  rubyforge_project:
90
- rubygems_version: 1.8.11
91
+ rubygems_version: 1.8.17
91
92
  signing_key:
92
93
  specification_version: 3
93
94
  summary: pipeline builder