bumbleworks 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/doc/QUICKSTART.md +67 -0
- data/lib/bumbleworks/task.rb +15 -11
- data/lib/bumbleworks/version.rb +1 -1
- metadata +9 -3
data/.gitignore
CHANGED
data/doc/QUICKSTART.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Quick Start for Rails
|
2
|
+
|
3
|
+
1. Install [Rails](http://rubyonrails.org) and [redis](http://redis.io).
|
4
|
+
|
5
|
+
1. Create a new Rails application.
|
6
|
+
|
7
|
+
```
|
8
|
+
$ rails new bumbleworks_quickstart_rails
|
9
|
+
$ cd bumbleworks_quickstart_rails
|
10
|
+
```
|
11
|
+
|
12
|
+
1. Add Bumbleworks and the Redis storage adapter to your Gemfile.
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'bumbleworks'
|
16
|
+
gem 'bumbleworks-redis'
|
17
|
+
```
|
18
|
+
|
19
|
+
1. Install the gems in your Gemfile.
|
20
|
+
```
|
21
|
+
$ bundle install
|
22
|
+
```
|
23
|
+
|
24
|
+
1. Create an initializer at `config/initializers/bumbleworks.rb`:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
Bumbleworks.configure do |c|
|
28
|
+
c.storage = Redis.new
|
29
|
+
end
|
30
|
+
|
31
|
+
Bumbleworks.load_definitions!
|
32
|
+
```
|
33
|
+
|
34
|
+
1. Add your first process definition at `lib/process_definitions/`:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
Bumbleworks.define_process do
|
38
|
+
# write your process definition here
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
Process definitions follow the same syntax as [ruote](http://ruote.rubyforge.org/definitions.html), but are defined using `Bumbleworks.define_process` instead of `Ruote.define`.
|
43
|
+
|
44
|
+
1. (*optional*) Put any [custom participants](http://ruote.rubyforge.org/implementing_participants.html) in `app/participants` or `participants`.
|
45
|
+
|
46
|
+
1. Create an initializer file (e.g. `config/initializers/bumbleworks.rb` for Rails) with the following:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
Bumbleworks.configure do |c|
|
50
|
+
c.storage = Hash.new
|
51
|
+
end
|
52
|
+
|
53
|
+
# this next block is optional - it's only needed
|
54
|
+
# if you want to load custom participants
|
55
|
+
Bumbleworks.register_participants do
|
56
|
+
# foo FooParticipant
|
57
|
+
# bar BarParticipant
|
58
|
+
# ...
|
59
|
+
end
|
60
|
+
|
61
|
+
Bumbleworks.load_definitions!
|
62
|
+
Bumbleworks.start_worker!
|
63
|
+
```
|
64
|
+
|
65
|
+
1. You can now launch processes using `Bumbleworks.launch!('process_definition_name')`.
|
66
|
+
|
67
|
+
1. Any expressions of the form `[role] :task => [task_name]` will be turned into tasks retrievable at `Bumbleworks::Task.all`; you can get tasks specific to a role or roles using `Bumbleworks::Task.for_roles([role1, role2, ...])`.
|
data/lib/bumbleworks/task.rb
CHANGED
@@ -76,21 +76,16 @@ module Bumbleworks
|
|
76
76
|
storage_participant.proceed(@workitem)
|
77
77
|
end
|
78
78
|
|
79
|
-
# Claim task and assign token to claim
|
80
|
-
def claim(token)
|
81
|
-
if token && claimant && token != claimant
|
82
|
-
raise AlreadyClaimed, "Already claimed by #{claimant}"
|
83
|
-
end
|
84
|
-
|
85
|
-
params['claimant'] = token
|
86
|
-
save
|
87
|
-
end
|
88
|
-
|
89
79
|
# Token used to claim task, nil if not claimed
|
90
80
|
def claimant
|
91
81
|
params['claimant']
|
92
82
|
end
|
93
83
|
|
84
|
+
# Claim task and assign token to claimant
|
85
|
+
def claim(token)
|
86
|
+
set_claimant(token)
|
87
|
+
end
|
88
|
+
|
94
89
|
# true if task is claimed
|
95
90
|
def claimed?
|
96
91
|
!claimant.nil?
|
@@ -98,12 +93,21 @@ module Bumbleworks
|
|
98
93
|
|
99
94
|
# release claim on task.
|
100
95
|
def release
|
101
|
-
|
96
|
+
set_claimant(nil)
|
102
97
|
end
|
103
98
|
|
104
99
|
private
|
105
100
|
def storage_participant
|
106
101
|
self.class.storage_participant
|
107
102
|
end
|
103
|
+
|
104
|
+
def set_claimant(token)
|
105
|
+
if token && claimant && token != claimant
|
106
|
+
raise AlreadyClaimed, "Already claimed by #{claimant}"
|
107
|
+
end
|
108
|
+
|
109
|
+
params['claimant'] = token
|
110
|
+
save
|
111
|
+
end
|
108
112
|
end
|
109
113
|
end
|
data/lib/bumbleworks/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bumbleworks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-
|
15
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: ruote
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- Rakefile
|
164
164
|
- bumbleworks.gemspec
|
165
165
|
- doc/GUIDE.md
|
166
|
+
- doc/QUICKSTART.md
|
166
167
|
- doc/TERMS.md
|
167
168
|
- lib/bumbleworks.rb
|
168
169
|
- lib/bumbleworks/configuration.rb
|
@@ -216,12 +217,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
217
|
- - ! '>='
|
217
218
|
- !ruby/object:Gem::Version
|
218
219
|
version: '0'
|
220
|
+
segments:
|
221
|
+
- 0
|
222
|
+
hash: -2621503672602724538
|
219
223
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
224
|
none: false
|
221
225
|
requirements:
|
222
226
|
- - ! '>='
|
223
227
|
- !ruby/object:Gem::Version
|
224
228
|
version: '0'
|
229
|
+
segments:
|
230
|
+
- 0
|
231
|
+
hash: -2621503672602724538
|
225
232
|
requirements: []
|
226
233
|
rubyforge_project:
|
227
234
|
rubygems_version: 1.8.23
|
@@ -255,4 +262,3 @@ test_files:
|
|
255
262
|
- spec/lib/bumbleworks_spec.rb
|
256
263
|
- spec/spec_helper.rb
|
257
264
|
- spec/support/path_helpers.rb
|
258
|
-
has_rdoc:
|