File Coverage

blib/lib/Catmandu/FileBag/Index.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 28 28 100.0


line stmt bran cond sub pod time code
1             package Catmandu::FileBag::Index;
2              
3             our $VERSION = '1.16';
4              
5 12     12   77826 use Catmandu::Sane;
  12         195936  
  12         96  
6 12     12   2716 use Moo::Role;
  12         30  
  12         73  
7 12     12   9707 use IO::String;
  12         26240  
  12         410  
8 12     12   88 use utf8;
  12         25  
  12         68  
9 12     12   356 use Catmandu::Util qw(:check);
  12         26  
  12         3406  
10 12     12   118 use namespace::clean;
  12         29  
  12         101  
11              
12             sub files {
13 6     6 1 54 my ($self, $id) = @_;
14 6         29 return $self->store->bag($id);
15             }
16              
17             1;
18              
19             __END__
20              
21             =pod
22              
23             =head1 NAME
24              
25             Catmandu::FileBag::Index - Flag a Bag as a FileStore Index
26              
27             =head1 SYNOPSIS
28              
29             use Catmandu;
30              
31             my $store = Catmandu->store('Simple' , root => 't/data');
32              
33             # List all containers
34             $store->bag->each(sub {
35             my $container = shift;
36              
37             print "%s\n" , $container->{_id};
38             });
39              
40             # Add a new folder
41             $store->bag->add({ _id => '1234' });
42              
43             # Get the v
44             my $files = $store->bag->files('1234');
45              
46             # Add a file to the files
47             $files->upload(IO::File->new('<foobar.txt'), 'foobar.txt');
48              
49             # Stream the contents of a file
50             $files->stream(IO::File->new('>foobar.txt'), 'foobar.txt');
51              
52             # Delete a file
53             $files->delete('foobar.txt');
54              
55             # Delete a folder
56             $store->bag->delete('1234');
57              
58              
59             =head1 DESCRIPTION
60              
61             Each L<Catmandu::FileBag> is a L<Catmandu::Bag> and inherits all its methods.
62              
63             =head1 METHODS
64              
65             =head2 files($id)
66              
67             Return the L<Catmandu::FileBag> for this L<Catmandu::FileStore> containing
68             all the files
69              
70             =head1 SEE ALSO
71              
72             L<Catmandu::FileStore> ,
73             L<Catmandu::FileBag>
74              
75             =cut