[Bps-public-commit] r14854 - in Prophet/trunk: . lib/Prophet/CLI

sartak at bestpractical.com sartak at bestpractical.com
Wed Aug 6 12:26:41 EDT 2008


Author: sartak
Date: Wed Aug  6 12:26:41 2008
New Revision: 14854

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/App.pm
   Prophet/trunk/lib/Prophet/CLI.pm
   Prophet/trunk/lib/Prophet/CLI/Command.pm
   Prophet/trunk/lib/Prophet/Record.pm

Log:


Modified: Prophet/trunk/lib/Prophet/App.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/App.pm	(original)
+++ Prophet/trunk/lib/Prophet/App.pm	Wed Aug  6 12:26:41 2008
@@ -122,20 +122,6 @@
     return 1;
 }
 
-=head2 already_required class
-
-Helper function to test whether a given class has already been require'd.
-
-=cut
-    
-    
-sub already_required {
-    my ($self, $class) = @_;
-    my $path =  join('/', split(/::/,$class)).".pm";
-    return ( $INC{$path} ? 1 : 0);
-}
-
-
 __PACKAGE__->meta->make_immutable;
 no Moose;
 

Modified: Prophet/trunk/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI.pm	Wed Aug  6 12:26:41 2008
@@ -340,23 +340,17 @@
     }
 }
 
-=head2 change_attributes ( args => $hashref, props => $arrayref, type => 'str' )
+=head2 run_another_command ( args => $hashref, props => $hashref, type => 'str' )
 
-A hook for modifying attributes to prepare for running other commands from
-within a command.
-
-C<props> should be an array reference of hashes containing the keys C<prop>,
-C<cmp>, and C<value>, such as what is expected by the C<prop_set> attribute
-(see L<parse_args>'s use of C<add_to_prop_set>).
-
-C<args> should be a simple array of arg / value pairs.
+A hook for running a second command from within a command without having
+to use the commandline argument parsing.
 
 If C<type>, C<uuid>, or C<primary_commands> are not passed in, the values
 from the previous command run are used.
 
 =cut
 
-sub change_attributes {
+sub run_another_command {
     my $self = shift;
     my %args = @_;
 
@@ -372,19 +366,21 @@
         }
     }
     if (my $props = $args{props}) {
-        foreach my $prop (@$props) {
-            my $key = $prop->{prop};
-            my $value = $prop->{value};
-            $self->set_prop($key => $value);
+        foreach my $prop (keys %$props) {
+            $self->set_prop($prop => $props->{$prop});
             $self->add_to_prop_set($prop);
         }
     }
     if (my $type = $args{type}) {
         $self->type($type);
     }
+
     if (my $primary_commands = $args{primary_commands}) {
         $self->primary_commands($primary_commands);
     }
+    if ( my $cmd_obj = $self->_get_cmd_obj() ) {
+        $cmd_obj->run();
+    }
 }
 
 =head2 clear_args
@@ -396,7 +392,7 @@
 sub clear_args {
     my $self = shift;
 
-    foreach my $arg ($self->arg_names) {
+    foreach my $arg ($self->args) {
         $self->delete_arg($arg);
     }
 }
@@ -410,7 +406,7 @@
 sub clear_props {
     my $self = shift;
 
-    foreach my $prop ($self->prop_names) {
+    foreach my $prop ($self->props) {
         $self->delete_prop($prop);
     }
     $self->prop_set( ( ) );

Modified: Prophet/trunk/lib/Prophet/CLI/Command.pm
==============================================================================

Modified: Prophet/trunk/lib/Prophet/Record.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Record.pm	(original)
+++ Prophet/trunk/lib/Prophet/Record.pm	Wed Aug  6 12:26:41 2008
@@ -436,8 +436,7 @@
 =head2 default_props $props_ref
 
 Takes a reference to a hash of props and looks up the defaults for those
-props, if they exist (by way of C<default_prop_$prop> routines). Sets the
-values of the props in the hash to the defaults.
+props, if they exist. Sets the values of the props in the hash to the defaults.
 
 =cut
 
@@ -460,8 +459,7 @@
 
 =head2 _default_summary_format
 
-A string of the default summary format for record types that do not
-define their own summary format.
+returns a formatted string that is the summary for the record.
 
 A summary format should consist of format_string,field pairs, separated
 by | characters.



More information about the Bps-public-commit mailing list