ntswf 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,11 +10,7 @@ module Ntswf
10
10
  domain.activity_tasks.poll_for_single_task(activity_task_list) do |task|
11
11
  announce("got activity task #{task.activity_type.inspect} #{task.input}")
12
12
  begin
13
- if task.activity_type == activity_type
14
- yield task
15
- else
16
- raise "unknown activity type: #{task.activity_type.inspect}"
17
- end
13
+ yield task
18
14
  rescue => e
19
15
  notify(e, activity_type: task.activity_type.inspect, input: task.input)
20
16
  details = {
data/lib/ntswf/base.rb CHANGED
@@ -69,8 +69,21 @@ module Ntswf
69
69
  log("#{message.message}\n #{message.backtrace.join("\n ")}") if message.kind_of? Exception
70
70
  end
71
71
 
72
+ # @return [String] separator for composite *workflow_id*
73
+ def separator
74
+ ";"
75
+ end
76
+
72
77
  protected
73
78
 
79
+ def activity_name
80
+ "#{default_unit}-activity"
81
+ end
82
+
83
+ def activity_type
84
+ @activity_type ||= domain.activity_types[activity_name, workflow_version]
85
+ end
86
+
74
87
  def announce(s)
75
88
  $0 = s
76
89
  log(s)
data/lib/ntswf/client.rb CHANGED
@@ -31,11 +31,6 @@ module Ntswf
31
31
  )
32
32
  end
33
33
 
34
- # @return [String] separator part of the final *workflow_id*
35
- def separator
36
- ";"
37
- end
38
-
39
34
  protected
40
35
 
41
36
  def workflow_type
data/lib/ntswf/utils.rb CHANGED
@@ -8,10 +8,6 @@ module Ntswf
8
8
  swf.domains.create(@config.domain, 3, description: description)
9
9
  end
10
10
 
11
- def activity_name
12
- "#{default_unit}-activity"
13
- end
14
-
15
11
  def register_workflow_type
16
12
  domain.workflow_types.register(workflow_name, workflow_version)
17
13
  end
@@ -19,9 +15,5 @@ module Ntswf
19
15
  def register_activity_type
20
16
  domain.activity_types.register(activity_name, workflow_version)
21
17
  end
22
-
23
- def activity_type
24
- @activity_type ||= domain.activity_types[activity_name, workflow_version]
25
- end
26
18
  end
27
19
  end
@@ -0,0 +1,26 @@
1
+ require "ntswf"
2
+
3
+ describe Ntswf::ActivityWorker do
4
+ class Worker
5
+ include Ntswf::ActivityWorker
6
+ end
7
+
8
+ before { Worker.any_instance.stub(announce: nil, log: nil) }
9
+
10
+ let(:config) { { unit: "test", activity_task_lists: { "test" => "task_list" } } }
11
+ let(:worker) { Worker.new config }
12
+ let(:activity_task) { mock input: "{}" }
13
+
14
+ describe "processing an activity task" do
15
+ before do
16
+ AWS::SimpleWorkflow::ActivityTaskCollection.any_instance.stub(:poll_for_single_task).
17
+ and_yield activity_task
18
+ end
19
+
20
+ context "given foreign activity type" do
21
+ before { activity_task.stub activity_type: :some_random_thing }
22
+ subject { worker.process_activity_task { :accepted } }
23
+ it { should eq :accepted }
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ntswf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-15 00:00:00.000000000 Z
12
+ date: 2014-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.8'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  description: A layer around AWS SWF
31
47
  email: info@infopark.de
32
48
  executables: []
@@ -42,6 +58,7 @@ files:
42
58
  - lib/ntswf/client.rb
43
59
  - lib/ntswf/base.rb
44
60
  - lib/ntswf.rb
61
+ - spec/activity_worker_spec.rb
45
62
  homepage: https://github.com/infopark/ntswf
46
63
  licenses:
47
64
  - LGPLv3
@@ -67,5 +84,6 @@ rubygems_version: 1.8.23
67
84
  signing_key:
68
85
  specification_version: 3
69
86
  summary: Not That Simple Workflow
70
- test_files: []
87
+ test_files:
88
+ - spec/activity_worker_spec.rb
71
89
  has_rdoc: