File Coverage

blib/lib/App/PYX/Optimization.pm
Criterion Covered Total %
statement 30 30 100.0
branch 4 4 100.0
condition 6 6 100.0
subroutine 6 6 100.0
pod 2 2 100.0
total 48 48 100.0


line stmt bran cond sub pod time code
1             package App::PYX::Optimization;
2              
3 4     4   97820 use strict;
  4         25  
  4         113  
4 4     4   23 use warnings;
  4         7  
  4         140  
5              
6 4     4   8360 use Getopt::Std;
  4         205  
  4         268  
7 4     4   1989 use PYX::Optimization;
  4         137602  
  4         1061  
8              
9             our $VERSION = 0.04;
10              
11             # Constructor.
12             sub new {
13 6     6 1 8774 my ($class, @params) = @_;
14              
15             # Create object.
16 6         16 my $self = bless {}, $class;
17              
18             # Object.
19 6         27 return $self;
20             }
21              
22             # Run script.
23             sub run {
24 5     5 1 8 my $self = shift;
25              
26             # Process arguments.
27 5         19 $self->{'_opts'} = {
28             'h' => 0,
29             };
30 5 100 100     17 if (! getopts('h', $self->{'_opts'}) || $self->{'_opts'}->{'h'}
      100        
31             || @ARGV < 1) {
32              
33 3         364 print STDERR "Usage: $0 [-h] [--version] [filename] [-]\n";
34 3         43 print STDERR "\t-h\t\tPrint help.\n";
35 3         30 print STDERR "\t--version\tPrint version.\n";
36 3         31 print STDERR "\tfilename\tProcess on filename.\n";
37 3         31 print STDERR "\t-\t\tProcess on stdin.\n";
38 3         19 return 1;
39             }
40 2         63 $self->{'_filename_or_stdin'} = $ARGV[0];
41              
42             # PYX::Optimization object.
43 2         11 my $optimizer = PYX::Optimization->new;
44              
45             # Parse from stdin.
46 2 100       208 if ($self->{'_filename_or_stdin'} eq '-') {
47 1         6 $optimizer->parse_handler(\*STDIN);
48              
49             # Parse file.
50             } else {
51 1         8 $optimizer->parse_file($self->{'_filename_or_stdin'});
52             }
53              
54 2         2093 return 1;
55             }
56              
57             1;
58              
59             __END__