File.pm

filter: Statementstmt 96.3% 186 / 193 Branchbran 86.2% 88 / 102 Conditioncond 78.9% 15 / 19 MC/DCmcdc 55.5% 5 / 9 Subroutinesub 97.1% 34 / 35 Podpod 100% 18 / 18 totaltotal 92.0% 346 / 376 CC 62 SCAR 17.3
CC
62
Cov
92%
_load
11.7
write
11.1
get
8.0
CRAP 5.6
↑ Summary File/YAML.pm »
1 package Tree::File;
2  
3 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 18 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use File::Path ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 NAME
10  
11 Tree::File - (DEPRECATED) store a data structure in a file tree
12  
13 =head1 VERSION
14  
15 version 0.112
16  
17 =cut
18  
19 18 our $VERSION = '0.112';
20  
21 =head1 SYNOPSIS
22  
23 use Tree::File::Subclass;
24  
25 my $tree = Tree::File::Subclass->new($treerot);
26  
27 die "death mandated" if $tree->get("/master/die")
28  
29 print "Hello, ", $tree->get("/login/user/name");
30  
31 $tree->set("/login/user/lastlogin", time);
32 $tree->write;
33  
34 =head1 DESCRIPTION
35  
36 This module stores configuration in a series of files spread across a directory
37 tree, and provides uniform access to the data structure.
38  
39 It can load a single file or a directory tree containing files as leaves. The
40 tree's branches can be returned as data structures, and the tree can be
41 modified and rewritten. Directory-based branches can be collapsed back into
42 files and file-based branches can be exploded into directories.
43  
44 =head1 METHODS
45  
46 =head2 C<< Tree::File->new($treeroot, \%arg) >>
47  
48 This loads the tree at the named root, which may be a file or a directory. The
49 C<%arg> hash is optional, the following options are recognized:
50  
51 readonly - if true, set and delete methods croak (default: false)
52 preload - the number of levels of directories to preload (default: none)
53 pass -1 to preload as deep as required
54 found - a closure called when a node or value is found; it is passed the
55 Tree::File object, the id requested, and the data retrieved; it
56 should apply any transformations and return the 'real' value desired.
57 not_found - a closure called if a node cannot be found; it is passed the id
58 requested and the root of the last node reached; by default,
59 Tree::File will return undef in this situation
60  
61 =cut
62  
63 25 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
64 25 my ($class, $root, $arg) = @_;
65  
66 25 $arg->{lock_mgr} = bless { root => $root } => "Tree::File::LockManager";
67  
68 25 my $self = $class->_load(q{}, $arg->{preload}, {%$arg, basedir => $root});
69  
70 22 return $self;
71 }
72  
73 11 ▶sub _as_arg {
Subroutine _as_arg: called CC=1 SCAR=0.0
74 11 my $self = shift;
75 return {
76 11 map { $_ => $self->{$_} } qw(basedir lock_mgr readonly found not_found)
77 };
78 }
79  
80 225 ▶sub _new_node {
Subroutine _new_node: called CC=5 SCAR=16.1
81 225 my ($self, $root, $data, $arg) = @_;
82 225 ▶ my $class = ref $self ? ref $self : $self;
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 14 211 225
83  
84 225 ▶ if (ref $self and not $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self and not $arg) 11 214 225
Condition100%3/3
ref $self and not $arg
!ll&&!rl&&r
211311
MC/DC100%2/2
ref $self and not $arg
ref $self not $arg
Truth table100%3/3
A and not(B)
A= ref $selfB= not $arg
ABresult
0X0
100
111
85 11 $arg = $self->_as_arg;
86 }
87  
88 225 ▶ return $data if ref $data ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $data ne "HASH" 150 75 225
89  
90 my $processed_data = {
91 75 map { $_ => $self->_new_node("$root/$_", $data->{$_}, $arg) }
92 keys %$data
93 };
94  
95 75 bless {
96 root => $root,
97 data => $processed_data,
98 %$arg
99 } => $class;
100 }
101  
102 =head2 C<< $tree->load_file($filename) >>
103  
104 This method is used internally by Tree::File subclasses, which must implement
105 it. Given the name of a file on disk, this method returns the data structure
106 contained in the file.
107  
108 =cut
109  
110 1 ▶sub load_file { croak "load_file method unimplemented" }
Subroutine load_file: called CC=1 SCAR=0.0
Pod documented
111  
112 81 ▶sub _load {
Subroutine _load: called CC=11 SCAR=24.6
113 81 my ($self, $root, $preload, $arg) = @_;
114 81 my $lock_mgr = $arg->{lock_mgr};
115  
116 81 eval { $lock_mgr->lock() };
117 81 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 81 81
118 0 ▶ if ($@ =~ /couldn.t open lockfile/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ =~ /couldn.t open lockfile/i) { } 0 0 0
119 0 $arg->{readonly}++;
120 0 $lock_mgr->no_op;
121 } else {
122 0 die; ## no critic Carping
123 }
124 }
125  
126 81 ▶ my $file = $root ? "$arg->{basedir}/$root" : $arg->{basedir};
Branch: 1 branch
BranchTrueFalseTotal
$root ? : 56 25 81
127  
128 81 ▶ if (-f $file) {
Branch: 2 branches
BranchTrueFalseTotal
if (-f $file) { } 43 38 81
elsif (-d $file) { } 37 1 38
129 43 my $data = $self->load_file($file);
130 42 $lock_mgr->unlock();
131 42 return $self->_new_node($root, $data, \%$arg);
132 }
133  
134 elsif (-d $file) {
135 37 my $dir;
136 37 ▶ opendir $dir, $file or croak "can't open branch directory $dir: $!";
Branch: 1 branch
BranchTrueFalseTotal
opendir $dir, $file or croak("can't open branch directory ${dir}: $!") 36 1 37
137  
138 36 my $tree = {};
139 36 ▶ for my $twig (grep { $_ !~ /\A\./ && ! -l "$file/$_" && $_ ne 'CVS' } readdir $dir) {
Condition83%5/6
!($_ =~ /\A\./ || -l "$file/$_") && $_ ne 'CVS'
!ll&&!rl&&r
74071
$_ =~ /\A\./ || -l "$file/$_"
l!l&&r!l&&!r
72271
MC/DC66%2/3
!($_ =~ /\A\./ || -l "$file/$_") && $_ ne 'CVS'
$_ =~ /\A\./ -l "$file/$_" $_ ne 'CVS'
Truth table75%3/4
not(A || B) && C
A= $_ =~ /\A\./B= -l "$file/$_"C= $_ ne 'CVS'
ABCresult
1XX0
01X0
0000
0011
140 $tree->{$twig} = $preload
141 ? $self->_load("$root/$twig", $preload-1, { %$arg, preload => $preload-1})
142 71 ▶ : sub { $self->_load("$root/$twig", 0, { %$arg, preload => 0 }) };
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
$preload ? : 7 64 71
143 }
144 36 $lock_mgr->unlock();
145 36 return $self->_new_node($root, $tree, { %$arg, type => 'dir' });
146 }
147  
148 else {
149 1 $lock_mgr->unlock();
150 1 croak "$file doesn't exist or isn't a normal file or directory";
151 }
152 }
153  
154 =head2 C<< $tree->get($id) >>
155  
156 This returns the branch with the given name. If the name contains slashes,
157 they indicate recursive fetches, so that these two calls are identical:
158  
159 $tree->get("foo")->get("bar")->get("baz");
160  
161 $tree->get("foo/bar/baz");
162  
163 Leading slashes are ignored.
164  
165 If a second, true argument is passed to C<get>, any missing data structures
166 will be autovivified as needed to get to the leaf.
167  
168 =cut
169  
170 11 ▶sub _not_found {
Subroutine _not_found: called CC=2 SCAR=6.9
171 11 my ($self) = shift;
172 11 ▶ if ($self->{not_found}) { return $self->{not_found}->(@_) }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"not_found"}) 2 9 11
173 9 return;
174 }
175  
176 324 ▶sub _found {
Subroutine _found: called CC=2 SCAR=7.2
177 324 my ($self) = shift;
178 324 ▶ return $self->{found} ? $self->{found}->($self, @_) : $_[1];
Branch: 1 branch
BranchTrueFalseTotal
$self->{'found'} ? : 0 324 324
179 }
180  
181 365 ▶sub get {
Subroutine get: called CC=8 SCAR=20.8
Pod documented
182 365 my ($self, $id, $autovivify) = @_;
183  
184 365 ▶ $id && $id =~ s|\A/+||;
Branch: 1 branch
BranchTrueFalseTotal
$id and $id =~ s[\A/+][] 364 1 365
185 365 my $rest;
186  
187 365 ▶ croak "get called on $self without property identifier" unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 1 364 365
188  
189 364 ($id, $rest) = split m|/|, $id, 2;
190 364 ▶ if ($rest) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rest) 27 337 364
191 27 my $head = $self->get($id, $autovivify);
192 27 ▶ return $self->_not_found($id, $self->{root}) unless $head;
Branch: 1 branch
BranchTrueFalseTotal
unless $head 3 24 27
193 24 return $head->get($rest, $autovivify);
194 }
195  
196 337 ▶ if (exists $self->{data}{$id}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"data"}{$id}) 324 13 337
197 324 ▶ if (ref $self->{data}{$id} eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"data"}{$id} eq "CODE") 49 275 324
198 49 $self->{data}{$id} = $self->{data}{$id}->();
199 }
200 324 return $self->_found($id, $self->{data}{$id});
201 }
202  
203 13 ▶ if ($autovivify) {
Branch: 1 branch
BranchTrueFalseTotal
if ($autovivify) 5 8 13
204 5 return $self->{data}{$id} =
205 $self->_new_node("$self->{root}/$id", {});
206 }
207  
208 8 return $self->_not_found($id, $self->{root});
209 }
210  
211 =head2 C<< $tree->set($id, $value) >>
212  
213 This sets the identified branch's value to the given value. Hash references
214 are automatically expanded into trees.
215  
216 =cut
217  
218 18 ▶sub set { ## no critic Ambiguous
Subroutine set: called CC=7 SCAR=19.5
Pod documented
219 18 my ($self, $id, $value, $root) = @_;
220  
221 18 ▶ $value = $value->data if eval { $value->isa("Tree::File") };
Branch: 1 branch
BranchTrueFalseTotal
if eval { do { $value->isa("Tree::File") } } 1 17 18
222  
223 18 ▶ croak "set called on readonly tree" if $self->{readonly};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"readonly"} 2 16 18
224  
225 16 ▶ $id && $id =~ s|\A/+||;
Branch: 1 branch
BranchTrueFalseTotal
$id and $id =~ s[\A/+][] 15 1 16
226 16 ▶ $root = $id unless $root;
Branch: 1 branch
BranchTrueFalseTotal
unless $root 7 9 16
227 16 my $rest;
228  
229 16 ▶ croak "set called on $self without property identifier" unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 1 15 16
230  
231 15 ($id, $rest) = split m|/|, $id, 2;
232 15 ▶ if ($rest) { return $self->get($id, 1)->set($rest, $value, $root); }
Branch: 1 branch
BranchTrueFalseTotal
if ($rest) 9 6 15
233  
234 6 return $self->{data}{$id} =
235 $self->_new_node($root, $value);
236 }
237  
238 =head2 C<< $tree->delete($id) >>
239  
240 This method deletes the identified branch (and returns the deleted value).
241  
242 =cut
243  
244 10 ▶sub delete { ## no critic Homonym
Subroutine delete: called CC=5 SCAR=16.1
Pod documented
245 10 my ($self, $id) = @_;
246  
247 10 ▶ croak "delete called on readonly tree" if $self->{readonly};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"readonly"} 2 8 10
248  
249 8 ▶ $id && $id =~ s|\A/+||;
Branch: 1 branch
BranchTrueFalseTotal
$id and $id =~ s[\A/+][] 7 1 8
250 8 my $rest;
251  
252 8 ▶ croak "delete called on $self without property identifier" unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 1 7 8
253  
254 7 ($id, $rest) = split m|/|, $id, 2;
255 7 ▶ if ($rest) { return $self->get($id)->delete($rest); }
Branch: 1 branch
BranchTrueFalseTotal
if ($rest) 4 3 7
256  
257 3 return delete $self->{data}{$id};
258 }
259  
260 =head2 C<< $tree->move($old_id, $new_id) >>
261  
262 This method deletes the value at the old id and places it at the new id.
263  
264 =cut
265  
266 2 ▶sub move {
Subroutine move: called CC=1 SCAR=0.0
Pod documented
267 2 my ($self, $old_id, $new_id) = @_;
268  
269 2 $self->set($new_id, $self->delete($old_id));
270 }
271  
272 =head2 C<< $tree->path() >>
273  
274 This method returns the path to this node from the root.
275  
276 =cut
277  
278 2 ▶sub path {
Subroutine path: called CC=1 SCAR=0.0
Pod documented
279 2 my ($self) = @_;
280 2 return $self->{root};
281 }
282  
283 =head2 C<< $tree->basename() >>
284  
285 This method retuns the base name of the node. (If, for example, the path to
286 the node is "/things/good/all" then its base name is "all".)
287  
288 =cut
289  
290 1 ▶sub basename {
Subroutine basename: called CC=1 SCAR=0.0
Pod documented
291 1 my ($self) = @_;
292 1 my @parts = split m{/}, $self->path();
293 1 return $parts[-1];
294 }
295  
296 1 ▶sub _handoff {
Subroutine _handoff: called CC=2 SCAR=7.1
297 1 my $self = shift;
298 1 my $method = (caller(1))[3];
299 1 $method =~ s/.*:://;
300 1 my $node = $self->get(@_);
301 1 ▶ unless ($node) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($node) 0 1 1
302 0 return $self->_not_found(@_);
303 }
304 #warn "handing off $method to " . $node->path . "\n";
305 1 $node->$method;
306 }
307  
308 =head2 C<< $tree->node_names() >>
309  
310 This method returns the names of all the nodes beneath this branch.
311  
312 =cut
313  
314 140 ▶sub node_names {
Subroutine node_names: called CC=2 SCAR=6.9
Pod documented
315 140 my $self = shift;
316 140 ▶ return $self->_handoff(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 139 140
317 139 return sort keys %{$self->{data}};
318 }
319  
320 =head2 C<< $tree->nodes() >>
321  
322 This method returns each node beneath this branch.
323  
324 =cut
325  
326 1 ▶sub nodes {
Subroutine nodes: called CC=2 SCAR=7.0
Pod documented
327 1 my $self = shift;
328 1 ▶ return $self->_handoff(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
329 1 return map { $self->get($_) } $self->node_names();
330 }
331  
332 =head2 C<< $tree->branch_names >>
333  
334 =cut
335  
336 2 ▶sub branch_names {
Subroutine branch_names: called CC=2 SCAR=7.0
Pod documented
337 2 my $self = shift;
338 2 ▶ return $self->_handoff(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 2 2
339 2 return grep { eval { $self->get($_)->isa("Tree::File") } } $self->node_names;
340 }
341  
342 =head2 C<< $tree->branches >>
343  
344 This method returns all the nodes on this branch which are also branches (that
345 is, are also Tree::File objects).
346  
347 =cut
348  
349 1 ▶sub branches {
Subroutine branches: called CC=2 SCAR=7.0
Pod documented
350 1 my $self = shift;
351 1 ▶ return $self->_handoff(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 1 1
352 1 return map { $self->get($_) } $self->branch_names();
353 }
354  
355 =head2 C<< $tree->data() >>
356  
357 This method returns the entire tree of data as an unblessed Perl data
358 structure.
359  
360 =cut
361  
362 123 ▶sub data {
Subroutine data: called CC=3 SCAR=11.0
Pod documented
363 123 my ($self) = @_;
364 123 my %data;
365  
366 123 for ($self->node_names) {
367 238 my $datum = $self->get($_);
368  
369 238 ▶ $data{$_} = eval { $datum->isa("Tree::File") } ? $datum->data
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $datum->isa('Tree::File') } } ? : 74 164 238
370 : $datum;
371 }
372  
373 123 return \%data;
374 }
375  
376 =head2 C<< $tree->write($basedir) >>
377  
378 This method forces the object to write itself out to disk. It will write out
379 branches to directories if a directory for the branch already exists, or if it
380 was orginally loaded as a directory.
381  
382 =cut
383  
384 20 ▶sub write { ## no critic Homonym
Subroutine write: called CC=11 SCAR=24.1
Pod documented
385 20 my $self = shift;
386 20 ▶ my $basedir = shift || $self->{basedir};
Condition66%2/3
shift() || $self->{'basedir'}
l!l&&r!l&&!r
1730
MC/DC0%0/2
shift() || $self->{'basedir'}
shift() $self->{'basedir'}
Truth table66%2/3
A || B
A= shift()B= $self->{'basedir'}
ABresult
1X1
011
000
387 20 ▶ my $root = $basedir ? "$basedir/$self->{root}" : $self->{root};
Branch: 1 branch
BranchTrueFalseTotal
$basedir ? : 20 0 20
388 20 my $lock_mgr = $self->{lock_mgr};
389  
390 20 $self->data; # force load of all data now
391  
392 20 ▶ my $type = $self->type
Condition71%5/7
$self->type || -d $root && 'dir' || 'file'
l!l
128
$self->type or -d $root and "dir"
l!l&&r!l&&!r
1208
-d $root and "dir"
!ll
80
MC/DC50%1/2
$self->type || -d $root && 'dir' || 'file'
$self->type -d $root
Truth table66%2/3
A or B
A= $self->typeB= -d $root
ABresult
1X1
011
000
393 || (-d $root && 'dir')
394 || 'file';
395  
396 20 $lock_mgr->lock();
397  
398 20 ▶ if ($type eq 'dir') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'dir') { } 10 10 20
399 10 ▶ File::Path::rmtree($root) if -d $root;
Branch: 1 branch
BranchTrueFalseTotal
if -d $root 4 6 10
400 10 File::Path::mkpath($root);
401 10 for ($self->node_names) {
402 19 my $datum = $self->get($_);
403 19 ▶ if (eval { $datum->isa("Tree::File") }) { $datum->write($basedir) }
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $datum->isa('Tree::File') } }) { } 13 6 19
404 6 else { $self->write_file("$root/$_", $datum) }
405 }
406 } else {
407 10 ▶ File::Path::rmtree($root) if -d $root;
Branch: 1 branch
BranchTrueFalseTotal
if -d $root 2 8 10
408 10 $self->write_file($root, $self->data);
409 }
410  
411 20 $lock_mgr->unlock();
412  
413 20 1;
414 }
415  
416 =head2 C<< $tree->write_file($filename) >>
417  
418 This method is used by Tree::File's C<write> method. It must be implement in
419 subclasses of Tree::File. Given the name of a file on disk and a data
420 structure, this method writes the data structure to the file.
421  
422 =cut
423  
424 1 ▶sub write_file { croak "write_file method unimplemented" }
Subroutine write_file: called CC=1 SCAR=0.0
Pod documented
425  
426 =head2 C<< $tree->type($type) >>
427  
428 This method returns the branch type for the given branch. If C<$type> is
429 defined and one of "dir" or "file" it will set the type and return the new
430 value.
431  
432 =cut
433  
434 29 ▶sub type {
Subroutine type: called CC=4 SCAR=13.9
Pod documented
435 29 my $self = shift;
436 29 ▶ return $self->{type} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 22 7 29
437  
438 7 my $type = shift;
439 7 ▶ return $self->{type} = undef unless defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 1 6 7
440  
441 6 ▶ croak "invalid branch type: $type" unless $type =~ /\A(?:dir|file)\Z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /\A(?:dir|file)\Z/ 1 5 6
442  
443 5 $self->{type} = $type;
444 }
445  
446 =head2 C<< $tree->explode() >>
447  
448 =head2 C<< $tree->collapse() >>
449  
450 These methods set the type of the branch to "dir" and "file" respectively.
451  
452 =cut
453  
454 1 ▶sub explode { (shift)->type("dir") }
Subroutine explode: called CC=1 SCAR=0.0
Pod documented
455 2 ▶sub collapse { (shift)->type("file") }
Subroutine collapse: called CC=1 SCAR=0.0
Pod documented
456  
457 package Tree::File::LockManager;
458  
459 18 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
460 18 ▶use Fcntl qw(:DEFAULT :flock);
Subroutine BEGIN: called CC=1 SCAR=0.0
461 18 ▶use File::Basename ();
Subroutine BEGIN: called CC=1 SCAR=0.0
462  
463 101 ▶sub lock {
Subroutine lock: called CC=6 SCAR=18.1
464 101 my ($self, $tree) = @_;
465 101 ▶ return if $self->{_no_op};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_no_op"} 0 101 101
466  
467 101 ▶ unless ($self->{_lockfile}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_lockfile"}) 25 76 101
468 25 my $lockfile = File::Basename::dirname($self->{root}) . "/.lock";
469 25 ▶ unless (-e $lockfile) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $lockfile) 2 23 25
470 2 ▶ open(my $lock, '>', $lockfile)
Branch: 1 branch
BranchTrueFalseTotal
open my $lock, ">", $lockfile or Carp::croak("couldn't create lockfile $lockfile") 2 0 2
471 or Carp::croak("couldn't create lockfile $lockfile");
472 2 print $lock time, "\n";
473 2 close $lock;
474 }
475 25 $self->{_locks} = 0;
476 25 ▶ open($self->{_lockfile}, "+<", $lockfile)
Branch: 1 branch
BranchTrueFalseTotal
open $self->{"_lockfile"}, "+<", $lockfile or Carp::croak("couldn't open lockfile $lockfile") 25 0 25
477 or Carp::croak("couldn't open lockfile $lockfile");
478 }
479 101 flock($self->{_lockfile}, LOCK_EX);
480 101 ++$self->{_locks};
481 }
482  
483 99 ▶sub unlock {
Subroutine unlock: called CC=4 SCAR=14.1
484 99 my ($self, $tree) = @_;
485 99 ▶ return if $self->{_no_op};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_no_op"} 0 99 99
486 99 ▶ return unless $self->{_lockfile};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_lockfile"} 0 99 99
487 99 ▶ flock($self->{_lockfile}, LOCK_UN) if (--$self->{_locks} == 0);
Branch: 1 branch
BranchTrueFalseTotal
if --$self->{"_locks"} == 0 79 20 99
488 99 return $self->{_locks};
489 }
490  
491 0 ▶sub no_op {
Subroutine no_op: not called CC=1 SCAR=6.9
492 0 my $self = shift;
493 0 $self->{_no_op}++;
494 }
495  
496 =head1 TODO
497  
498 =over
499  
500 =item * symlinks and references
501  
502 =item * serialization through delegation, not inheritance
503  
504 =item * make locking methods pluggable
505  
506 =item * callback for determining which files to skip
507  
508 =back
509  
510 =head1 AUTHOR
511  
512 Ricardo SIGNES, C<< <rjbs@cpan.org> >>
513  
514 =head1 BUGS
515  
516 Please report any bugs or feature requests to C<bug-tree-file@rt.cpan.org>, or
517 through the web interface at L<http://rt.cpan.org>. I will be notified, and
518 then you'll automatically be notified of progress on your bug as I make
519 changes.
520  
521 =head1 COPYRIGHT
522  
523 Copyright 2005 Ricardo Signes, All Rights Reserved.
524  
525 This program is free software; you can redistribute it and/or modify it
526 under the same terms as Perl itself.
527  
528 =cut
529  
530 18 1;
↑ Summary File/YAML.pm »