Skip to content

Commit 2c7280d

Browse files
committed
Document "task"
1 parent 4cd739b commit 2c7280d

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

doc/procedures/readme.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
* [schedule](schedule.md) - Schedules a function
7171
* [signal](signal.md) - Used in conjuction with "on".
7272
* [sleep](sleep.md) - Makes a branch of an execution sleep for a while.
73+
* [task](task.md) - Tasks a tasker with a task.
7374
* [trap](trap.md) - Watches the messages emitted in the execution and reacts when a message matches certain criteria.
7475

7576

@@ -152,7 +153,7 @@
152153
* [Flor::Pro::Slice](https://github.com/floraison/flor/blob/master/lib/flor/pcore/slice.rb) : [slice, index](slice.md)
153154
* [Flor::Pro::Stall](https://github.com/floraison/flor/blob/master/lib/flor/pcore/stall.rb) : [stall](stall.md)
154155
* [Flor::Pro::Strings](https://github.com/floraison/flor/blob/master/lib/flor/pcore/strings.rb) : downcase, lowercase, upcase, uppercase, capitalize
155-
* [Flor::Pro::Task](https://github.com/floraison/flor/blob/master/lib/flor/punit/task.rb) : task
156+
* [Flor::Pro::Task](https://github.com/floraison/flor/blob/master/lib/flor/punit/task.rb) : [task](task.md)
156157
* [Flor::Pro::TimeStamp](https://github.com/floraison/flor/blob/master/lib/flor/pcore/timestamp.rb) : [timestamp, ltimestamp](timestamp.md)
157158
* [Flor::Pro::ToArray](https://github.com/floraison/flor/blob/master/lib/flor/pcore/to_array.rb) : [to-array, to-object](to_array.md)
158159
* [Flor::Pro::Trace](https://github.com/floraison/flor/blob/master/lib/flor/punit/trace.rb) : trace

doc/procedures/task.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
# task
3+
4+
Tasks a tasker with a task.
5+
6+
```
7+
task 'clean up' by: 'alan'
8+
task 'clean up' for: 'alan'
9+
task 'clean up' assign: 'alan'
10+
task 'alan' with: 'clean up'
11+
alan task: 'clean up' # {tasker} task: {taskname}
12+
task 'alan'
13+
# ...
14+
```
15+
16+
Note that the quotes are the tasker name can be omitted:
17+
```
18+
task 'clean up' by: alan
19+
task 'clean up' for: alan
20+
task 'clean up' assign: alan
21+
task alan with: 'clean up'
22+
alan task: 'clean up' # {tasker} task: {taskname}
23+
task alan
24+
# ...
25+
```
26+
27+
Tasking hands a task (a message hash serializable to JSON) to a tasker.
28+
See [tasks](../tasks.md) for more information.
29+
30+
Since routing tasks among taskers is flor essential "task", this "task"
31+
procedure is very important.
32+
33+
Note that "task" can be implicit, as in:
34+
```
35+
alan task: 'clean up'
36+
```
37+
38+
39+
* [source](https://github.com/floraison/flor/tree/master/lib/flor/punit/task.rb)
40+
* [task spec](https://github.com/floraison/flor/tree/master/spec/punit/task_spec.rb)
41+

lib/flor/punit/task.rb

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
11

22
class Flor::Pro::Task < Flor::Procedure
33
#
4-
# Tasks a tasker with a task. Argh.
4+
# Tasks a tasker with a task.
55
#
66
# ```
77
# task 'clean up' by: 'alan'
88
# task 'clean up' for: 'alan'
99
# task 'clean up' assign: 'alan'
1010
# task 'alan' with: 'clean up'
11+
# alan task: 'clean up' # {tasker} task: {taskname}
12+
# task 'alan'
13+
# # ...
14+
# ```
15+
#
16+
# Note that the quotes are the tasker name can be omitted:
17+
# ```
18+
# task 'clean up' by: alan
19+
# task 'clean up' for: alan
20+
# task 'clean up' assign: alan
21+
# task alan with: 'clean up'
22+
# alan task: 'clean up' # {tasker} task: {taskname}
23+
# task alan
24+
# # ...
25+
# ```
26+
#
27+
# Tasking hands a task (a message hash serializable to JSON) to a tasker.
28+
# See [tasks](../tasks.md) for more information.
29+
#
30+
# Since routing tasks among taskers is flor essential "task", this "task"
31+
# procedure is very important.
32+
#
33+
# Note that "task" can be implicit, as in:
34+
# ```
1135
# alan task: 'clean up'
1236
# ```
1337

spec/punit/task_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@
244244
task 'three' assign: 'alpha'
245245
task 'alpha' with: 'four'
246246
alpha task: 'five'
247+
task 'alpha'
247248
},
248249
wait: true)
249250

@@ -257,6 +258,7 @@
257258
[ 'alpha', 'three' ],
258259
[ 'alpha', 'four' ],
259260
[ 'alpha', 'five' ],
261+
[ 'alpha', nil ],
260262
])
261263
end
262264

@@ -269,6 +271,7 @@
269271
task 'three' assign: alpha
270272
task alpha with: 'four'
271273
alpha task: 'five'
274+
task alpha
272275
},
273276
wait: true)
274277

@@ -282,6 +285,7 @@
282285
[ 'alpha', 'three' ],
283286
[ 'alpha', 'four' ],
284287
[ 'alpha', 'five' ],
288+
[ 'alpha', nil ],
285289
])
286290
end
287291
end

0 commit comments

Comments
 (0)