stages 0.2.10 → 0.3.0

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.10
1
+ 0.3.0
@@ -0,0 +1,11 @@
1
+ module Stages
2
+ class ExhaustCount < Stage
3
+ def process
4
+ results = 0
5
+ while value = input
6
+ results += 1
7
+ end
8
+ output results
9
+ end
10
+ end
11
+ end
data/lib/sugar.rb CHANGED
@@ -24,6 +24,10 @@ module Stages
24
24
  Exhaust.new(*args, &block)
25
25
  end
26
26
 
27
+ def exhaust_and_count(*args, &block)
28
+ ExhaustCount.new(*args, &block)
29
+ end
30
+
27
31
  def restrict(*args, &block)
28
32
  Restrict.new(*args, &block)
29
33
  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.2.10"
8
+ s.version = "0.3.0"
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"]
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
31
31
  "lib/stages/each.rb",
32
32
  "lib/stages/emit.rb",
33
33
  "lib/stages/exhaust.rb",
34
+ "lib/stages/exhaust_count.rb",
34
35
  "lib/stages/map.rb",
35
36
  "lib/stages/restrict.rb",
36
37
  "lib/stages/resume.rb",
data/test/test_stages.rb CHANGED
@@ -109,6 +109,11 @@ 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
113
+ pipeline = Each.new(%w(foo bar zut)) | ExhaustCount.new
114
+ assert_equal(3, pipeline.run)
115
+ end
116
+
112
117
  test 'count aggregates from prevous counts' do
113
118
  pipeline = Each.new([{ a: 2}, { a: 3}]) | Count.new
114
119
  assert_equal({ a: 5}, pipeline.run)
data/test/test_syntax.rb CHANGED
@@ -35,4 +35,9 @@ class TestSyntax < MiniTest::Unit::TestCase
35
35
  pipeline = each([1, 3, 2, 3, 2, 1]) | unique | run_until_exhausted
36
36
  assert_equal([1, 3, 2], pipeline.run)
37
37
  end
38
+
39
+ test 'exhaustcount' do
40
+ pipeline = each([1, 3, 2, 3, 2, 1]) | unique | exhaust_and_count
41
+ assert_equal(3, pipeline.run)
42
+ end
38
43
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: stages
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.10
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - The Justice Eight
@@ -47,6 +47,7 @@ files:
47
47
  - lib/stages/each.rb
48
48
  - lib/stages/emit.rb
49
49
  - lib/stages/exhaust.rb
50
+ - lib/stages/exhaust_count.rb
50
51
  - lib/stages/map.rb
51
52
  - lib/stages/restrict.rb
52
53
  - lib/stages/resume.rb
@@ -73,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
74
  requirements:
74
75
  - - ">="
75
76
  - !ruby/object:Gem::Version
76
- hash: 4574983875197029108
77
+ hash: -3050689494935064105
77
78
  segments:
78
79
  - 0
79
80
  version: "0"