App-BackupPlan

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

         }
      },
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "Archive::Tar" : "1.76",
            "DateTime" : "0.78",
            "File::Find" : "1.15",
            "Log::Log4perl" : "1.33",
            "XML::DOM" : "1.44"
         }
      }
   },
   "release_status" : "stable",
   "version" : "v0.0.11",
   "x_serialization_backend" : "JSON::PP version 2.27400_02"
}

META.yml  view on Meta::CPAN

meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: App-BackupPlan
no_index:
  directory:
    - t
    - inc
requires:
  Archive::Tar: '1.76'
  DateTime: '0.78'
  File::Find: '1.15'
  Log::Log4perl: '1.33'
  XML::DOM: '1.44'
version: v0.0.11
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

Makefile.PL  view on Meta::CPAN

# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
    NAME              => 'App::BackupPlan',
    VERSION_FROM      => 'lib/App/BackupPlan.pm', # finds $VERSION
    LICENSE	  		  => 'perl',
    PREREQ_PM         => {'XML::DOM'      => 1.44,
    	                  'Log::Log4perl' => 1.33,
                          'File::Find'    => 1.15,
                          'Archive::Tar'  => 1.76,
    					  'DateTime'	  => 0.78},
    dist              => {TARFLAGS  => '-cv --format=gnu -f'},
    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
      (ABSTRACT_FROM  => 'lib/App/BackupPlan.pm', # retrieve abstract from module
       AUTHOR         => 'gualtiero chiaia') : ()),
);

lib/App/BackupPlan.pm  view on Meta::CPAN


package App::BackupPlan;

use 5.012003;
use strict;
use warnings;
use Config;
use DateTime;
use Time::Local;
use XML::DOM;
use Log::Log4perl qw(:easy);
use App::BackupPlan::Policy;
use App::BackupPlan::Utils qw(fromISO2TS fromTS2ISO addSpan subSpan);

require XML::DOM;
require Log::Log4perl;

require Exporter;

lib/App/BackupPlan/Utils.pm  view on Meta::CPAN

package App::BackupPlan::Utils;

use strict;
use warnings;
use Archive::Tar;
use File::Find;
use Time::Local;
use DateTime;

our @ISA = qw(Exporter);
our $VERSION = '0.0.11';

# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.

# This allows declaration	use App::BackupPlan ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK

lib/App/BackupPlan/Utils.pm  view on Meta::CPAN

  }
}


sub addSpan{
  my ($timestamp,$span) = @_;
  my @ts = localtime $timestamp;
  my $year = $ts[5]+1900;
  my $month = $ts[4]+1;
  my $day = $ts[3];
  my $dt = DateTime->new(year	=> $year,
	                 month	=> $month, 
			 day	=> $day);
  if ($span=~/(\d+)d/) {
    $dt->add_duration(DateTime::Duration->new(days => $1));
      return timelocal(0,0,0,$dt->day(),$dt->month()-1,$dt->year());
  }
  if ($span=~/(\d+)m/) {
      $dt->add_duration(DateTime::Duration->new(months => $1));
        return timelocal(0,0,0,$dt->day(),$dt->month()-1,$dt->year());
  }
  if ($span=~/(\d+)y/) {
       $dt->add_duration(DateTime::Duration->new(years => $1));
        return timelocal(0,0,0,$dt->day(),$dt->month()-1,$dt->year());
  }
}

sub subSpan{
  my ($timestamp,$span) = @_;
  my @ts = localtime $timestamp;
  my $year = $ts[5]+1900;
  my $month = $ts[4]+1;
  my $day = $ts[3];
  my $dt = DateTime->new(year	=> $year,
	                 month	=> $month, 
			 day	=> $day);
  if ($span=~/(\d+)d/) {
    $dt->subtract_duration(DateTime::Duration->new(days => $1));
      return timelocal(0,0,0,$dt->day(),$dt->month()-1,$dt->year());
  }
  if ($span=~/(\d+)m/) {
      $dt->subtract_duration(DateTime::Duration->new(months => $1));
        return timelocal(0,0,0,$dt->day(),$dt->month()-1,$dt->year());
  }
  if ($span=~/(\d+)y/) {
       $dt->subtract_duration(DateTime::Duration->new(years => $1));
        return timelocal(0,0,0,$dt->day(),$dt->month()-1,$dt->year());
  }
}


1;



( run in 0.309 second using v1.01-cache-2.11-cpan-05444aca049 )