]> Frank Brehm's Git Trees - my-stuff/perl.git/commitdiff
Sinnvollen Anfang gefunden
authorFrank Brehm <frank@brehm-online.com>
Thu, 13 May 2010 07:59:21 +0000 (07:59 +0000)
committerFrank Brehm <frank@brehm-online.com>
Thu, 13 May 2010 07:59:21 +0000 (07:59 +0000)
git-svn-id: http://svn.brehm-online.com/svn/my-stuff/Perl@63 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa

lib/FrBr/Common/MooseX/App.pm
lib/FrBr/Common/MooseX/Role/Config.pm
lib/FrBr/Common/MooseX/Role/FtpClient.pm

index 04fd6511dc3d496f5ccb5d7edd5f183112037dc5..c7fef5de02e07df99d3a8ecfacca72db53f97612 100644 (file)
@@ -32,7 +32,7 @@ use FindBin;
 use Encode qw( decode_utf8 encode_utf8 );
 use Data::Dump;
 
-use Carp ();
+use Carp;
 
 with 'FrBr::Common::MooseX::Role::CommonOpts';
 
@@ -330,7 +330,7 @@ before BUILD => sub {
 after 'BUILD' => sub {
 
     my $self = shift;
-    $self->init_app() unless $self->app_initialized;
+    $self->_init_app() unless $self->app_initialized;
 
     $self->debug( "Anwendungsobjekt: ", $self ) if $self->verbose >= 3;
     $self->debug( "Bereit zum Kampf - äh - was auch immer." );
@@ -339,22 +339,58 @@ after 'BUILD' => sub {
 
 #---------------------------------
 
-=head2 init_app( )
+=head2 _init_app( )
 
 Initialisiert nach dem BUILD alles.
 
 =cut
 
-sub init_app {
+sub _init_app {
 
     my $self = shift;
 
     $self->debug( "Initialisiere Anwendung ..." );
+    $self->init_app();
     $self->app_initialized(1);
 }
 
 #---------------------------------
 
+=head2 init_app( )
+
+Initialisierung als Haken für andere Rollen und Objekte
+
+=cut
+
+sub init_app {
+
+    my $self = shift;
+
+    $self->debug( "Initialisierung beginnt ..." ) if $self->verbose >= 2;
+
+}
+
+#---------------------------------
+
+=head2 run( )
+
+Dummy-Funktion zum Start der Anwendung nach der Initialisierung.
+
+Muss in abgeleiteten Objekten überschrieben werden.
+
+=cut
+
+sub run {
+
+    my $self = shift;
+
+    $self->error( "run() im " . __PACKAGE__ . "-Objekt ist nur eine Dummy-Funktion." );
+    confess( "Dummy-Funktion." );
+
+}
+
+#---------------------------------
+
 sub _init_log {
 
     my $self = shift;
index a170f4e378950db8bc7f7969afb8124fe7e55a1e..0310f01080a2acb50fb087bb99299877911164f1 100644 (file)
@@ -281,6 +281,9 @@ after 'init_app' => sub {
 
     my $self = shift;
 
+    return if $self->app_initialized;
+
+    $self->debug( "Initialisiere ..." );
     $self->read_config_file();
     $self->evaluate_config();
 
index 5d6401917de18c158266c2f358e86f6a0c42c069..788325f0feea5683f07b231f60bb1a54bd0ad209 100644 (file)
@@ -510,6 +510,8 @@ after 'init_app' => sub {
 
     my $self = shift;
 
+    return if $self->app_initialized;
+
     $self->debug( "Initialisiere ..." );
     if ( $self->verbose >= 2 ) {
 
@@ -605,16 +607,19 @@ sub login_ftp {
     }
     my $ftp = $self->ftp;
 
-    if ( $ftp->login( $self->ftp_user, $self->ftp_password ) ) {
-        $self->debug( "FTP-Login erfolgreich." );
-        $self->_set_ftp_connected(1);
-        return 1;
-    }
-    else {
+    unless ( $ftp->login( $self->ftp_user, $self->ftp_password ) ) {
         $self->warn( sprintf( "FTP-Login misslungen: %s", $ftp->message ) );
+        return undef;
     }
 
-    return undef;
+    $self->debug( "FTP-Login erfolgreich." );
+    $self->_set_ftp_connected(1);
+
+    $self->debug( sprintf( "Wechsele in das FTP-Verzeichnis '%s' ...", $self->ftp_remote_dir->stringify ) );
+    my $result = $ftp->cwd( $self->ftp_remote_dir->stringify );
+    $self->error( sprintf( "Konnte nicht in das FTP-Verzeichnis '%s' wechseln: %s", $self->ftp_remote_dir->stringify, $ftp->message ) ) unless $result;
+
+    return $result;
 
 }