From e56763721e595bd3337d7aadd688c47b545b3d8b Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 1 Apr 2017 23:07:14 +0200 Subject: Mark some functions private Signed-off-by: Florian Pritz --- lib/App/BorgRestore.pm | 22 +++++++++++----------- t/02_parsing.t | 2 +- t/03_timespec.t | 18 +++++++++--------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/App/BorgRestore.pm b/lib/App/BorgRestore.pm index 3e76c0d..6d3d5c7 100644 --- a/lib/App/BorgRestore.pm +++ b/lib/App/BorgRestore.pm @@ -124,7 +124,7 @@ sub select_archive_timespec { my $archives = shift; my $timespec = shift; - my $seconds = $self->timespec_to_seconds($timespec); + my $seconds = $self->_timespec_to_seconds($timespec); if (!defined($seconds)) { say STDERR "Error: Invalid time specification"; return; @@ -150,7 +150,7 @@ sub format_timestamp { return POSIX::strftime "%a. %F %H:%M:%S %z", localtime $timestamp; } -sub timespec_to_seconds { +sub _timespec_to_seconds { my $self = shift; my $timespec = shift; @@ -213,7 +213,7 @@ sub restore { $self->{borg}->restore($components_to_strip, $archive_name, $path); } -sub add_path_to_hash { +sub _add_path_to_hash { my $self = shift; my $hash = shift; my $path = shift; @@ -259,7 +259,7 @@ sub get_missing_items { return $ret; } -sub handle_removed_archives { +sub _handle_removed_archives { my $self = shift; my $borg_archives = shift; @@ -286,7 +286,7 @@ sub handle_removed_archives { } } -sub handle_added_archives { +sub _handle_added_archives { my $self = shift; my $borg_archives = shift; @@ -307,7 +307,7 @@ sub handle_added_archives { if ($line =~ m/^.{4} (?....)-(?..)-(?..) (?..):(?..):(?..) (?.+)$/) { my $time = POSIX::mktime($+{second},$+{minute},$+{hour},$+{day},$+{month}-1,$+{year}-1900); #$log->debugf("Adding path %s with time %s", $+{path}, $time); - $self->add_path_to_hash($lookuptable, $+{path}, $time); + $self->_add_path_to_hash($lookuptable, $+{path}, $time); } }); @@ -316,7 +316,7 @@ sub handle_added_archives { $self->{db}->begin_work; $self->{db}->add_archive_name($archive); my $archive_id = $self->{db}->get_archive_id($archive); - $self->save_node($archive_id, undef, $lookuptable); + $self->_save_node($archive_id, undef, $lookuptable); $self->{db}->commit; $self->{db}->vacuum; @@ -334,13 +334,13 @@ sub build_archive_cache { $log->debugf("Found %d archives in db", scalar(@$archives)); - $self->handle_removed_archives($borg_archives); - $self->handle_added_archives($borg_archives); + $self->_handle_removed_archives($borg_archives); + $self->_handle_added_archives($borg_archives); $log->debugf("DB contains information for %d archives in %d rows", scalar(@{$self->{db}->get_archive_names()}), $self->{db}->get_archive_row_count()); } -sub save_node { +sub _save_node { my $self = shift; my $archive_id = shift; my $prefix = shift; @@ -354,7 +354,7 @@ sub save_node { my $time = $$node[0]->{$child}[1]; $self->{db}->add_path($archive_id, $path, $time); - $self->save_node($archive_id, $path, $$node[0]->{$child}); + $self->_save_node($archive_id, $path, $$node[0]->{$child}); } } diff --git a/t/02_parsing.t b/t/02_parsing.t index 8f3bcfb..b8e2d64 100644 --- a/t/02_parsing.t +++ b/t/02_parsing.t @@ -28,7 +28,7 @@ $borg->mock('list_archive', sub { # Call the actual function we want to test my $app = App::BorgRestore->new({borg => $borg, db => $db}); -$app->handle_added_archives(['archive-1'], $db); +$app->_handle_added_archives(['archive-1'], $db); # Check if $db->add_path has been called properly my (@calls, @a); diff --git a/t/03_timespec.t b/t/03_timespec.t index ae1b1e5..0f367c9 100644 --- a/t/03_timespec.t +++ b/t/03_timespec.t @@ -7,15 +7,15 @@ use App::BorgRestore; my $app = App::BorgRestore->new_no_defaults(undef); -is($app->timespec_to_seconds('5s'), 5, '5 seconds'); -is($app->timespec_to_seconds('5minutes'), 5*60, '5 minutes'); -is($app->timespec_to_seconds('6d'), 6*60*60*24, '6 days'); -is($app->timespec_to_seconds('8m'), 8*60*60*24*31, '8 months'); -is($app->timespec_to_seconds('2y'), 2*60*60*24*365, '2 years'); +is($app->_timespec_to_seconds('5s'), 5, '5 seconds'); +is($app->_timespec_to_seconds('5minutes'), 5*60, '5 minutes'); +is($app->_timespec_to_seconds('6d'), 6*60*60*24, '6 days'); +is($app->_timespec_to_seconds('8m'), 8*60*60*24*31, '8 months'); +is($app->_timespec_to_seconds('2y'), 2*60*60*24*365, '2 years'); -is($app->timespec_to_seconds('5sec'), undef, 'invalid unit returns undef'); -is($app->timespec_to_seconds('5'), undef, 'missing unit returns undef'); -is($app->timespec_to_seconds('blub'), undef, 'string returns undef'); -is($app->timespec_to_seconds(''), undef, 'empty string returns undef'); +is($app->_timespec_to_seconds('5sec'), undef, 'invalid unit returns undef'); +is($app->_timespec_to_seconds('5'), undef, 'missing unit returns undef'); +is($app->_timespec_to_seconds('blub'), undef, 'string returns undef'); +is($app->_timespec_to_seconds(''), undef, 'empty string returns undef'); done_testing; -- cgit v1.2.3-24-g4f1b