[Rt-commit] r19887 - in rt/3.999/trunk: . lib/RT lib/RT/Lorzy/Package

clkao at bestpractical.com clkao at bestpractical.com
Thu Jun 4 09:13:27 EDT 2009


Author: clkao
Date: Thu Jun  4 09:13:27 2009
New Revision: 19887

Modified:
   rt/3.999/trunk/   (props changed)
   rt/3.999/trunk/lib/RT/Lorzy.pm
   rt/3.999/trunk/lib/RT/Lorzy/Package/RT.pm
   rt/3.999/trunk/t/lorzy/action.t
   rt/3.999/trunk/t/lorzy/condition.t

Log:
 r43270 at mtl-2:  clkao | 2009-06-04 21:11:40 +0800
 deprecate RT.Condition.Applicable in favour of individual condition
 code.
 r43271 at mtl-2:  clkao | 2009-06-04 21:13:10 +0800
 remove fallback code using RT.Condition.Applicable.


Modified: rt/3.999/trunk/lib/RT/Lorzy.pm
==============================================================================
--- rt/3.999/trunk/lib/RT/Lorzy.pm	(original)
+++ rt/3.999/trunk/lib/RT/Lorzy.pm	Thu Jun  4 09:13:27 2009
@@ -16,16 +16,34 @@
     eval { $EVAL->apply_script( $code, \%args ) };
 }
 
+my %cond_compat_map = ( 'On Create' => 'OnCreate',
+                        'On Transaction' => 'OnTransaction',
+                        'On Correspond' => 'OnCorrespond',
+                        'On comment' => 'OnComment',
+                        'On Status Change' => 'OnStatusChange',
+                        'On owner Change' => 'OnOwnerChange',
+                        'On priority Change' => 'OnPriorityChange',
+                        'On Resolve' => 'OnResolve',
+                        'On Close' => 'OnClose',
+                        'On Reopen' => 'OnReopen',
+                        # doesn't work yet
+                        'PriorityExceeds' => 'PriorityExceeds',
+                        'BeforeDue' => 'BeforeDue',
+                        'OverDue' => 'OverDue',
+          );
+
+
 sub create_scripish {
     my ( $class, $scrip_condition, $scrip_action, $template, $description, $queue ) = @_;
     my $sigs = { ticket => Lorzy::FunctionArgument->new( name => 'ticket', type => 'RT::Model::Ticket' ),
         transaction => Lorzy::FunctionArgument->new( name => 'transaction', type => 'RT::Model::Transaction' ) };
     my $builder = Lorzy::Builder->new();
 
+    my $lorzy_cond = $cond_compat_map{$scrip_condition}
+        or die "unsupported compat condition: $scrip_condition";
     my $tree = {
-        name => 'RT.Condition.Applicable',
+        name => 'RT.Condition.'.$lorzy_cond,
         args => {
-            name => $scrip_condition,
             ticket => { name => 'Symbol', args => { symbol => 'ticket' } },
             transaction => { name => 'Symbol', args => { symbol => 'transaction' } }
         } };

Modified: rt/3.999/trunk/lib/RT/Lorzy/Package/RT.pm
==============================================================================
--- rt/3.999/trunk/lib/RT/Lorzy/Package/RT.pm	(original)
+++ rt/3.999/trunk/lib/RT/Lorzy/Package/RT.pm	Thu Jun  4 09:13:27 2009
@@ -2,20 +2,6 @@
 use strict;
 use base 'Lorzy::Package';
 
-# TODO: make create_scripish resolve from this map and call the
-# condtion function here without RT.Condition.Applicable
-
-my %mymap = ( 'On Create' => 'OnCreate',
-              'On Transaction' => 'OnTransaction',
-              'On Correspond' => 'OnCorrespond',
-              'On comment' => 'OnComment',
-              'On Status Change' => 'OnStatusChange',
-              'On owner Change' => 'OnOwnerChange',
-              'On priority Change' => 'OnPriorityChange',
-              'On Resolve' => 'OnResolve',
-              'On Close' => 'OnClose',
-              'On Reopen' => 'OnReopen',
-          );
 
 my $sig_ticket_txn = {
         'ticket' => Lorzy::FunctionArgument->new( name => 'ticket', type => 'RT::Model::Ticket' ),
@@ -160,26 +146,6 @@
     );
 }
 
-__PACKAGE__->defun( 'Condition.Applicable',
-    signature => {
-        'name'   => Lorzy::FunctionArgument->new( name => 'name' ),
-        %$sig_ticket_txn,
-    },
-    native => sub {
-        my $args = shift;
-        my $eval = shift;
-
-        my $lorzy_cond = $mymap{$args->{name}}
-            or die "no compat mapping for scrip condition $args->{name}";
-        $lorzy_cond = 'RT.Condition.'.$lorzy_cond;
-        return $eval->resolve_symbol_name($lorzy_cond)->apply
-            ( $eval,
-              { transaction => $args->{transaction},
-                ticket => $args->{ticket}
-            });
-    },
-);
-
 __PACKAGE__->defun( 'ScripAction.Prepare',
     signature => {
         'name'     => Lorzy::FunctionArgument->new( name => 'name' ),

Modified: rt/3.999/trunk/t/lorzy/action.t
==============================================================================
--- rt/3.999/trunk/t/lorzy/action.t	(original)
+++ rt/3.999/trunk/t/lorzy/action.t	Thu Jun  4 09:13:27 2009
@@ -19,9 +19,8 @@
 my $tree    = [ { name => 'IfThen',
                   args => { if_true => { name => 'True' },
                             if_false => { name => 'False' },
-                            condition => { name => 'RT.Condition.Applicable',
+                            condition => { name => 'RT.Condition.OnCreate',
                                 args => {
-                                    name => "On Create",
                                     ticket => { name => 'Symbol', args => { symbol => 'ticket' }},
                                     transaction => { name => 'Symbol', args => { symbol => 'transaction' }},
                                     }

Modified: rt/3.999/trunk/t/lorzy/condition.t
==============================================================================
--- rt/3.999/trunk/t/lorzy/condition.t	(original)
+++ rt/3.999/trunk/t/lorzy/condition.t	Thu Jun  4 09:13:27 2009
@@ -18,9 +18,8 @@
 $eval->load_package($_) for qw(Str Native);
 $eval->load_package('RT', 'RT::Lorzy::Package::RT');
 
-my $tree    = [ { name => 'RT.Condition.Applicable',
+my $tree    = [ { name => 'RT.Condition.OnCreate',
                   args => {
-                      name => "On Create",
                       ticket => { name => 'Symbol', args => { symbol => 'ticket' }},
                       transaction => { name => 'Symbol', args => { symbol => 'transaction' }},
                   }


More information about the Rt-commit mailing list