[Bps-public-commit] Prophet branch, master, updated. 0.742-6-ga517a0b

Shawn Moore sartak at bestpractical.com
Fri Jun 18 15:25:12 EDT 2010


The branch, master has been updated
       via  a517a0b848b54a578d7c7751b52d3218bb45234d (commit)
      from  d3baf555a545bf5dc4f145ef5cf5df5a0188abd6 (commit)

Summary of changes:
 lib/Prophet/CLI/Dispatcher.pm               |   23 ++++++++++++++++-------
 lib/Prophet/CLI/Dispatcher/Rule/RecordId.pm |    4 +++-
 2 files changed, 19 insertions(+), 8 deletions(-)

- Log -----------------------------------------------------------------
commit a517a0b848b54a578d7c7751b52d3218bb45234d
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Jun 18 15:26:11 2010 -0400

    Use the RecordId rule

diff --git a/lib/Prophet/CLI/Dispatcher.pm b/lib/Prophet/CLI/Dispatcher.pm
index ab1d36c..7842de2 100644
--- a/lib/Prophet/CLI/Dispatcher.pm
+++ b/lib/Prophet/CLI/Dispatcher.pm
@@ -3,7 +3,7 @@ use Path::Dispatcher::Declarative -base;
 use Any::Moose;
 extends 'Path::Dispatcher::Declarative', any_moose('Object');
 
-require Prophet::CLIContext;
+use Prophet::CLI::Dispatcher::Rule::RecordId;
 
 with 'Prophet::CLI::Parameters';
 
@@ -57,12 +57,21 @@ under settings => sub {
     };
 };
 
-on [ qr/^(update|edit|show|display|delete|del|rm|history)$/,
-     qr/^$Prophet::CLIContext::ID_REGEX$/i ] => sub {
-    my $self = shift;
-    $self->context->set_id_from_primary_commands;
-    run($1, $self, @_);
-};
+dispatcher->add_rule(
+    Path::Dispatcher::Rule::Sequence->new(
+        rules => [
+            Path::Dispatcher::Rule::Regex->new(
+                regex => qr/^(update|edit|show|display|delete|del|rm|history)$/,
+            ),
+            Prophet::CLI::Dispatcher::Rule::RecordId->new,
+        ],
+        block => sub {
+            my $self = shift;
+            $self->context->set_id_from_primary_commands;
+            run($1, $self, @_);
+        },
+    )
+);
 
 on [ [ 'update', 'edit' ] ]      => run_command("Update");
 on [ [ 'show', 'display' ] ]     => run_command("Show");
diff --git a/lib/Prophet/CLI/Dispatcher/Rule/RecordId.pm b/lib/Prophet/CLI/Dispatcher/Rule/RecordId.pm
index cd610e0..06eb914 100644
--- a/lib/Prophet/CLI/Dispatcher/Rule/RecordId.pm
+++ b/lib/Prophet/CLI/Dispatcher/Rule/RecordId.pm
@@ -3,8 +3,10 @@ use Any::Moose;
 extends 'Path::Dispatcher::Rule::Regex';
 with 'Prophet::CLI::Dispatcher::Rule';
 
+use Prophet::CLIContext;
+
 has '+regex' => (
-    default => qr/^$Prophet::CLIContext::ID_REGEX$/i,
+    default => sub { qr/^$Prophet::CLIContext::ID_REGEX$/i },
 );
 
 __PACKAGE__->meta->make_immutable;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list