File Coverage

blib/lib/Algorithm/Classifier/NaiveBayes/App/Command.pm
Criterion Covered Total %
statement 21 28 75.0
branch 2 4 50.0
condition n/a
subroutine 7 7 100.0
pod 2 3 66.6
total 32 42 76.1


line stmt bran cond sub pod time code
1             package Algorithm::Classifier::NaiveBayes::App::Command;
2              
3 1     1   774 use 5.006;
  1         2  
4 1     1   4 use strict;
  1         1  
  1         26  
5 1     1   3 use warnings;
  1         3  
  1         87  
6 1     1   5 use App::Cmd::Setup -command;
  1         3  
  1         7  
7              
8             =head1 NAME
9              
10             Algorithm::Classifier::NaiveBayes::App::Command - The base class for nb_tool commands.
11              
12             =cut
13              
14             sub opt_spec {
15 27     27 1 49320 my ( $class, $app ) = @_;
16 27         126 return ( [ 'help|h' => 'This usage screen.' ], $class->options($app), );
17             }
18              
19             sub validate_args {
20 27     27 1 49221 my ( $self, $opt, $args ) = @_;
21 27 50       151 if ( $opt->{'help'} ) {
22 0         0 my ($command) = $self->command_names;
23 0         0 $self->app->execute_command( $self->app->prepare_command( 'help', $command ) );
24 0         0 exit;
25             }
26 27         131 $self->validate( $opt, $args );
27             }
28              
29             # returns the text to work on, either the remaining args joined by a
30             # space or stdin slurped
31             sub text_from {
32 7     7 0 16 my ( $self, $args ) = @_;
33              
34 7 50       11 if ( @{$args} ) {
  7         25  
35 7         13 return join( ' ', @{$args} );
  7         39  
36             }
37              
38 0           my $text = do { local $/; };
  0            
  0            
39 0           return $text;
40             } ## end sub text_from
41              
42             1;