[otrs-cvs] otrs/bin otrs.CheckModules.pl,1.45,1.46

"CVS commits notifications of OTRS.org" <[email protected]>
Newsgroups gmane.comp.otrs.cvs
Message-ID <[email protected]>
Comments:
Update of /home/cvs/otrs/bin
In directory lancelot:/tmp/cvs-serv21974/bin

Modified Files:
	otrs.CheckModules.pl 
Log Message:
Improved logic for module checking. Added ANSI terminal coloring for the statuses.

Author: mg

Index: otrs.CheckModules.pl
===================================================================
RCS file: /home/cvs/otrs/bin/otrs.CheckModules.pl,v
retrieving revision 1.45
retrieving revision 1.46
diff -2 -u -d -r1.45 -r1.46
--- otrs.CheckModules.pl	14 Jan 2013 16:26:36 -0000	1.45
+++ otrs.CheckModules.pl	15 Jan 2013 10:04:18 -0000	1.46
@@ -32,4 +32,5 @@
 
 use ExtUtils::MakeMaker;
+use Term::ANSIColor;
 
 use vars qw($VERSION);
@@ -485,9 +486,7 @@
     my ( $Module, $Depends ) = @_;
 
-    for ( 0 .. $Depends ) {
-        print "   ";
-    }
+    print "  " x ( $Depends + 1 );
     print "o $Module->{Module}";
-    my $Length = 33 - ( length( $Module->{Module} ) + ( $Depends * 3 ) );
+    my $Length = 33 - ( length( $Module->{Module} ) + ( $Depends * 2 ) );
     print '.' x $Length;
 
@@ -505,9 +504,9 @@
         );
 
+        my $ErrorMessage;
+
         # test if all module dependencies are installed by requiring the module
-        my $MissingDependencies;
         if ( !eval "require $Module->{Module}" ) {
-            print "failed!!! Not all prerequisites installed. ";
-            $MissingDependencies = 1;
+            $ErrorMessage .= 'Not all prerequisites for this module correctly installed. ';
         }
 
@@ -530,6 +529,5 @@
 
             if ($NotSupported) {
-                print "failed!!! Version $Version not supported! $NotSupported\n";
-                return;
+                $ErrorMessage .= "Version $Version not supported! $NotSupported ";
             }
         }
@@ -538,33 +536,33 @@
 
             # cleanup item version number
-            my $ModuleVersion = _VersionClean(
+            my $RequiredModuleVersion = _VersionClean(
                 Version => $Module->{Version},
             );
 
-            if ( $CleanedVersion >= $ModuleVersion ) {
-                print "ok (v$Version)\n";
-            }
-            else {
-                print
-                    "failed!!! Version $Version installed but $Module->{Version} or higher is required!\n";
+            if ( $CleanedVersion < $RequiredModuleVersion ) {
+                $ErrorMessage
+                    .= "Version $Version installed but $Module->{Version} or higher is required! ";
             }
         }
-        elsif ($MissingDependencies) {
-            print "(v$Version)\n";
+
+        if ($ErrorMessage) {
+            print color('red') . "FAILED!" . color('reset') . " $ErrorMessage\n";
         }
         else {
-            print "ok (v$Version)\n";
+            print color('green') . "ok" . color('reset') . " (v$Version)\n";
         }
     }
     else {
-        my $Comment = $Module->{Comment} || '';
+        my $Comment  = $Module->{Comment} || '';
         my $Required = $Module->{Required};
+        my $Color    = 'yellow';
         if ($Required) {
-            $Required = 'Required - use "perl -MCPAN -e shell;"';
+            $Required = 'required - use "perl -MCPAN -e shell;"';
+            $Color    = 'red';
         }
         else {
-            $Required = 'Optional';
+            $Required = 'optional';
         }
-        print "Not installed! ($Required - $Comment)\n";
+        print color($Color) . "Not installed!" . color('reset') . " ($Required - $Comment)\n";
     }
 
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.