Flexible and extensible dispatch
We really like Jifty::Dispatcher and wanted to use it for Prophet's command
line.
The basic operation is that of dispatch. Dispatch takes a path and a list
of rules, and it returns a list of matches. From there you can "run" the
rules that matched. These phases are distinct so that, if you need to, you
can inspect which rules were matched without ever running their codeblocks.
Tab completion support is also available (see in particular
Path::Dispatcher::Cookbook/How can I configure tab completion for shells?)
for the dispatchers you write.
Each rule may take a variety of different forms (which I think justifies
the "flexible" adjective in the module's description). Some of the rule
types are:
* Path::Dispatcher::Rule::Regex
Matches the path against a regular expression.
* Path::Dispatcher::Rule::Enum
Match one of a set of strings.
* Path::Dispatcher::Rule::CodeRef
Execute a coderef to determine whether the path matches the rule. So you
can do anything you like. Though writing a domain-specific rule (see below)
will enable better introspection and encoding intent.
* Path::Dispatcher::Rule::Dispatch
Use another Path::Dispatcher to match the path. This facilitates both
extending dispatchers (a bit like subclassing) and delegating to plugins.
Since Path::Dispatcher is designed with good object-oriented programming
practices, you can also write your own domain-specific rule classes (which
earns it the "extensible" adjective). For example, in Prophet, we have a
custom rule for matching, and tab completing, record IDs.
You may want to use Path::Dispatcher::Declarative which gives you some
sugar inspired by Jifty::Dispatcher.
- Sources inherited from project devel:languages:perl
- Download package
-
Checkout Package
osc -A https://api.opensuse.org checkout home:Tomcat42/perl-Path-Dispatcher && cd $_
- Create Badge
Source Files
Filename | Size | Changed |
---|---|---|
Path-Dispatcher-1.08.tar.gz | 0000050388 49.2 KB | |
perl-Path-Dispatcher.changes | 0000000156 156 Bytes | |
perl-Path-Dispatcher.spec | 0000003869 3.78 KB |
Latest Revision
- initial version 1.08
Comments 0