Plugin/Config.pm

filter: Statementstmt 29.1% 7 / 24 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 2 / 6 Podpod 0.0% 0 / 2 totaltotal 25.0% 9 / 36 SCAR 19.2
CC
3
Cov
25%
build_plugin
6.0
_read_file
6.0
find
2.0
CRAP 6.8
↑ Summary Plugin/Config/YAML.pm »
1 package Terse::Plugin::Config;
2  
3 1 ▶use base 'Terse::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Data::LNPath qw/lnpath/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 sub build_plugin {
7 0 ▶ my ($self) = @_;
Subroutine build_plugin: not called CC=2 SCAR=17.9
Pod undocumented
8 0 ▶ if (!$self->config_file) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->config_file) 0 0 0
9 0 my $file = $0;
10 0 ($self->config_file = $0) =~ s/(\.psgi)?$/.json/;
11 }
12 0 $self->data = $self->_read_file($self->config_file);
13 0 return $self;
14 }
15  
16 sub find {
17 0 ▶ my ($self, $path) = @_;
Subroutine find: not called CC=1 SCAR=6.9
Pod undocumented
18 0 return lnpath($self->{data}, $path);
19 }
20  
21 sub _read_file {
22 0 ▶ my ($self, $file) = @_;
Subroutine _read_file: not called CC=2 SCAR=17.9
23 0 ▶ open my $fh, '<', $file or die "Cannot open config file: $file";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $file or die "Cannot open config file: $file" 0 0 0
24 0 my $content = do { local $/; <$fh> };
25 0 close $fh;
26 0 $self->_parse_config($content);
27 }
28  
29 sub _parse_config {
30 0 ▶ my ($self, $content) = @_;
Subroutine _parse_config: not called CC=1 SCAR=6.9
31 0 return $self->graft('data', $content);
32 }
33  
34 1 1;
35  
36 __END__
↑ Summary Plugin/Config/YAML.pm »