blib/lib/Pinto/Role/PauseConfig.pm

filter: Statementstmt 94.7% 36 / 38 Branchbran 90.0% 9 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod n/a totaltotal 92.9% 53 / 57 CC 6 SCAR 11.7
CC
6
Cov
94%
_build_pausecfg
6.0
_build_pauserc
2.0
BEGIN
1.0
CRAP 3.2
« blib/lib/Pinto/Remote/Result.pm ↑ Summary blib/lib/App/Pinto/Command/look.pm »
1 # ABSTRACT: Something that has a pause config attribute
2  
3 package Pinto::Role::PauseConfig;
4  
5 39 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 39 ▶use MooseX::Types::Moose qw(HashRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 39 ▶use Pinto::Globals;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 39 ▶use Pinto::Types qw(File);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 39 ▶use Pinto::Util qw(current_author_id);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 39 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 39 ▶use File::HomeDir;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 #------------------------------------------------------------------------------
16  
17 39 our $VERSION = '0.14'; # VERSION
18  
19 #------------------------------------------------------------------------------
20  
21  
22 39 has pauserc => (
23 is => 'ro',
24 isa => File,
25 lazy => 1,
26 coerce => 1,
27 builder => '_build_pauserc',
28 );
29  
30 #------------------------------------------------------------------------------
31  
32  
33 39 has pausecfg => (
34 is => 'ro',
35 isa => HashRef,
36 lazy => 1,
37 init_arg => undef,
38 builder => '_build_pausecfg',
39 );
40  
41 #------------------------------------------------------------------------------
42  
43 0 ▶sub _build_pauserc {
Subroutine _build_pauserc: not called CC=1 SCAR=6.9
44 0 my ($self) = @_;
45  
46 0 return file( File::HomeDir->my_home, '.pause' );
47 }
48  
49 #------------------------------------------------------------------------------
50  
51 23 ▶sub _build_pausecfg {
Subroutine _build_pausecfg: called CC=6 SCAR=17.9
52 23 my ($self) = @_;
53  
54 23 my $cfg = {};
55 23 ▶ return $cfg if $Pinto::Globals::current_author_id;
Branch: 1 branch
BranchTrueFalseTotal
if $Pinto::Globals::current_author_id 22 1 23
56 1 ▶ return $cfg if not -e $self->pauserc();
Branch: 1 branch
BranchTrueFalseTotal
unless -e $self->pauserc 0 1 1
57 1 my $fh = $self->pauserc->openr();
58  
59 # basically taken from the parsing code used by cpan-upload
60 # (maybe this should be part of the CPAN::Uploader api?)
61  
62 1 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 5 1 6
63 5 ▶ next if /^ \s* (?: [#].*)? $/x;
Branch: 1 branch
BranchTrueFalseTotal
if /^ \s* (?: [#].*)? $/x 2 3 5
64 3 my ( $k, $v ) = /^ \s* (\w+) \s+ (.+?) \s* $/x;
65 3 ▶ next unless $k;
Branch: 1 branch
BranchTrueFalseTotal
unless $k 1 2 3
66 2 $cfg->{$k} = $v;
67 }
68  
69 1 return $cfg;
70 }
71  
72 #------------------------------------------------------------------------------
73 39 1;
74  
75 __END__
« blib/lib/Pinto/Remote/Result.pm ↑ Summary blib/lib/App/Pinto/Command/look.pm »