| 1 | package Text::Graph::DataSet; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 8 | ▶ | use Moo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 8 | ▶ | use namespace::clean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 8 | our $VERSION = '0.83'; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 8 | has values => ( | |||||||||||||||||||
| 11 | is => 'ro', | ||||||||||||||||||||
| 12 | reader => 'get_values', | ||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||
| 14 | 8 | 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 | 49 | ▶ | { | ||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=15 SCAR=27.1
Pod
undocumented
| |||||||||||||||||||||
| 24 | 49 | my ( $class, @args ) = @_; | |||||||||||||||||||
| 25 | 49 | ▶ | return { values => [], labels => [] } if !@args; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | 48 | my ( $values, $labels, $hash ) = ( [], undef, undef ); | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 48 | ▶ | if( ref $args[0] eq ref [] ) | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 29 | { | ||||||||||||||||||||
| 30 | 42 | $values = shift @args; | |||||||||||||||||||
| 31 | 42 | ▶ | if( ref $args[0] eq ref [] ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | { | ||||||||||||||||||||
| 33 | 36 | $labels = shift @args; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | elsif( ref $args[0] eq ref {} ) | ||||||||||||||||||||
| 37 | { | ||||||||||||||||||||
| 38 | 4 | $hash = shift @args; | |||||||||||||||||||
| 39 | 4 | ▶ | if( ref $args[0] eq ref [] ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | { | ||||||||||||||||||||
| 41 | 1 | $labels = shift @args; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | 48 | ▶ | die "Odd number of parameters to new.\n" if @args % 2 == 1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 45 | 47 | ▶ | my %real_args = ( sort => sub { sort @_ }, @args ); | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 46 | 47 | my $sortref = delete $real_args{sort}; | |||||||||||||||||||
| 47 | 47 | ▶ | $hash ||= delete $real_args{hash}; | ||||||||||||||||||
|
Condition100%3/3
$hash ||= delete $real_args{"hash"}
MC/DC100%2/2
$hash ||= delete $real_args{"hash"}
$hash
delete $real_args{"hash"}
Truth table100%3/3
A ||= B
A= $hashB= delete $real_args{"hash"}
| |||||||||||||||||||||
| 48 | 47 | ▶ | if( defined $hash ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | { | ||||||||||||||||||||
| 50 | 5 | ▶ | if( $sortref ) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | { | ||||||||||||||||||||
| 52 | 4 | my ( $pkg ) = caller; | |||||||||||||||||||
| 53 | 4 | ▶ | $labels ||= [ $sortref->( keys %{$hash} ) ] if !$labels; | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$labels ||= [&$sortref(keys %{$hash;})]
MC/DC0%0/1
$labels ||= [&$sortref(keys %{$hash;})]
$labels
Truth table50%1/2
A
A= $labels
| |||||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | else | ||||||||||||||||||||
| 56 | { | ||||||||||||||||||||
| 57 | 1 | ▶ | $labels ||= [ keys %{$hash} ]; | ||||||||||||||||||
|
Condition50%1/2
$labels ||= [keys %{$hash;}]
MC/DC0%0/1
$labels ||= [keys %{$hash;}]
$labels
Truth table50%1/2
A
A= $labels
| |||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | 5 | $values = [ @{$hash}{ @{$labels} } ]; | |||||||||||||||||||
| 60 | 5 | $hash = undef; | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | 47 | ▶ | $labels ||= []; | ||||||||||||||||||
|
Condition100%2/2
$labels ||= []
MC/DC100%1/1
$labels ||= []
$labels
Truth table100%2/2
A
A= $labels
| |||||||||||||||||||||
| 63 | 47 | ▶ | push @{$labels}, ( '' ) x ( @{$values} - @{$labels} ) if @{$values} > @{$labels}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | 47 | 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 | 149 | ▶ | { | ||||||||||||||||||
|
Subroutine
_list_or_ref: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 71 | 149 | my ( $orig, $self ) = @_; | |||||||||||||||||||
| 72 | 149 | my $val = $orig->( $self ); | |||||||||||||||||||
| 73 | 149 | ▶ | return wantarray ? @{$val} : $val; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 74 | } | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 8 | around 'get_values' => \&_list_or_ref; | |||||||||||||||||||
| 77 | 8 | around 'get_labels' => \&_list_or_ref; | |||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 8 | 1; | |||||||||||||||||||
| 80 | __END__ | ||||||||||||||||||||