| 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.3 | ||||||||||
| 32 | |||||||||||
| 33 | =cut | ||||||||||
| 34 | |||||||||||
| 35 | 4 | our $VERSION = "v1.4.3"; | |||||||||
| 36 | |||||||||||
| 37 | # permit callers to sloppily pass undefined values | ||||||||||
| 38 | 7 | ▶ | sub BUILDARGS ( $class, %args ) | ||||||||
|
Subroutine
BUILDARGS: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 39 | { | ||||||||||
| 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 | has datadir => ( | ||||||||||
| 52 | is => 'lazy', | ||||||||||
| 53 | isa => Maybe [DataDir], | ||||||||||
| 54 | coerce => 1, | ||||||||||
| 55 | 0 | ▶ | default => sub {undef}, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 56 | 4 | ); | |||||||||
| 57 | |||||||||||
| 58 | has suite => ( | ||||||||||
| 59 | is => 'ro', | ||||||||||
| 60 | isa => Suite, | ||||||||||
| 61 | required => 1, | ||||||||||
| 62 | coerce => 1, | ||||||||||
| 63 | 6 | ▶ | default => sub {'bullseye'}, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 64 | 4 | ); | |||||||||
| 65 | |||||||||||
| 66 | 4 | has classdir => ( | |||||||||
| 67 | is => 'lazy', | ||||||||||
| 68 | isa => ClassDir, | ||||||||||
| 69 | coerce => 1, | ||||||||||
| 70 | required => 1, | ||||||||||
| 71 | ); | ||||||||||
| 72 | |||||||||||
| 73 | 6 | ▶ | sub _build_classdir ($self) | ||||||||
|
Subroutine
_build_classdir: called CC=2 SCAR=7.6
| |||||||||||
| 74 | { | ||||||||||
| 75 | 6 | my $dir; | |||||||||
| 76 | 6 | ▶ | if ( $self->datadir ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 77 | 6 | $self->_logger->trace('Resolving classdir from datadir'); | |||||||||
| 78 | 6 | $dir = $self->datadir->child('classes'); | |||||||||
| 79 | } | ||||||||||
| 80 | else { | ||||||||||
| 81 | 0 | $self->_logger->trace('Resolving classdir from XDG_DATA_DIRS'); | |||||||||
| 82 | 0 | $dir = scalar data_dirs( 'boxer', $self->suite, 'classes' ); | |||||||||
| 83 | } | ||||||||||
| 84 | 6 | return $dir; | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | 4 | has nodedir => ( | |||||||||
| 88 | is => 'lazy', | ||||||||||
| 89 | isa => NodeDir, | ||||||||||
| 90 | coerce => 1, | ||||||||||
| 91 | required => 1, | ||||||||||
| 92 | ); | ||||||||||
| 93 | |||||||||||
| 94 | 5 | ▶ | sub _build_nodedir ($self) | ||||||||
|
Subroutine
_build_nodedir: called CC=2 SCAR=7.6
| |||||||||||
| 95 | { | ||||||||||
| 96 | 5 | my $dir; | |||||||||
| 97 | 5 | ▶ | if ( $self->datadir ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 98 | 5 | $self->_logger->trace('Resolving nodedir from datadir'); | |||||||||
| 99 | 5 | $dir = $self->datadir->child('nodes'); | |||||||||
| 100 | } | ||||||||||
| 101 | else { | ||||||||||
| 102 | 0 | $self->_logger->trace('Setting nodedir to current directory'); | |||||||||
| 103 | 0 | $dir = '.'; | |||||||||
| 104 | } | ||||||||||
| 105 | 5 | return $dir; | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | 6 | ▶ | sub run ($self) | ||||||||
|
Subroutine
run: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||
| 109 | { | ||||||||||
| 110 | 6 | my @args = ( | |||||||||
| 111 | suite => scalar $self->suite, | ||||||||||
| 112 | classdir => scalar $self->classdir, | ||||||||||
| 113 | nodedir => scalar $self->nodedir, | ||||||||||
| 114 | ); | ||||||||||
| 115 | 5 | ▶ | $self->_logger->info( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 116 | 'Classifying with reclass', | ||||||||||
| 117 | $self->_logger->is_debug() ? {@args} : (), | ||||||||||
| 118 | ); | ||||||||||
| 119 | 5 | return Boxer->get_world( $self->world )->new(@args); | |||||||||
| 120 | } | ||||||||||
| 121 | |||||||||||
| 122 | =head1 AUTHOR | ||||||||||
| 123 | |||||||||||
| 124 | Jonas Smedegaard C<< <dr@jones.dk> >>. | ||||||||||
| 125 | |||||||||||
| 126 | =cut | ||||||||||
| 127 | |||||||||||
| 128 | 4 | our $AUTHORITY = 'cpan:JONASS'; | |||||||||
| 129 | |||||||||||
| 130 | =head1 COPYRIGHT AND LICENCE | ||||||||||
| 131 | |||||||||||
| 132 | Copyright © 2013-2016 Jonas Smedegaard | ||||||||||
| 133 | |||||||||||
| 134 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 135 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 136 | |||||||||||
| 137 | =head1 DISCLAIMER OF WARRANTIES | ||||||||||
| 138 | |||||||||||
| 139 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | ||||||||||
| 140 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | ||||||||||
| 141 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||
| 142 | |||||||||||
| 143 | =cut | ||||||||||
| 144 | |||||||||||
| 145 | 4 | 1; | |||||||||