Catmandu-BagIt

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

        # Read the file listing as found in the manifest file
        printf "file-sums:\n";
        for my $file ($bagit->list_checksum) {
            my $sum = $bagit->get_checksum($file);
            printf " $file: %s\n" , $sum;
        }
    
        # Read the real listing of files as found on the disk
        printf "files:\n";
        for my $file ($bagit->list_files) {
            my $stat = [stat($file->path)];
            printf " name: %s\n", $file->filename;
            printf " size: %s\n", $stat->[7];
            printf " last-mod: %s\n", scalar(localtime($stat->[9]));
        }
    
        my $file = $bagit->get_file("mydata.txt");
        my $fh   = $file->open;
    
        while (<$fh>) {
           ....

lib/Catmandu/BagIt.pm  view on Meta::CPAN

    # Read the file listing as found in the manifest file
    printf "file-sums:\n";
    for my $file ($bagit->list_checksum) {
        my $sum = $bagit->get_checksum($file);
        printf " $file: %s\n" , $sum;
    }

    # Read the real listing of files as found on the disk
    printf "files:\n";
    for my $file ($bagit->list_files) {
        my $stat = [stat($file->path)];
        printf " name: %s\n", $file->filename;
        printf " size: %s\n", $stat->[7];
        printf " last-mod: %s\n", scalar(localtime($stat->[9]));
    }

    my $file = $bagit->get_file("mydata.txt");
    my $fh   = $file->open;

    while (<$fh>) {
       ....

lib/Catmandu/Exporter/BagIt.pm  view on Meta::CPAN

use Moo;

with 'Catmandu::Exporter';

has user_agent      => (is => 'ro');
has ignore_existing => (is => 'ro' , default => sub { 0 });
has overwrite       => (is => 'ro' , default => sub { 0 });

sub _mtime {
    my $file = $_[0];
    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($file);
    return $mtime;
}

sub add {
    my ($self, $data) = @_;
    my $directory = $data->{_id};
    $directory =~ s{\/$}{};

    return 1 if -d $directory && $self->ignore_existing;

script/bagit.pl  view on Meta::CPAN

    }

    printf "file-sums:\n";
    for my $file ($bagit->list_checksum) {
        my $sum = $bagit->get_checksum($file);
        printf " $file: %s\n" , $sum;
    }

    printf "files:\n";
    for my $file ($bagit->list_files) {
        my $stat = [stat($file->path)];
        printf "  -";
        printf " name: %s\n", $file->filename;
        printf "    size: %d\n", $stat->[7];
        printf "    last-mod: %s\n", scalar(localtime($stat->[9]));
    }
}

sub cmd_holey {
    my ($directory) = shift;

t/Catmandu-BagIt.t  view on Meta::CPAN

    ok $fetch , 'get_fetch()';

    ok $bagit->write($bag_dir, overwrite => 1) , 'write bag overwrite';

    ok $bagit->mirror_fetch($fetch) , 'mirror_fetch';

    ok $bagit->write($bag_dir, overwrite => 1) , 'write bag overwrite';

    ok -r "$bag_dir/data/poem.txt";

    my $size = [stat("$bag_dir/data/poem.txt")]->[7];

    is $size , 65 , 'got the correct size';

    remove_path($bag_dir);
}

note("lock");
{
    my $bagit = Catmandu::BagIt->read("bags/demo03");



( run in 0.598 second using v1.01-cache-2.11-cpan-49f99fa48dc )