| 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
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||