Skip to content

Commit 06db9c2

Browse files
committed
Some renaming and a light spring clean
1 parent 418b41a commit 06db9c2

15 files changed

+65
-60
lines changed

Changes

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v0.1.0 Mon 18 Jan 10:15:01 GMT 2021
2+
* Light renaming
3+
* Move CI to github actions
14
v0.0.8 Wed 13 Mar 21:24:52 GMT 2019
25
* Small change to support Tinky::DB
36
v0.0.7 Tue 29 Jan 19:20:46 GMT 2019

Documentation.md

+33-32
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ SYNOPSIS
3636

3737
my $open = Tinky::Transition.new(name => 'open', from => $state-new, to => $state-open);
3838

39-
# Where more than one transition has the same name, the transition which matches the object's
39+
# Where more than one transition has the same name, the transition which matches the object's
4040
# current state will be use.
4141
my $reject-new = Tinky::Transition.new(name => 'reject', from => $state-new, to => $state-rejected);
4242
my $reject-open = Tinky::Transition.new(name => 'reject', from => $state-open, to => $state-rejected);
@@ -64,7 +64,7 @@ SYNOPSIS
6464
my $workflow = Tinky::Workflow.new(:@transitions, name => 'ticket-workflow', initial-state => $state-new );
6565

6666
# The workflow aggregates the Supplies of the transitions and the states.
67-
# This could be to a logging subsystem for instance.
67+
# This could be to a logging subsystem for instance.
6868

6969
$workflow.transition-supply.act(-> ($trans, $object) { say "Ticket '{ $object.ticket-number }' went from { $trans.from.name }' to '{ $trans.to.name }'" });
7070

@@ -126,8 +126,8 @@ All those subroutines that would accept the supplied Tinky::Object will be calle
126126

127127
A similar mechanism is used for method callbacks.
128128

129-
class Tinky::State
130-
-------------------
129+
class Tinky::State
130+
------------------
131131

132132
The [Tinky::State](Tinky::State) is the managed state that is applied to an object, it provides a mechanism for validating whether on object should enter or leave a particular state and supplies that emit objects that have entered or left a given state.
133133

@@ -143,7 +143,7 @@ The constructor must be supplied with a `name` named parameter which must be uni
143143

144144
method enter(Object:D $object)
145145

146-
This is called with the [Tinky::Object](Tinky::Object) instance when the state has been entered by the object, the default implementation arranges for the object to be emitted on the `enter-supply`, so if it is over-ridden in a sub-class it should nonetheless call the base implementation with `nextsame` in order to provide the object to the supply. It would probably be better however to simply tap the [enter-supply](enter-supply).
146+
This is called with the [Tinky::Object](Tinky::Object) instance when the state has been entered by the object, the default implementation arranges for the object to be emitted on the `enter-supply`, so if it is over-ridden in a sub-class it should nonetheless call the base implementation with `nextsame` in order to provide the object to the supply. It would probably be better however to simply tap the [enter-supply](enter-supply).
147147

148148
### method validate-enter
149149

@@ -161,15 +161,15 @@ This returns a [Supply](Supply) to which is emitted each object that has success
161161

162162
method leave(Object:D $object)
163163

164-
This is called when an object leaves this state, with the object instance as the argument. Like <enter> the default implementation provides for the object to emitted on the `leave-supply` so any over-ride implementation should arrange to call this base method. Typically it would be preferred to tap the `leave-supply` if some action is required on leaving a state.
164+
This is called when an object leaves this state, with the object instance as the argument. Like <enter> the default implementation provides for the object to emitted on the `leave-supply` so any over-ride implementation should arrange to call this base method. Typically it would be preferred to tap the `leave-supply` if some action is required on leaving a state.
165165

166166
### method validate-leave
167167

168168
method validate-leave(Object $object) returns Promise
169169

170170
This is called prior to the transition being actually performed and returns a [Promise](Promise) that will be kept with [True](True) if all of the leave validators return True, or False otherwise. It can be over-ridden in a sub-class if some other validation mechanism to the callbacks is required, but **must** return a [Promise](Promise)
171171

172-
### method leave-supply
172+
### method leave-supply
173173

174174
method leave-supply() returns Supply
175175

@@ -183,8 +183,8 @@ This returns a sensible string representation of the State,
183183

184184
### method ACCEPTS
185185

186-
multi method ACCEPTS(State:D $state) returns Bool
187-
multi method ACCEPTS(Transition:D $transition) returns Bool
186+
multi method ACCEPTS(State:D $state) returns Bool
187+
multi method ACCEPTS(Transition:D $transition) returns Bool
188188
multi method ACCEPTS(Object:D $object) returns Bool
189189

190190
This provides for smart-matching against another [State](State) ( returning true if they evaluate to the same state,) a [Transition](Transition) ( returning True if the `from` State of the transition is the same as this state,) or a [Tinky::Object](Tinky::Object) ( returnning True if the Object is at the State.)
@@ -215,16 +215,16 @@ Alternatively a sub-class can define validator methods with the `leave-validator
215215

216216
This may be useful if you have fixed states and wish to substitute runtime complexity.
217217

218-
class Tinky::Transition
219-
------------------------
218+
class Tinky::Transition
219+
-----------------------
220220

221221
A transition is the configured change between two pre-determined states, Only changes described by a transition are allowed to be performed. The transaction class provides for validators that can indicate whether the transition should be applied to an object (distinct from the enter or leave state validators,) and provides a separate supply that emits the object whenever the transition is succesfully applied to an object's state. This higher level of granularity may simplify application logic when in some circumstances than taking both from state and to state individually.
222222

223223
### method new
224224

225225
method new(Tinky::Transition:U: Str :$!name!, Tinky::State $!from!, Tinky::State $!to!, :@!validators)
226226

227-
The constructor of the class, The `name` parameter must be supplied, it need not be unique but will be used to create a helper method that will be applied to the target Object when the workflow is applied so should be a valid Perl 6 identifier. The mechanism for creating these methods is decribed under [Tinky::Workflow](Tinky::Workflow).
227+
The constructor of the class, The `name` parameter must be supplied, it need not be unique but will be used to create a helper method that will be applied to the target Object when the workflow is applied so should be a valid Raku identifier. The mechanism for creating these methods is decribed under [Tinky::Workflow](Tinky::Workflow).
228228

229229
The `from` and `to` states must be supplied, A transition can only be supplied to an object that has a current state that matches `from`.
230230

@@ -248,7 +248,7 @@ This can be over-ridden in a sub-class if some other validation mechanism is to
248248

249249
method validate-apply(Object:D $object) returns Promise
250250

251-
This is the top-level method that is used to check whether a transition should be applied, it returns a Promise that will be kept with True if all of the promises returned by the transition's `validate`, the `from` state's `leave-validate` and the `to` state's `enter-validate` are kept with True.
251+
This is the top-level method that is used to check whether a transition should be applied, it returns a Promise that will be kept with True if all of the promises returned by the transition's `validate`, the `from` state's `leave-validate` and the `to` state's `enter-validate` are kept with True.
252252

253253
It is unlikely that this would need to over-ridden but any sub-class implementation must return a Promise that will be kept with a Bool.
254254

@@ -268,10 +268,10 @@ Returns a plausible string representation of the transition.
268268

269269
### method ACCEPTS
270270

271-
multi method ACCEPTS(State:D $state) returns Bool
271+
multi method ACCEPTS(State:D $state) returns Bool
272272
multi method ACCEPTS(Object:D $object) returns Bool
273273

274-
This is used to smart match the transition against either a [Tinky::State](Tinky::State) (returning True if the State matches the transition's `from` state,) or a [Tink::Object](Tink::Object) (returning True if the object's current state matches the transition's `from` state.)
274+
This is used to smart match the transition against either a [Tinky::State](Tinky::State) (returning True if the State matches the transition's `from` state,) or a [Tinky::Object](Tinky::Object) (returning True if the object's current state matches the transition's `from` state.)
275275

276276
### attribute validators
277277

@@ -285,10 +285,10 @@ Alternatively validators can be supplied as methods with the `transition-validat
285285

286286
The same rules for execution based on the signature and the object to which the transition is being applied are true for methods as for validation subroutines.
287287

288-
class Tinky::Workflow
289-
----------------------
288+
class Tinky::Workflow
289+
---------------------
290290

291-
The [Tinky::Workflow](Tinky::Workflow) class brings together a collection of transitions together and provides additional functionality to objects that consume the workflow as well as aggregating the various [Supply](Supply)s that are provided by State and Transition.
291+
The [Tinky::Workflow](Tinky::Workflow) class brings together a collection of transitions together and provides additional functionality to objects that consume the workflow as well as aggregating the various [Supply](Supply)s that are provided by State and Transition.
292292

293293
Whilst it is possible that standalone transitions can be applied to any object that does the [Tinky::Object](Tinky::Object) role, certain functionality is not available if workflow is not known.
294294

@@ -390,10 +390,10 @@ Alternatively validators can be supplied as methods with the `apply-validator` t
390390

391391
The same rules for execution based on the signature and the object to which the transition is being applied are true for methods as for validation subroutines.
392392

393-
role Tinky::Object
394-
-------------------
393+
role Tinky::Object
394+
------------------
395395

396-
This is a role that should should be applied to any application object that is to have a state managed by [Tink::Workflow](Tink::Workflow), it provides the mechanisms for transition application and allows the transitions to be validated by the mechanisms described above for [Tinky::State](Tinky::State) and [Tinky::Transition](Tinky::Transition)
396+
This is a role that should should be applied to any application object that is to have a state managed by [Tinky::Workflow](Tinky::Workflow), it provides the mechanisms for transition application and allows the transitions to be validated by the mechanisms described above for [Tinky::State](Tinky::State) and [Tinky::Transition](Tinky::Transition)
397397

398398
### method state
399399

@@ -435,52 +435,53 @@ This returns the transition that would place the object in the supplied state fr
435435

436436
### method ACCEPTS
437437

438-
multi method ACCEPTS(State:D $state) returns Bool
438+
multi method ACCEPTS(State:D $state) returns Bool
439439
multi method ACCEPTS(Transition:D $trans) returns Bool
440440

441441
Used to smart match the object against either a State (returns True if the state matches the current state of the object,) or a Transition (returns True if the `from` state matches the current state of the object.)
442442

443443
EXCEPTIONS
444444
----------
445445

446-
The methods for applying a transition to an object will signal an inability to apply the transition by means of an exception.
446+
The methods for applying a transition to an object will signal an inability to apply the transition by means of an exception.
447447

448448
The below documents the location where the exceptions are thrown directly, of course they may be the result of some higher level method.
449449

450-
### class Tinky::X::Fail is Exception
450+
### class Tinky::X::Fail is Exception
451451

452452
This is used as a base class for all of the exceptions thrown by Tinky, it will never be thrown itself.
453453

454454
### class Tinky::X::Workflow is Tinky::X::Fail
455455

456456
This is an additional sub-class of [Tinky::X::Fail](Tinky::X::Fail) that is used by some of the other exceptions.
457457

458-
### class Tinky::X::InvalidState is Tinky::X::Workflow
458+
### class Tinky::X::InvalidState is Tinky::X::Workflow
459459

460-
### class Tinky::X::InvalidTransition is Tinky::X::Workflow
460+
### class Tinky::X::InvalidTransition is Tinky::X::Workflow
461461

462462
This will be thrown by the helper methods provided by the application of the workflow if the current state of the object does match the `from` state of any of the applicable transitions. It will also be thrown by `apply-transition` if the `from` state of the transition supplied doesn't match the current state of the object.
463463

464-
### class Tinky::X::NoTransition is Tinky::X::Fail
464+
### class Tinky::X::NoTransition is Tinky::X::Fail
465465

466466
This will be thrown when attempting to set the state of the object by assignment when there is no transition that goes from the object's current state to the supplied state.
467467

468-
### class Tinky::X::NoWorkflow is Tinky::X::Fail
468+
### class Tinky::X::NoWorkflow is Tinky::X::Fail
469469

470470
This is thrown by `transitions` and `transitions-for-state` on the [Tinky::Object](Tinky::Object) if they are called when no workflow has yet been applied to the object.
471471

472-
### class Tinky::X::NoTransitions is Tinky::X::Fail
472+
### class Tinky::X::NoTransitions is Tinky::X::Fail
473473

474474
This is thrown by the [Workflow](Workflow) `states` method if it is called and there are no transitions defined.
475475

476-
### class Tinky::X::TransitionRejected is Tinky::X::Fail
476+
### class Tinky::X::TransitionRejected is Tinky::X::Fail
477477

478478
This is thrown by `apply-transition` when the transition validation resulted in a False value, because the transition, leave state or enter state validators returned false.
479479

480-
### class Tinky::X::ObjectRejected is Tinky::X::Fail
480+
### class Tinky::X::ObjectRejected is Tinky::X::Fail
481481

482482
This is thrown on `apply-workflow` if one or more of the workflow's apply validators returned false.
483483

484-
### class Tinky::X::NoState is Tinky::X::Fail
484+
### class Tinky::X::NoState is Tinky::X::Fail
485485

486486
This will be thrown by apply-transition if there is no current state on the object.
487+

META6.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Tinky",
3-
"version": "0.0.8",
3+
"version": "0.1.0",
44
"auth": "github:jonathanstowe",
55
"api": "1.0",
66
"description": "An Experimental Workflow / State Management toolit",
@@ -11,6 +11,7 @@
1111
"bugtracker": "https://github.com/jonathanstowe/Tinky/issues"
1212
},
1313
"perl": "6.*",
14+
"raku": "6.*",
1415
"resources": [ ],
1516
"build-depends": [ ],
1617
"depends": [ ],
@@ -29,5 +30,5 @@
2930
"authors": [
3031
"Jonathan Stowe <jns+git@gellyfish.co.uk>"
3132
],
32-
"meta-version": "0"
33+
"meta-version": "1"
3334
}

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Tinky
22

3-
An experimental workflow module for Perl 6
3+
An experimental workflow module for Raku
44

55
[![Build Status](https://travis-ci.org/jonathanstowe/Tinky.svg?branch=master)](https://travis-ci.org/jonathanstowe/Tinky)
66

@@ -9,6 +9,7 @@ An experimental workflow module for Perl 6
99
This is quite long [skip to the Description](#description) if you are impatient.
1010

1111
```perl6
12+
1213
use Tinky;
1314

1415

@@ -126,7 +127,7 @@ transition application,) is provided by Supplies which are available at
126127

127128
I have taken somewhat of a "kitchen-sink" toolkit approach with this to
128129
provide a somewhat rich interface that can be more easily used to create
129-
higher level applications which interact nicely with Perl 6's reactive
130+
higher level applications which interact nicely with Raku's reactive
130131
and composable nature. I've taken some ideas from similar software in
131132
other languages that I have used and added features that I would have
132133
liked for the problems that I was solving and ended up providing myself.
@@ -144,8 +145,7 @@ The full documentation is available [here](Documentation.md).
144145

145146
## Installation
146147

147-
Assuming you have a working perl6 installation you should be able to
148-
install this with *zef* :
148+
Assuming you have a working Rakudo installation you should be able to install this with *zef* :
149149

150150
# From the source directory
151151

@@ -169,4 +169,4 @@ This is free software.
169169

170170
Please see the [LICENCE](LICENCE) file in the distribution.
171171

172-
© Jonathan Stowe 2016 - 2019
172+
© Jonathan Stowe 2016 - 2021

examples/encode-files

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,4 @@ multi sub MAIN($dir, Str :$out-dir = '/tmp/flac') {
124124
}
125125
}
126126

127-
# vim: expandtab shiftwidth=4 ft=perl6
127+
# vim: expandtab shiftwidth=4 ft=raku

examples/synopsis

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!perl6
1+
#!/usr/bin/env raku
22

33
use Tinky;
44

lib/Tinky.pm

+3-3
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ from state and to state individually.
308308
The constructor of the class, The C<name> parameter must be supplied,
309309
it need not be unique but will be used to create a helper method that
310310
will be applied to the target Object when the workflow is applied so
311-
should be a valid Perl 6 identifier. The mechanism for creating these
311+
should be a valid Raku identifier. The mechanism for creating these
312312
methods is decribed under L<Tinky::Workflow>.
313313
314314
The C<from> and C<to> states must be supplied, A transition can only
@@ -727,7 +727,7 @@ current state on the object.
727727
728728
=end pod
729729

730-
module Tinky:ver<0.0.8>:auth<github:jonathanstowe>:api<1.0> {
730+
module Tinky:ver<0.1.0>:auth<github:jonathanstowe>:api<1.0> {
731731

732732
# Stub here, definition below
733733
class State { ... };
@@ -1170,4 +1170,4 @@ module Tinky:ver<0.0.8>:auth<github:jonathanstowe>:api<1.0> {
11701170
}
11711171
}
11721172
}
1173-
# vim: expandtab shiftwidth=4 ft=perl6
1173+
# vim: expandtab shiftwidth=4 ft=raku

t/001-meta.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!perl6
1+
#!/usr/bin/env raku
22

33
use v6;
44

@@ -36,4 +36,4 @@ else {
3636

3737

3838
done-testing;
39-
# vim: expandtab shiftwidth=4 ft=perl6
39+
# vim: expandtab shiftwidth=4 ft=raku

t/010-use.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!perl6
1+
#!/usr/bin/env raku
22

33
use v6;
44

@@ -7,4 +7,4 @@ use Test;
77
use-ok('Tinky', 'Can load "Tinky" ok');
88

99
done-testing;
10-
# vim: expandtab shiftwidth=4 ft=perl6
10+
# vim: expandtab shiftwidth=4 ft=raku

t/020-matches.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!perl6
1+
#!/usr/bin/env raku
22

33
use v6;
44

@@ -32,4 +32,4 @@ ok @transitions[0] ~~ $obj, "transition matches object";
3232

3333

3434
done-testing;
35-
# vim: expandtab shiftwidth=4 ft=perl6
35+
# vim: expandtab shiftwidth=4 ft=raku

t/030-apply-simple.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!perl6
1+
#!/usr/bin/env raku
22

33
use v6;
44

@@ -27,4 +27,4 @@ $obj = FooTest.new;
2727
throws-like { $obj.apply-transition(@transitions[0]) }, Tinky::X::NoState, "should throw X::NoState with apply-transition and state not set";
2828

2929
done-testing;
30-
# vim: expandtab shiftwidth=4 ft=perl6
30+
# vim: expandtab shiftwidth=4 ft=raku

t/040-workflow-object.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!perl6
1+
#!/usr/bin/env raku
22

33
use v6;
44

@@ -76,4 +76,4 @@ subtest {
7676
}, "initial state on Workflow";
7777

7878
done-testing;
79-
# vim: expandtab shiftwidth=4 ft=perl6
79+
# vim: expandtab shiftwidth=4 ft=raku

t/050-supplies.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!perl6
1+
#!/usr/bin/env raku
22

33
use v6;
44

@@ -57,4 +57,4 @@ ok $final, "and got the final event";
5757
is $applied, 1, "and we saw the application of the workflow";
5858

5959
done-testing;
60-
# vim: expandtab shiftwidth=4 ft=perl6
60+
# vim: expandtab shiftwidth=4 ft=raku

t/060-callbacks.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!perl6
1+
#!/usr/bin/env raku
22

33
use v6;
44

@@ -190,4 +190,4 @@ lives-ok { WorkflowGood.new.apply-workflow($apply-wf-meths) }, "Workflow.apply-w
190190

191191

192192
done-testing;
193-
# vim: expandtab shiftwidth=4 ft=perl6
193+
# vim: expandtab shiftwidth=4 ft=raku

0 commit comments

Comments
 (0)