File Coverage

blib/lib/Data/TableData/Object.pm
Criterion Covered Total %
statement 28 31 90.3
branch 9 12 75.0
condition 1 3 33.3
subroutine 8 8 100.0
pod 2 2 100.0
total 48 56 85.7


line stmt bran cond sub pod time code
1             package Data::TableData::Object;
2              
3 4     4   307193 use 5.010001;
  4         65  
4 4     4   24 use strict;
  4         8  
  4         89  
5 4     4   22 use warnings;
  4         7  
  4         161  
6              
7 4     4   2318 use Data::Check::Structure qw(is_aos is_aoaos is_aohos);
  4         6376  
  4         354  
8 4     4   33 use Exporter qw(import);
  4         10  
  4         109  
9 4     4   21 use Scalar::Util qw(blessed);
  4         9  
  4         1384  
10              
11             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
12             our $DATE = '2021-11-17'; # DATE
13             our $DIST = 'Data-TableData-Object'; # DIST
14             our $VERSION = '0.114'; # VERSION
15              
16             our @EXPORT_OK = qw(table);
17              
18 49     49 1 28497 sub table { __PACKAGE__->new(@_) }
19              
20             sub new {
21 49     49 1 154 my ($class, $data, $spec) = @_;
22 49 50 33     506 if (!defined($data)) {
    50          
    100          
    100          
    100          
    50          
23 0         0 die "Please specify table data";
24             } elsif (blessed($data) && $data->isa("Data::TableData::Object::Base")) {
25 0         0 return $data;
26             } elsif (ref($data) eq 'HASH') {
27 17         711 require Data::TableData::Object::hash;
28 17         87 Data::TableData::Object::hash->new($data);
29             } elsif (is_aoaos($data)) {
30 9         1353 require Data::TableData::Object::aoaos;
31 9         41 Data::TableData::Object::aoaos->new($data, $spec);
32             } elsif (is_aohos($data)) {
33 8         1777 require Data::TableData::Object::aohos;
34 8         56 Data::TableData::Object::aohos->new($data, $spec);
35             } elsif (ref($data) eq 'ARRAY') {
36 15         1694 require Data::TableData::Object::aos;
37 15         70 Data::TableData::Object::aos->new($data);
38             } else {
39 0           die "Unknown table data form, please supply array of scalar, ".
40             "array of array-of-scalar, or array of hash-of-scalar";
41             }
42             }
43              
44             1;
45             # ABSTRACT: Manipulate data structure via table object
46              
47             __END__