File Coverage

blib/lib/Astro/STSDAS/Table/Simple.pm
Criterion Covered Total %
statement 12 29 41.3
branch 0 14 0.0
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 49 34.6


line stmt bran cond sub pod time code
1             package Astro::STSDAS::Table::Simple;
2              
3 1     1   20962 use strict;
  1         2  
  1         33  
4 1     1   5 use warnings;
  1         2  
  1         23  
5              
6 1     1   626 use Astro::STSDAS::Table::Binary;
  1         3  
  1         33  
7              
8 1     1   7 use Carp;
  1         2  
  1         410  
9              
10             require Exporter;
11              
12             our @ISA = qw(Exporter);
13              
14             our %EXPORT_TAGS = ( 'all' => [ qw(
15             read_binary
16             ) ] );
17              
18             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
19              
20             our $VERSION = '0.01';
21              
22              
23             sub read_table
24             {
25 0     0 1   my ( $file, %uattr ) = @_;
26              
27              
28 0           my %attr = ( input => 'Binary',
29             output => 'RowHash',
30             );
31              
32 0           my ( $key, $val );
33 0           $attr{lc $key} = $val while( ( $key, $val ) = each %uattr );
34              
35 0           my $input = lc $attr{input};
36 0           my $output = lc $attr{output};
37            
38 0 0         croak( __PACKAGE__, "->read_table: only binary tables are supported\n" )
39             unless 'binary' eq $input;
40              
41              
42 0           my $tbl;
43 0 0         if ( 'binary' eq $input )
44             {
45 0           $tbl = Astro::STSDAS::Table::Binary->new;
46             }
47              
48 0 0         $tbl->open( $file ) or
49             croak( __PACKAGE__, "::read_table: unable to open $file\n" );
50              
51 0 0         if ( 'rowhash' eq $output )
    0          
    0          
    0          
52             {
53 0           $tbl->read_rows_hash
54             }
55             elsif ( 'colhash' eq $output )
56             {
57 0           $tbl->read_cols_hash
58             }
59             elsif ( 'rowarray' eq $output )
60             {
61 0           $tbl->read_rows_array
62             }
63             elsif ( 'rowarray' eq $output )
64             {
65 0           $tbl->read_rows_array
66             }
67             else
68             {
69 0           croak( __PACKAGE__,
70             "::read_table: unknown output type: $attr{output}\n" );
71             }
72             }
73              
74             1;
75              
76             __END__