seam 1.0.1 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b27e0247eafdc389e112ff49179889ddfc61c98
4
- data.tar.gz: d83abc8a9725612d1533b834b9e92f8ac7a51636
3
+ metadata.gz: f77d3c7f56742635b5fda7bbd4fd6273e4f98293
4
+ data.tar.gz: 39a5730134d7d8cc53b028a36c915873809b6d54
5
5
  SHA512:
6
- metadata.gz: 378292922e1a0c974f5050afe0259e1e37c049e8e73b03a730a225533ec769cd606441dc974be6d0f0d822e6f92434d7cfa61340db985707ba9108f28cfeb0f0
7
- data.tar.gz: 95b5520d6a540b4865787c7f33f36482d18492f399d0440ab3067341bdc809394a31a0232c4d449581093fd78740f8824ac36a68a6649a198f17715b404e18fb
6
+ metadata.gz: 113c2d036b72d7e07e99e19aca09ea4a21d9da7fb608fc6c1470b8ee51d5bab28b5c0433edb3fad0b25699488e63271715d0b3373decd347c3a84d7f89033e68
7
+ data.tar.gz: 6e1b2fa575ea9c47294321e1e2f606ab15eb490555dfeccd80409cfee0402a4e0942a1b479c7e004446a1f00df9cf80c04509e2c6b03a6b7a825b13fd58badae
data/lib/seam/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Seam
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/seam/worker.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Seam
2
+
2
3
  class Worker
4
+
3
5
  def handles step
4
6
  @step = step
5
7
  end
@@ -11,6 +13,23 @@ module Seam
11
13
  after_process
12
14
  end
13
15
 
16
+ def self.inherited handler
17
+ @handlers ||= []
18
+ @handlers << handler
19
+ end
20
+
21
+ def self.handler_for step
22
+ @handlers.each do |handler|
23
+ instance = handler.new
24
+ return instance if instance.handles == step
25
+ end
26
+ nil
27
+ end
28
+
29
+ def self.all
30
+ (@handlers || []).map { |x| x.new }
31
+ end
32
+
14
33
  def execute_all
15
34
  efforts_to_execute.each { |e| execute e }
16
35
  end
@@ -141,5 +160,7 @@ module Seam
141
160
  def save_the_effort
142
161
  effort.save
143
162
  end
163
+
144
164
  end
165
+
145
166
  end
@@ -19,6 +19,55 @@ describe "worker" do
19
19
  end
20
20
  end
21
21
 
22
+ describe "inherited & all" do
23
+
24
+ before do
25
+ Seam::Worker.instance_eval { @handlers = nil }
26
+ end
27
+
28
+ it "should default to an empty set" do
29
+ Seam::Worker.all.count.must_equal 0
30
+ end
31
+
32
+ it "should return new instances of all handlers" do
33
+ instance = Object.new
34
+ klass = Struct.new(:new).new instance
35
+ Seam::Worker.inherited klass
36
+ Seam::Worker.all.count.must_equal 1
37
+ Seam::Worker.all[0].must_be_same_as instance
38
+ end
39
+
40
+ end
41
+
42
+ describe "handler for" do
43
+
44
+ let(:handler_1) { Struct.new(:handles).new SecureRandom.uuid }
45
+ let(:handler_2) { Struct.new(:handles).new SecureRandom.uuid }
46
+ let(:handler_3) { Struct.new(:handles).new SecureRandom.uuid }
47
+
48
+ before do
49
+ handler_1_class, handler_2_class, handler_3_class = Object.new, Object.new, Object.new
50
+
51
+ handler_1_class = Struct.new(:new).new handler_1
52
+ handler_2_class = Struct.new(:new).new handler_2
53
+ handler_3_class = Struct.new(:new).new handler_3
54
+
55
+ Seam::Worker.instance_eval do
56
+ @handlers = [handler_1_class, handler_2_class, handler_3_class]
57
+ end
58
+ end
59
+
60
+ it "should return the handler for the type" do
61
+ Seam::Worker.handler_for(handler_2.handles).must_be_same_as handler_2
62
+ Seam::Worker.handler_for(handler_1.handles).must_be_same_as handler_1
63
+ Seam::Worker.handler_for(handler_3.handles).must_be_same_as handler_3
64
+ end
65
+
66
+ it "should return nil if none exist" do
67
+ Seam::Worker.handler_for('test').nil?.must_equal true
68
+ end
69
+ end
70
+
22
71
  describe "move_to_next_step" do
23
72
 
24
73
  [:date].to_objects {[
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seam
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Cauthon