Commits

Anonymous committed 0654b7e

Extracted out the _add method to append an item to the queue.

Comments (0)

Files changed (1)

File-Dir-Dumper/lib/File/Dir/Dumper/Scanner.pm

 
     $self->_queue([]);
 
-    push @{$self->_queue()}, { type => "header", dir_to_dump => $dir_to_dump};
+    $self->_add({ type => "header", dir_to_dump => $dir_to_dump});
     
     return;
 }
 
+sub _add
+{
+    my $self = shift;
+    my $token = shift;
+
+    push @{$self->_queue()}, $token;
+
+    return;
+}
+
 sub fetch
 {
     my $self = shift;
 
     if (! $last_result)
     {
-        push @{$self->_queue()}, { type => "dir", depth => 0 };
+        $self->_add({ type => "dir", depth => 0 });
     }
     else
     {
         if ($result->is_dir())
         {
-             push @{$self->_queue()},
+            $self->_add(
                 {
                     type => "dir",
                     filename => $result->full_components()->[-1],
                     depth => scalar(@{$result->full_components()}),
-                };
+                }
+            );
         }
         else
         {
             my @stat = stat($result->path());
-            push @{$self->_queue()},
+            $self->_add(
                 {
                     type => "file",
                     filename => $result->basename(),
                     mtime => strftime("%Y-%m-%dT%H:%M:%S", localtime($stat[9])),
                     size => $stat[7],
                     depth => scalar(@{$result->full_components()}),
-                };
+                }
+            );
         }
     }