Plugin/Config.pm

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