line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Automatan::Plugin::Source::File; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: File input module |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
454
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
7
|
1
|
|
|
1
|
|
692
|
use Moo; |
|
1
|
|
|
|
|
12890
|
|
|
1
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub go { |
10
|
2
|
|
|
2
|
1
|
1776
|
my $self = shift; |
11
|
2
|
|
|
|
|
2
|
my $in = shift; |
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
|
|
3
|
my $d = $in->{debug}; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
|
|
3
|
my $file = $in->{path}; |
16
|
2
|
|
|
|
|
5
|
_logger($d, "Processing file: $file"); |
17
|
2
|
50
|
|
|
|
66
|
open(my $fh, "<", $in->{path}) || return 1; |
18
|
2
|
|
|
|
|
33
|
my @lines = <$fh>; |
19
|
2
|
|
|
|
|
14
|
close($fh); |
20
|
|
|
|
|
|
|
|
21
|
2
|
50
|
|
|
|
9
|
if ($in->{empty}) { |
22
|
0
|
|
|
|
|
0
|
_logger($d, "emptying the file: $file"); |
23
|
0
|
|
|
|
|
0
|
open(my $fh, '>', $in->{path}); |
24
|
0
|
|
|
|
|
0
|
print $fh ''; |
25
|
0
|
|
|
|
|
0
|
close($fh); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
2
|
100
|
|
|
|
4
|
if ($in->{delete}) { |
29
|
1
|
|
|
|
|
4
|
_logger($d, "deleting file: $file"); |
30
|
1
|
|
|
|
|
81
|
unlink $file; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
8
|
chomp(@lines); |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
14
|
return(@lines); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _logger { |
39
|
3
|
|
|
3
|
|
3
|
my $level = shift; |
40
|
3
|
|
|
|
|
4
|
my $message = shift; |
41
|
3
|
50
|
|
|
|
6
|
print "$message\n" if $level; |
42
|
3
|
|
|
|
|
4
|
return 1; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |