Conveyor/Control/File.pm

filter: Statementstmt 30.4% 14 / 46 Branchbran 0.0% 0 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 27.4% 20 / 73 CC 11 SCAR 45.1
CC
11
Cov
21%
read
132.0
BEGIN
1.0
BEGIN
1.0
CRAP 91.1
« Conveyor/Test/Ticket.pm ↑ Summary Conveyor/Service/Result/Tabular.pm »
1 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Data::Conveyor::Control::File;
6 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 $Data::Conveyor::Control::File::VERSION = '1.103130';
8 }
9 # ABSTRACT: Stage-based conveyor-belt-like ticket handling system
10  
11 1 ▶use parent 'Data::Conveyor::Control';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 __PACKAGE__->mk_scalar_accessors(qw(filename));
13  
14 0 ▶sub read {
Subroutine read: not called CC=11 SCAR=48.8
Pod documented
15 0 my $self = shift;
16  
17 # Read the file indicated by $self->filename, which has an entry for
18 # each stage to be disabled, or 'ALL' to disable all stages. As soon as
19 # the word 'all' is found, the rest of the file is discarded!
20 #
21 # The line '__end__' signals the end of the stage list; anything below is
22 # ignored. If there is no such line, the whole file will be read - this
23 # works like the __END__ directive in a perl program.
24 #
25 #
26 #
27 # This method is pretty strict; if you misspell a stage or include it more
28 # than once, it aborts. Here we feel it is better to err on the cautious
29 # side. Suppose you'd like to disable the 'keywords_end' stage but mistype
30 # it as 'keyword_end'. If we didn't abort on an unknown stage name, we
31 # might record an error in the logs but the 'keywords_end' stage would
32 # still run.
33 0 $self->ignore_ticket_no_clear;
34 0 $self->allowed_stages_clear;
35 0 $self->allowed_stages(map { $_ => 1 }
36 $self->delegate->allowed_dispatcher_stages);
37  
38 # It's ok for the file not to be there.
39 0 ▶ return unless -e $self->filename;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $self->filename 0 0 0
40 0 my ($fh, $error);
41 0 ▶ unless (open $fh, '<', $self->filename) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open $fh, "<", $self->filename) 0 0 0
42 0 $self->log->info("can't open %s: %s", $self->filename, $!);
43 0 return 0;
44 }
45 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
46 0 chomp;
47 0 s/#.*$//; # comments are being ignored
48 0 s/^\s*//;
49 0 s/\s*$//;
50 0 ▶ next unless length;
Branch: 1 branch
BranchTrueFalseTotal
unless length $_ 0 0 0
51 0 $_ = lc;
52 0 ▶ if ($_ eq 'all') {
Branch: 4 branches
BranchTrueFalseTotal
if ($_ eq 'all') { } 0 0 0
elsif ($_ eq '__end__') { } 0 0 0
elsif ($self->allowed_stages($_)) { } 0 0 0
elsif ($self->make_obj('value_ticket_number')->check($_)) { } 0 0 0
53 0 $self->log->info("disallowing all stages");
54 0 $self->allowed_stages_clear;
55 0 last;
56 } elsif ($_ eq '__end__') {
57 0 last;
58 } elsif ($self->allowed_stages($_)) {
59 0 $self->allowed_stages_delete($_);
60 } elsif ($self->make_obj('value_ticket_number')->check($_)) {
61 0 $self->ignore_ticket_no($_ => 1);
62 } else {
63 0 $self->log->info(
64 "[%s] isn't a ticket number or a known stage, or a duplicate",
65 $_);
66 0 $error++;
67 0 last;
68 }
69 }
70 0 ▶ unless (close $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (close $fh) 0 0 0
71 0 $self->log->info("can't close %s: %s", $self->filename, $!);
72 0 return 0;
73 }
74 0 ▶ return 0 if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 0 0
75 0 1;
76 }
77 1 1;
78  
79  
80 __END__
« Conveyor/Test/Ticket.pm ↑ Summary Conveyor/Service/Result/Tabular.pm »