Boxer/Task/Classify.pm

filter: Statementstmt 94.8% 73 / 77 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 22 / 22 Podpod 0.0% 0 / 2 totaltotal 91.5% 98 / 107 CC 4 SCAR 2.4
CC
4
Cov
92%
_build_classdir
2.1
_build_nodedir
2.1
run
2.0
CRAP 1.3
« Boxer/World/Flat.pm ↑ Summary Boxer/Types.pm »
1 package Boxer::Task::Classify;
2  
3 =encoding UTF-8
4  
5 =cut
6  
7 4 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Role::Commons -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶no warnings "experimental::signatures";
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use namespace::autoclean 0.16;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use autodie qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use IPC::System::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 4 ▶use File::BaseDir qw(data_dirs);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶use Boxer;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use MooX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 4 extends qw(Boxer::Task);
22  
23 4 ▶use Types::Standard qw(Maybe);
Subroutine BEGIN: called CC=1 SCAR=0.0
24 4 ▶use Boxer::Types qw( WorldName DataDir ClassDir NodeDir Suite );
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 4 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 4 ▶no warnings "experimental::signatures";
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 =head1 VERSION
30  
31 Version v1.4.1
32  
33 =cut
34  
35 4 our $VERSION = "v1.4.1";
36  
37 # permit callers to sloppily pass undefined values
38 sub BUILDARGS ( $class, %args )
39 ▶{
Subroutine BUILDARGS: called CC=1 SCAR=0.0
Pod undocumented
40 7 delete @args{ grep !defined( $args{$_} ), keys %args };
41 7 return {%args};
42 }
43  
44 has world => (
45 is => 'ro',
46 isa => WorldName,
47 required => 1,
48 6 ▶ default => sub {'reclass'},
Subroutine __ANON__: called CC=1 SCAR=0.0
49 4 );
50  
51 4 has datadir => (
52 is => 'lazy',
53 isa => Maybe [DataDir],
54 coerce => 1,
55 );
56  
57 has suite => (
58 is => 'ro',
59 isa => Suite,
60 required => 1,
61 coerce => 1,
62 6 ▶ default => sub {'buster'},
Subroutine __ANON__: called CC=1 SCAR=0.0
63 4 );
64  
65 4 has classdir => (
66 is => 'lazy',
67 isa => ClassDir,
68 coerce => 1,
69 required => 1,
70 );
71  
72 sub _build_classdir ($self)
73 ▶{
Subroutine _build_classdir: called CC=2 SCAR=7.6
74 6 my $dir;
75 6 ▶ if ( $self->datadir ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->datadir) { } 6 0 6
76 6 $self->_logger->trace('Resolving classdir from datadir');
77 6 $dir = $self->datadir->child('classes');
78 }
79 else {
80 0 $self->_logger->trace('Resolving classdir from XDG_DATA_DIRS');
81 0 $dir = scalar data_dirs( 'boxer', $_[0]->suite, 'classes' );
82 }
83 6 return $dir;
84 }
85  
86 4 has nodedir => (
87 is => 'lazy',
88 isa => NodeDir,
89 coerce => 1,
90 required => 1,
91 );
92  
93 sub _build_nodedir ($self)
94 ▶{
Subroutine _build_nodedir: called CC=2 SCAR=7.6
95 5 my $dir;
96 5 ▶ if ( $self->datadir ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->datadir) { } 5 0 5
97 5 $self->_logger->trace('Resolving nodedir from datadir');
98 5 $dir = $self->datadir->child('nodes');
99 }
100 else {
101 0 $self->_logger->trace('Setting nodedir to current directory');
102 0 $dir = '.';
103 }
104 5 return $dir;
105 }
106  
107 sub run ($self)
108 ▶{
Subroutine run: called CC=2 SCAR=7.1
Pod undocumented
109 6 my @args = (
110 suite => scalar $self->suite,
111 classdir => scalar $self->classdir,
112 nodedir => scalar $self->nodedir,
113 );
114 5 ▶ $self->_logger->info(
Branch: 1 branch
BranchTrueFalseTotal
$self->_logger->is_debug ? : 5 0 5
115 'Classifying with reclass',
116 $self->_logger->is_debug() ? {@args} : (),
117 );
118 5 return Boxer->get_world( $self->world )->new(@args);
119 }
120  
121 =head1 AUTHOR
122  
123 Jonas Smedegaard C<< <dr@jones.dk> >>.
124  
125 =cut
126  
127 4 our $AUTHORITY = 'cpan:JONASS';
128  
129 =head1 COPYRIGHT AND LICENCE
130  
131 Copyright © 2013-2016 Jonas Smedegaard
132  
133 This is free software; you can redistribute it and/or modify it under
134 the same terms as the Perl 5 programming language system itself.
135  
136 =head1 DISCLAIMER OF WARRANTIES
137  
138 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
139 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
140 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
141  
142 =cut
143  
144 4 1;
« Boxer/World/Flat.pm ↑ Summary Boxer/Types.pm »