stages 0.2.1 → 0.2.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.2.1
1
+ 0.2.2
@@ -0,0 +1,19 @@
1
+ require 'set'
2
+
3
+ module Stages
4
+ class Unique < Stage
5
+ def initialize_loop
6
+ @set = Set.new
7
+ super()
8
+ end
9
+
10
+ def die
11
+ @set = Set.new
12
+ super()
13
+ end
14
+
15
+ def handle_value(value)
16
+ output value if @set.add? value.hash
17
+ end
18
+ end
19
+ 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.1"
8
+ s.version = "0.2.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"]
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
35
35
  "lib/stages/resume.rb",
36
36
  "lib/stages/resume_count.rb",
37
37
  "lib/stages/select.rb",
38
+ "lib/stages/unique.rb",
38
39
  "lib/stages/wrap.rb",
39
40
  "stages.gemspec",
40
41
  "test/helper.rb",
data/test/test_stages.rb CHANGED
@@ -93,6 +93,15 @@ class TestStages < MiniTest::Unit::TestCase
93
93
  end
94
94
  end
95
95
 
96
+ test 'unique' do
97
+ pipeline = Each.new('abcadefbega'){ |x| x.chars} | Unique.new
98
+ results = []
99
+ while r = pipeline.run
100
+ results << r
101
+ end
102
+ assert_equal(%w(a b c d e f g), results)
103
+ end
104
+
96
105
  def sing
97
106
  { :do => 'doe a deer a female deer',
98
107
  :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.1
5
+ version: 0.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - The Justice Eight
@@ -51,6 +51,7 @@ files:
51
51
  - lib/stages/resume.rb
52
52
  - lib/stages/resume_count.rb
53
53
  - lib/stages/select.rb
54
+ - lib/stages/unique.rb
54
55
  - lib/stages/wrap.rb
55
56
  - stages.gemspec
56
57
  - test/helper.rb
@@ -69,7 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
70
  requirements:
70
71
  - - ">="
71
72
  - !ruby/object:Gem::Version
72
- hash: -2518020678826236574
73
+ hash: -1221105454278570128
73
74
  segments:
74
75
  - 0
75
76
  version: "0"