No description, website, or topics provided.
Other
Switch branches/tags
Nothing to show
Latest commit b6ab47f Apr 22, 2017 @MARTIMM committed on GitHub Merge pull request #1 from samcv/license-SPDX
Use SPDX identifier in license field of META6.json
Permalink
Failed to load latest commit information.
doc readme doc and version change Jan 2, 2017
lib/Tinky removed dependency after tests are complete Jan 2, 2017
t latest download of rakudo star for appveyor and subtest changes Jan 4, 2017
xt bug fixed in go-state() Jan 1, 2017
.gitignore setup Dec 30, 2016
.travis.yml
LICENSE setup Dec 30, 2016
META6.json Use SPDX identifier in license field of META6.json Apr 21, 2017
README.md Update README.md Mar 8, 2017
appveyor.yml

README.md

Configuration refinements

Build Status AppVeyor Build Status License

Synopsis

use Tinky::Hash;

class MyStateEngine is Tinky::Hash {

  submethod BUILD ( ) {

    self.from-hash(
      :config( {
          :states([< a z q>]),
          :transitions( {
              :az( { :from<a>, :to<z>}),
              :za( { :from<z>, :to<a>}),
              :zq( { :from<z>, :to<q>}),
              :qa( { :from<q>, :to<a>}),
            }
          ),
          :workflow( { :name<wf4>, :initial-state<a>}),
          :taps( {
              :states( { :q( { :enter<enter-q>})})
              :transitions( { :zq<tr-zq>}),
            }
          ),
        }
      )
    );
  }

  method tr-zq ( $object, Tinky::Transition $trans, Str :$transit ) {
    say "specific transition $transit '", $object.^name,
        "' '$trans.from.name()' ===>> '$trans.to.name()'";
    is $trans.from.name, 'z', "Comes from 'z'";
    is $trans.to.name, 'q', "Goes to 'q'";
  }

  method enter-q ( $object, Str :$state, EventType :$event) {
    say "state enter event: enter q in ", $object.^name;
    is $state, 'q', 'state is q';
    is $event, Enter, 'event is Enter';
  }
}

my MyStateEngine $th .= new;

$th.workflow('wf4');
say $th.state.name;             # 'a'
say $th.next-states>>.name;     # ('z',)

$th.go-state('z');
say $th.state.name;             # 'z'
say $th.next-states>>.name;     # (<a q>)

# specific transition zq 'MyStateEngine' 'z' ===>> 'q'
# state enter event: enter q in MyStateEngine

$th.go-state('q');


Documentation

Please look also at the Tinky documentation of Jonathon Stowe and his story at the perl6 advent calendar 18th december 2016 to understand the purpose of Tinky. After that it will be easy to grasp the use of this module.

Documentation about this class and other information at

Author

Marcel Timmerman: MARTIMM on github