line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Graph::DataSet; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
19553
|
use strict; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
292
|
|
4
|
8
|
|
|
8
|
|
34
|
use warnings; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
218
|
|
5
|
8
|
|
|
8
|
|
735
|
use Moo; |
|
8
|
|
|
|
|
12180
|
|
|
8
|
|
|
|
|
60
|
|
6
|
8
|
|
|
8
|
|
3258
|
use namespace::clean; |
|
8
|
|
|
|
|
9121
|
|
|
8
|
|
|
|
|
33
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.83'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has values => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
reader => 'get_values', |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
has labels => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
reader => 'get_labels', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
# This routine is quite complicated to support the bizarre interface that I |
21
|
|
|
|
|
|
|
# originally supported. |
22
|
|
|
|
|
|
|
sub BUILDARGS |
23
|
|
|
|
|
|
|
{ |
24
|
49
|
|
|
49
|
0
|
13266
|
my ( $class, @args ) = @_; |
25
|
49
|
100
|
|
|
|
128
|
return { values => [], labels => [] } if !@args; |
26
|
48
|
|
|
|
|
73
|
my ( $values, $labels, $hash ) = ( [], undef, undef ); |
27
|
|
|
|
|
|
|
|
28
|
48
|
100
|
|
|
|
115
|
if( ref $args[0] eq ref [] ) |
|
|
100
|
|
|
|
|
|
29
|
|
|
|
|
|
|
{ |
30
|
42
|
|
|
|
|
47
|
$values = shift @args; |
31
|
42
|
100
|
|
|
|
90
|
if( ref $args[0] eq ref [] ) |
32
|
|
|
|
|
|
|
{ |
33
|
36
|
|
|
|
|
37
|
$labels = shift @args; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif( ref $args[0] eq ref {} ) |
37
|
|
|
|
|
|
|
{ |
38
|
4
|
|
|
|
|
5
|
$hash = shift @args; |
39
|
4
|
100
|
|
|
|
8
|
if( ref $args[0] eq ref [] ) |
40
|
|
|
|
|
|
|
{ |
41
|
1
|
|
|
|
|
2
|
$labels = shift @args; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
48
|
100
|
|
|
|
119
|
die "Odd number of parameters to new.\n" if @args % 2 == 1; |
45
|
47
|
|
|
1
|
|
198
|
my %real_args = ( sort => sub { sort @_ }, @args ); |
|
1
|
|
|
|
|
5
|
|
46
|
47
|
|
|
|
|
92
|
my $sortref = delete $real_args{sort}; |
47
|
47
|
|
100
|
|
|
153
|
$hash ||= delete $real_args{hash}; |
48
|
47
|
100
|
|
|
|
72
|
if( defined $hash ) |
49
|
|
|
|
|
|
|
{ |
50
|
5
|
100
|
|
|
|
7
|
if( $sortref ) |
51
|
|
|
|
|
|
|
{ |
52
|
4
|
|
|
|
|
8
|
my ( $pkg ) = caller; |
53
|
4
|
100
|
50
|
|
|
11
|
$labels ||= [ $sortref->( keys %{$hash} ) ] if !$labels; |
|
3
|
|
|
|
|
20
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else |
56
|
|
|
|
|
|
|
{ |
57
|
1
|
|
50
|
|
|
21
|
$labels ||= [ keys %{$hash} ]; |
|
1
|
|
|
|
|
4
|
|
58
|
|
|
|
|
|
|
} |
59
|
5
|
|
|
|
|
24
|
$values = [ @{$hash}{ @{$labels} } ]; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
5
|
|
60
|
5
|
|
|
|
|
5
|
$hash = undef; |
61
|
|
|
|
|
|
|
} |
62
|
47
|
|
100
|
|
|
81
|
$labels ||= []; |
63
|
47
|
100
|
|
|
|
38
|
push @{$labels}, ( '' ) x ( @{$values} - @{$labels} ) if @{$values} > @{$labels}; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
22
|
|
|
47
|
|
|
|
|
50
|
|
|
47
|
|
|
|
|
90
|
|
64
|
47
|
|
|
|
|
1005
|
return { values => $values, labels => $labels, %real_args }; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# |
68
|
|
|
|
|
|
|
# Support the list or array ref original interface. |
69
|
|
|
|
|
|
|
sub _list_or_ref |
70
|
|
|
|
|
|
|
{ |
71
|
149
|
|
|
149
|
|
9673
|
my ( $orig, $self ) = @_; |
72
|
149
|
|
|
|
|
245
|
my $val = $orig->( $self ); |
73
|
149
|
100
|
|
|
|
224
|
return wantarray ? @{$val} : $val; |
|
129
|
|
|
|
|
544
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
around 'get_values' => \&_list_or_ref; |
77
|
|
|
|
|
|
|
around 'get_labels' => \&_list_or_ref; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
__END__ |