line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::Tasks::Add; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# See POD at end for docs |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
127
|
|
6
|
4
|
|
|
4
|
|
20
|
use base 'File::Tasks::Task'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
2250
|
|
7
|
4
|
|
|
4
|
|
4694
|
use File::Flat (); |
|
4
|
|
|
|
|
80236
|
|
|
4
|
|
|
|
|
121
|
|
8
|
4
|
|
|
4
|
|
47
|
use Params::Util '_INSTANCE'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
3468
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
26
|
use vars qw{$VERSION}; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
191
|
|
11
|
|
|
|
|
|
|
BEGIN { |
12
|
4
|
|
|
4
|
|
1007
|
$VERSION = '0.07'; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
##################################################################### |
20
|
|
|
|
|
|
|
# Constructor and Accessors |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
24
|
0
|
0
|
|
|
|
|
my $self = $class->SUPER::new(@_) or return undef; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Check the content source |
27
|
0
|
0
|
|
|
|
|
my $Script = _INSTANCE(shift, 'File::Tasks') or return undef; |
28
|
0
|
0
|
|
|
|
|
$self->{source} = $Script->provider->compatible(shift) or return undef; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
1
|
|
sub source { $_[0]->{source} } |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
##################################################################### |
40
|
|
|
|
|
|
|
# File::Tasks::Task |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
1
|
|
sub type { 'Add' } |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub test { |
45
|
0
|
|
|
0
|
1
|
|
File::Flat->canWrite( shift->path ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub content { |
49
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
$self->provider->content( $self->source ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub execute { |
54
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
55
|
0
|
0
|
|
|
|
|
my $content = $self->content or return undef; |
56
|
0
|
|
|
|
|
|
File::Flat->write( $self->path, $content ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |