| 1 | package Javascript::Select::Chain::Nested; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | ▶ | use 5.006001; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 1 | ▶ | use Carp qw/confess/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 1 | ▶ | use Data::Dumper; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 1 | ▶ | use FileHandle; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 1 | require Exporter; | |||||||||||
| 12 | |||||||||||||
| 13 | 1 | our @ISA = qw(Exporter); | |||||||||||
| 14 | |||||||||||||
| 15 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||
| 16 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||
| 17 | # Do not simply export all your public functions/methods/constants. | ||||||||||||
| 18 | |||||||||||||
| 19 | # This allows declaration use Javascript::Select::Chain ':all'; | ||||||||||||
| 20 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||
| 21 | # will save memory. | ||||||||||||
| 22 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||
| 23 | |||||||||||||
| 24 | ) ], | ||||||||||||
| 25 | ); | ||||||||||||
| 26 | |||||||||||||
| 27 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } , | |||||||||||
| 28 | 'selectchain' | ||||||||||||
| 29 | ); | ||||||||||||
| 30 | |||||||||||||
| 31 | 1 | our @EXPORT = qw( | |||||||||||
| 32 | |||||||||||||
| 33 | ); | ||||||||||||
| 34 | |||||||||||||
| 35 | 1 | our $VERSION = '0.04'; | |||||||||||
| 36 | |||||||||||||
| 37 | |||||||||||||
| 38 | # Preloaded methods go here. | ||||||||||||
| 39 | |||||||||||||
| 40 | |||||||||||||
| 41 | 0 | ▶ | sub header { | ||||||||||
|
Subroutine
header: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 42 | 0 | my $fh = shift; | |||||||||||
| 43 | 0 | print $fh "var hide_empty_list=true;\n\n"; | |||||||||||
| 44 | } | ||||||||||||
| 45 | |||||||||||||
| 46 | 1 | ▶ | sub validate { | ||||||||||
|
Subroutine
validate: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||||
| 47 | |||||||||||||
| 48 | 1 | my $model = shift; | |||||||||||
| 49 | |||||||||||||
| 50 | exists $model->{listgroupname} or | ||||||||||||
| 51 | 1 | ▶ | confess "listgroupname must be supplied in model"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | |||||||||||||
| 53 | exists $model->{data} or | ||||||||||||
| 54 | 1 | ▶ | confess "data must be supplied in model"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 55 | |||||||||||||
| 56 | |||||||||||||
| 57 | } | ||||||||||||
| 58 | |||||||||||||
| 59 | 1 | ▶ | sub add_list_group { | ||||||||||
|
Subroutine
add_list_group: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 60 | |||||||||||||
| 61 | 1 | my ($fh, $model) = @_; | |||||||||||
| 62 | |||||||||||||
| 63 | 1 | my $first_list_item = (keys %{$model->{data}[0][0]})[0]; | |||||||||||
| 64 | 1 | ▶ | $first_list_item = "" unless defined($first_list_item); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 65 | |||||||||||||
| 66 | print $fh sprintf 'addListGroup("%s", "%s");', | ||||||||||||
| 67 | $model->{listgroupname}, | ||||||||||||
| 68 | 1 | $first_list_item; | |||||||||||
| 69 | |||||||||||||
| 70 | 1 | print $fh "\n\n"; | |||||||||||
| 71 | } | ||||||||||||
| 72 | |||||||||||||
| 73 | 102 | ▶ | sub quoteary { | ||||||||||
|
Subroutine
quoteary: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||
| 74 | 102 | my $ary = shift; | |||||||||||
| 75 | 102 | my $size = shift; | |||||||||||
| 76 | |||||||||||||
| 77 | 102 | for my $elt (0..$size-2) { | |||||||||||
| 78 | 331 | ▶ | $ary->[$elt] = "" unless defined($ary->[$elt]); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 79 | 331 | $ary->[$elt] = sprintf '"%s"', $ary->[$elt]; | |||||||||||
| 80 | } | ||||||||||||
| 81 | |||||||||||||
| 82 | } | ||||||||||||
| 83 | |||||||||||||
| 84 | 1 | my %quoteary = (addList => 5, addOption => 4); | |||||||||||
| 85 | |||||||||||||
| 86 | 102 | ▶ | sub addonelist { | ||||||||||
|
Subroutine
addonelist: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 87 | |||||||||||||
| 88 | 102 | my ($fh, $ary, $func) = @_; | |||||||||||
| 89 | |||||||||||||
| 90 | 102 | quoteary($ary, $quoteary{$func}); | |||||||||||
| 91 | |||||||||||||
| 92 | 102 | print $fh sprintf "$func(%s);\n", join ', ', @$ary; | |||||||||||
| 93 | } | ||||||||||||
| 94 | |||||||||||||
| 95 | 3 | ▶ | sub addlistary { | ||||||||||
|
Subroutine
addlistary: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||
| 96 | 3 | my ($fh, $data, $func) = @_; | |||||||||||
| 97 | |||||||||||||
| 98 | |||||||||||||
| 99 | 3 | for my $record (@$data) { | |||||||||||
| 100 | 21 | my ($list_name, $list_data) = each %$record; | |||||||||||
| 101 | |||||||||||||
| 102 | 21 | for my $list_item (@{$list_data}) { | |||||||||||
| 103 | 102 | addonelist($fh, [ $list_name, @$list_item ], $func); | |||||||||||
| 104 | } | ||||||||||||
| 105 | } | ||||||||||||
| 106 | |||||||||||||
| 107 | } | ||||||||||||
| 108 | |||||||||||||
| 109 | 1 | ▶ | sub addlist { | ||||||||||
|
Subroutine
addlist: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 110 | 1 | my ($fh,$data) = @_; | |||||||||||
| 111 | |||||||||||||
| 112 | |||||||||||||
| 113 | 1 | for my $d (0 .. $#$data-1) { | |||||||||||
| 114 | 2 | addlistary($fh, $data->[$d], 'addList'); | |||||||||||
| 115 | } | ||||||||||||
| 116 | |||||||||||||
| 117 | } | ||||||||||||
| 118 | |||||||||||||
| 119 | 1 | ▶ | sub addoption { | ||||||||||
|
Subroutine
addoption: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 120 | 1 | my ($fh,$data) = @_; | |||||||||||
| 121 | |||||||||||||
| 122 | |||||||||||||
| 123 | # warn Dumper($data->[$#$data]); | ||||||||||||
| 124 | |||||||||||||
| 125 | 1 | addlistary($fh, $data->[$#$data], 'addOption'); | |||||||||||
| 126 | |||||||||||||
| 127 | |||||||||||||
| 128 | } | ||||||||||||
| 129 | |||||||||||||
| 130 | |||||||||||||
| 131 | |||||||||||||
| 132 | |||||||||||||
| 133 | 1 | ▶ | sub selectchain { | ||||||||||
|
Subroutine
selectchain: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||
| 134 | 1 | my ($model, $config) = @_; | |||||||||||
| 135 | |||||||||||||
| 136 | 1 | validate $model ; | |||||||||||
| 137 | |||||||||||||
| 138 | 1 | ▶ | my $js = $config->{js} || "_out.js"; | ||||||||||
|
Condition50%1/2
$config->{'js'} || '_out.js'
MC/DC0%0/1
$config->{'js'} || '_out.js'
$config->{'js'}
Truth table50%1/2
A
A= $config->{'js'}
| |||||||||||||
| 139 | 1 | my $jsf = new FileHandle; | |||||||||||
| 140 | 1 | ▶ | $jsf->open("> $js") or die $!; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 141 | |||||||||||||
| 142 | # header($jsf); | ||||||||||||
| 143 | 1 | add_list_group($jsf, $model); | |||||||||||
| 144 | |||||||||||||
| 145 | 1 | addlist($jsf, $model->{data}); | |||||||||||
| 146 | 1 | addoption($jsf, $model->{data}); | |||||||||||
| 147 | |||||||||||||
| 148 | } | ||||||||||||
| 149 | |||||||||||||
| 150 | 1 | 1; | |||||||||||
| 151 | __END__ | ||||||||||||