DevexpressHelpers/Helpers.pm

filter: Statementstmt 84.4% 158 / 187 Branchbran 64.7% 44 / 68 Conditioncond 59.2% 45 / 76 MC/DCmcdc 35.7% 15 / 42 Subroutinesub 78.5% 22 / 28 Podpod 100% 21 / 21 totaltotal 72.2% 305 / 422 CC 71 SCAR 24.6
CC
71
Cov
75%
dxbind
22.2
prepend_js
20.0
append_js
20.0
CRAP 11.7
↑ Summary DevexpressHelpers.pm »
1 7 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Mojolicious::Plugin::DevexpressHelpers::Helpers;
3 7 $Mojolicious::Plugin::DevexpressHelpers::Helpers::VERSION = '0.163572';
4 #ABSTRACT: Helpers for Devexpress controls are defined here
5 7 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use Mojo::ByteStream;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶use MojoX::AlmostJSON qw(encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 ▶use constant DEBUG => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 #Not sure why C<out> function have to decode from utf8,
11 #but it make my day!
12 7 our $OUT_DECODE = 'UTF-8';
13 7 our $INDENT_BINDING = 0;
14  
15 7 my @generic_controls = qw(
16 Accordion
17 ActionSheet
18 Autocomplete
19 Box
20 CheckBox
21 Calendar
22 ColorBox
23 ContextMenu
24 DateBox
25 DeferRendering
26 FileUploader
27 Gallery
28 List
29 LoadIndicator
30 Lookup
31 Map
32 MultiView
33 NavBar
34 NumberBox
35 Panorama
36 Pivot
37 PivotGrid
38 PivotGridFieldChooser
39 Popover
40 ProgressBar
41 RadioGroup
42 RangeSlider
43 Resizable
44 ResponsiveBox
45 Scheduler
46 ScrollView
47 SelectBox
48 Slider
49 Switch
50 TabPanel
51 Tabs
52 TagBox
53 TextArea
54 TextBox
55 TitleView
56 Toast
57 Toolbar
58 TreeView
59 );
60  
61 #Helper method to export without prepending a prefix
62 7 my @without_prefix = qw( dxbuild required_assets require_asset indent_binding append_js prepend_js );
63  
64 #Helper method to export with prepending a prefix
65 7 my @with_prefix = (qw( Button DataGrid Form Popup Menu LoadPanel Lookup ),
66 @generic_controls);
67  
68  
69 20 ▶sub out{
Subroutine out: called CC=2 SCAR=7.6
Pod documented
70 20 my $tag = shift;
71 20 my $bytes = Mojo::ByteStream->new($tag);
72 20 ▶ return $bytes->decode($OUT_DECODE) if defined $OUT_DECODE;
Branch: 1 branch
BranchTrueFalseTotal
if defined $Mojolicious::Plugin::DevexpressHelpers::Helpers::OUT_DECODE 20 0 20
73 0 return $bytes;
74 }
75  
76 12 ▶sub new{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
77 12 my $class = shift;
78 12 my $self = bless {
79 next_id => 1,
80 bindings => '',
81 before_bindings => '',
82 after_bindings => '',
83 }, $class;
84 12 return $self;
85 }
86  
87 0 ▶sub indent_binding{
Subroutine indent_binding: not called CC=1 SCAR=6.9
Pod documented
88 0 my $self = shift;
89 0 $INDENT_BINDING = shift;
90 }
91  
92 10 ▶sub add_binding{
Subroutine add_binding: called CC=1 SCAR=0.0
Pod documented
93 10 my $self = shift;
94 10 $self->{bindings} .= join "\n", @_;
95 }
96  
97 3 ▶sub next_id{
Subroutine next_id: called CC=1 SCAR=0.0
Pod documented
98 3 my $self = shift;
99 3 return "dxctl".($self->{next_id}++);
100 }
101  
102 3 ▶sub new_id{
Subroutine new_id: called CC=1 SCAR=0.0
Pod documented
103 3 my ($c, $attrs) = @_;
104 #should compute a new uniq id
105 3 $c->stash('dxHelper')->next_id;
106 }
107  
108 10 ▶sub dxbind{
Subroutine dxbind: called CC=22 SCAR=31.0
Pod documented
109 10 my ($c, $control, $id, $attrs, $extensions, $befores, $afters) = @_;
110 #should return html code to be associated to the control
111 10 ▶ $befores //=[];
Condition100%2/2
$befores //= []
l!l
37
MC/DC100%1/1
$befores //= []
$befores
Truth table100%2/2
A
A= $befores
Aresult
11
00
112 10 ▶ $afters //=[];
Condition100%2/2
$afters //= []
l!l
37
MC/DC100%1/1
$afters //= []
$afters
Truth table100%2/2
A
A= $afters
Aresult
11
00
113 #http://stackoverflow.com/questions/9930577/jquery-dot-in-id-selector
114 10 my $jquery_id = $id;
115 10 $jquery_id =~ s{\.}{\\\\.}g;
116 10 ▶ my $prepend = ref $attrs eq 'HASH' && delete $attrs->{prependTo};
Condition100%3/3
ref $attrs eq 'HASH' && delete $attrs->{'prependTo'}
!ll&&!rl&&r
181
MC/DC100%2/2
ref $attrs eq 'HASH' && delete $attrs->{'prependTo'}
ref $attrs eq 'HASH' delete $attrs->{'prependTo'}
Truth table100%3/3
A && B
A= ref $attrs eq 'HASH'B= delete $attrs->{'prependTo'}
ABresult
0X0
100
111
117 10 ▶ my $append = ref $attrs eq 'HASH' && delete $attrs->{appendTo};
Condition100%3/3
ref $attrs eq 'HASH' && delete $attrs->{'appendTo'}
!ll&&!rl&&r
181
MC/DC100%2/2
ref $attrs eq 'HASH' && delete $attrs->{'appendTo'}
ref $attrs eq 'HASH' delete $attrs->{'appendTo'}
Truth table100%3/3
A && B
A= ref $attrs eq 'HASH'B= delete $attrs->{'appendTo'}
ABresult
0X0
100
111
118 10 my $binding = '';
119 10 ▶ if($prepend || $append){
Branch: 1 branch
BranchTrueFalseTotal
if ($prepend or $append) { } 2 8 10
Condition100%3/3
$prepend or $append
l!l&&r!l&&!r
118
MC/DC100%2/2
$prepend or $append
$prepend $append
Truth table100%3/3
A or B
A= $prependB= $append
ABresult
1X1
011
000
120 2 $binding = '$(\'<div id="'.$id.'">\').'.$control.'(';
121 }
122 else{
123 8 $binding = '$("#'.$jquery_id.'").'.$control.'(';
124 }
125 10 my @options;
126  
127 10 ▶ if (ref($attrs) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attrs eq 'HASH') { } 9 1 10
128 9 $binding .= '{';
129 9 ▶ $binding .= "\n " if $INDENT_BINDING;
Branch: 1 branch
BranchTrueFalseTotal
if $Mojolicious::Plugin::DevexpressHelpers::Helpers::INDENT_BINDING 0 9 9
130 9 for my $k ( sort keys %$attrs){
131 19 ▶ my $v = $attrs->{$k} // '';
Condition50%1/2
$attrs->{$k} // ""
l!l
190
MC/DC0%0/1
$attrs->{$k} // ""
$attrs->{$k}
Truth table50%1/2
A
A= $attrs->{$k}
Aresult
11
00
132 19 ▶ if(ref($v) eq 'SCALAR'){
Branch: 2 branches
BranchTrueFalseTotal
if (ref $v eq 'SCALAR') { } 2 17 19
elsif (not $v =~ /^\s*(?:function\s*\()/u) { } 17 0 17
133 #unref protected scalar
134 2 $v = $$v;
135 }
136 elsif ($v!~/^\s*(?:function\s*\()/) {
137 17 $v = encode_json $v;
138 }
139 19 push @options, "$k: $v";
140 }
141 }
142 else{
143 1 push @options, $attrs;
144 }
145 10 ▶ $binding .= join ",\n".($INDENT_BINDING?' ':''), @options;
Branch: 1 branch
BranchTrueFalseTotal
$Mojolicious::Plugin::DevexpressHelpers::Helpers::INDENT_BINDING ? : 0 10 10
146 10 ▶ $binding .= '}' if ref($attrs) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $attrs eq "HASH" 9 1 10
147 10 $binding .= ')';
148 10 ▶ $binding .= '.prependTo("'.$prepend.'")' if $prepend;
Branch: 1 branch
BranchTrueFalseTotal
if $prepend 1 9 10
149 10 ▶ $binding .= '.appendTo("'.$append.'")' if $append;
Branch: 1 branch
BranchTrueFalseTotal
if $append 1 9 10
150 10 ▶ $binding .= ';' . ($INDENT_BINDING?"\n":"");
Branch: 1 branch
BranchTrueFalseTotal
$Mojolicious::Plugin::DevexpressHelpers::Helpers::INDENT_BINDING ? : 0 10 10
151 #append some extensions (eg: dxdatagrid)
152 10 ▶ $binding .= join ";\n".($INDENT_BINDING?' ':''), @$extensions if defined $extensions;
Branch: 2 branches
BranchTrueFalseTotal
if defined $extensions 3 7 10
$Mojolicious::Plugin::DevexpressHelpers::Helpers::INDENT_BINDING ? : 0 3 3
153 10 $c->stash('dxHelper')->add_binding($binding);
154 10 my $html_code = "<div id=\"$id\"></div>";
155 10 ▶ if($prepend || $append){
Branch: 1 branch
BranchTrueFalseTotal
if ($prepend or $append) 2 8 10
Condition100%3/3
$prepend or $append
l!l&&r!l&&!r
118
MC/DC100%2/2
$prepend or $append
$prepend $append
Truth table100%3/3
A or B
A= $prependB= $append
ABresult
1X1
011
000
156 2 $html_code = '';
157 }
158 10 out join('',@$befores, $html_code ,@$afters);
159 }
160  
161  
162 10 ▶sub parse_attributs{
Subroutine parse_attributs: called CC=15 SCAR=28.9
Pod documented
163 10 my $c = shift;
164 10 my @implicit_args = @{shift()};
165 10 my %attrs;
166 IMPLICIT_ARGUMENT:
167 10 ▶ while(@_ and @implicit_args){
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and @implicit_args) 27 8 35
Condition100%3/3
@_ and @implicit_args
!ll&&!rl&&r
3527
MC/DC100%2/2
@_ and @implicit_args
@_ @implicit_args
Truth table100%3/3
A and B
A= @_B= @implicit_args
ABresult
0X0
100
111
168 27 my $ref = ref($_[0]);
169 27 ▶ my $implicit = shift @implicit_args || '';
Condition50%1/2
shift @implicit_args || ''
l!l
270
MC/DC0%0/1
shift @implicit_args || ''
shift @implicit_args
Truth table50%1/2
A
A= shift @implicit_args
Aresult
11
00
170 27 ▶ last unless $ref =~ /^(?:|SCALAR)$/
Branch: 1 branch
BranchTrueFalseTotal
unless $ref =~ /^(?:|SCALAR)$/u or substr($implicit, 0, 1) eq "\@" and $ref eq "ARRAY" or substr($implicit, 0, 1) eq "%" and $ref eq "HASH" or substr($implicit, 0, 1) eq "\\" and $ref eq "REF" or substr($implicit, 0, 1) eq "*" 2 25 27
Condition52%11/21
$ref =~ /^(?:|SCALAR)$/u or substr($implicit, 0, 1) eq "\@" and $ref eq "ARRAY" or substr($implicit, 0, 1) eq "%" and $ref eq "HASH" or substr($implicit, 0, 1) eq "\\" and $ref eq "REF" or substr($implicit, 0, 1) eq "*"
l!l&&r!l&&!r
2502
$ref =~ /^(?:|SCALAR)$/u or substr($implicit, 0, 1) eq "\@" and $ref eq "ARRAY" or substr($implicit, 0, 1) eq "%" and $ref eq "HASH" or substr($implicit, 0, 1) eq "\\" and $ref eq "REF"
l!l&&r!l&&!r
2502
$ref =~ /^(?:|SCALAR)$/u or substr($implicit, 0, 1) eq "\@" and $ref eq "ARRAY" or substr($implicit, 0, 1) eq "%" and $ref eq "HASH"
l!l&&r!l&&!r
2502
$ref =~ /^(?:|SCALAR)$/u or substr($implicit, 0, 1) eq "\@" and $ref eq "ARRAY"
l!l&&r!l&&!r
2502
substr($implicit, 0, 1) eq "\@" and $ref eq "ARRAY"
!ll&&!rl&&r
200
substr($implicit, 0, 1) eq "%" and $ref eq "HASH"
!ll&&!rl&&r
200
substr($implicit, 0, 1) eq "\\" and $ref eq "REF"
!ll&&!rl&&r
200
MC/DC12%1/8
$ref =~ /^(?:|SCALAR)$/u or substr($implicit, 0, 1) eq "\@" and $ref eq "ARRAY" or substr($implicit, 0, 1) eq "%" and $ref eq "HASH" or substr($implicit, 0, 1) eq "\\" and $ref eq "REF" or substr($implicit, 0, 1) eq "*"
$ref =~ /^(?:|SCALAR)$/u substr($implicit, 0, 1) eq "\@" $ref eq "ARRAY" substr($implicit, 0, 1) eq "%" $ref eq "HASH" substr($implicit, 0, 1) eq "\\" $ref eq "REF" substr($implicit, 0, 1) eq "*"
Truth table8%2/24
A or B and C or D and E or F and G or H
A= $ref =~ /^(?:|SCALAR)$/uB= substr($implicit, 0, 1) eq "\@"C= $ref eq "ARRAY"D= substr($implicit, 0, 1) eq "%"E= $ref eq "HASH"F= substr($implicit, 0, 1) eq "\\"G= $ref eq "REF"H= substr($implicit, 0, 1) eq "*"
ABCDEFGHresult
1XXXXXXX1
011XXXXX1
00X11XXX1
01011XXX1
00X0X11X1
00X1011X1
0100X11X1
0101011X1
00X0X0X11
00X0X1011
00X100X11
00X101011
0100X0X11
0100X1011
010100X11
010101011
00X0X0X00
00X0X1000
00X100X00
00X101000
0100X0X00
0100X1000
010100X00
010101000
171 or (substr($implicit,0,1) eq '@' and $ref eq 'ARRAY')
172 or (substr($implicit,0,1) eq '%' and $ref eq 'HASH')
173 or (substr($implicit,0,1) eq '\\' and $ref eq 'REF')
174 or (substr($implicit,0,1) eq '*');
175 25 $implicit =~ s/^[\\\*\%\@]//;
176 25 $attrs{ $implicit } = shift @_;
177 }
178 10 ▶ if(my $args = shift){
Branch: 1 branch
BranchTrueFalseTotal
if (my $args = shift()) 7 3 10
179 7 ▶ if(ref($args) eq 'HASH'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args eq "HASH") 7 0 7
180 NAMED_ARGUMENT:
181 7 ▶ while(my($k,$v)=each %$args){
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$args) 8 7 15
182 8 $attrs{$k} = $v;
183 }
184 }
185 }
186 10 return \%attrs;
187 }
188  
189 0 ▶sub dxmenu {
Subroutine dxmenu: not called CC=2 SCAR=17.9
Pod documented
190 0 my $c = shift;
191 0 my $attrs = parse_attributs( $c, [qw(id @items onItemClick)], @_ );
192 0 ▶ my $id = delete($attrs->{id}) // new_id( $c, $attrs );
Condition0%0/3
delete $attrs->{"id"} // new_id($c, $attrs)
l!l&&r!l&&!r
000
MC/DC0%0/2
delete $attrs->{"id"} // new_id($c, $attrs)
delete $attrs->{"id"} new_id($c, $attrs)
Truth table0%0/3
A // B
A= delete $attrs->{"id"}B= new_id($c, $attrs)
ABresult
1X1
011
000
193 0 dxbind( $c, 'dxMenu' => $id => $attrs);
194 }
195  
196  
197 0 ▶sub dxloadpanel {
Subroutine dxloadpanel: not called CC=2 SCAR=17.9
Pod documented
198 0 my $c = shift;
199 0 my $attrs = parse_attributs( $c, [qw(id message)], @_ );
200 0 ▶ my $id = delete($attrs->{id}) // new_id( $c, $attrs );
Condition0%0/3
delete $attrs->{"id"} // new_id($c, $attrs)
l!l&&r!l&&!r
000
MC/DC0%0/2
delete $attrs->{"id"} // new_id($c, $attrs)
delete $attrs->{"id"} new_id($c, $attrs)
Truth table0%0/3
A // B
A= delete $attrs->{"id"}B= new_id($c, $attrs)
ABresult
1X1
011
000
201 0 dxbind( $c, 'dxLoadPanel' => $id => $attrs);
202 }
203  
204  
205 3 ▶sub dxbutton {
Subroutine dxbutton: called CC=2 SCAR=7.0
Pod documented
206 3 my $c = shift;
207 3 my $attrs = parse_attributs( $c, [qw(id text onClick type)], @_ );
208 3 ▶ my $id = delete($attrs->{id}) // new_id( $c, $attrs );
Condition66%2/3
delete $attrs->{"id"} // new_id($c, $attrs)
l!l&&r!l&&!r
210
MC/DC0%0/2
delete $attrs->{"id"} // new_id($c, $attrs)
delete $attrs->{"id"} new_id($c, $attrs)
Truth table66%2/3
A // B
A= delete $attrs->{"id"}B= new_id($c, $attrs)
ABresult
1X1
011
000
209 3 dxbind( $c, 'dxButton' => $id => $attrs);
210 }
211  
212  
213 3 ▶sub dxdatagrid{
Subroutine dxdatagrid: called CC=5 SCAR=16.1
Pod documented
214 3 my $c = shift;
215 3 my $attrs = parse_attributs( $c, [qw(id dataSource)], @_ );
216 3 ▶ my $id = delete($attrs->{id}) // new_id( $c, $attrs );
Condition66%2/3
delete $attrs->{"id"} // new_id($c, $attrs)
l!l&&r!l&&!r
210
MC/DC0%0/2
delete $attrs->{"id"} // new_id($c, $attrs)
delete $attrs->{"id"} new_id($c, $attrs)
Truth table66%2/3
A // B
A= delete $attrs->{"id"}B= new_id($c, $attrs)
ABresult
1X1
011
000
217 3 my @extensions;
218 #dxbind( $c, 'dxDataGrid' => $id => $attrs, [ $dataSource ]);
219 3 ▶ if ($attrs->{dataSource} && ref($attrs->{dataSource}) eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($attrs->{"dataSource"} and ref $attrs->{"dataSource"} eq "") 1 2 3
Condition100%3/3
$attrs->{"dataSource"} and ref $attrs->{"dataSource"} eq ""
!ll&&!rl&&r
111
MC/DC100%2/2
$attrs->{"dataSource"} and ref $attrs->{"dataSource"} eq ""
$attrs->{"dataSource"} ref $attrs->{"dataSource"} eq ""
Truth table100%3/3
A and B
A= $attrs->{"dataSource"}B= ref $attrs->{"dataSource"} eq ""
ABresult
0X0
100
111
220 1 my $dataSource = delete $attrs->{dataSource};
221 #push @extensions, '$.getJSON("' . $dataSource . '",function(data){$("#'.$id.'").dxDataGrid({ dataSource: data });});';
222 #$attrs->{dataSource} = \'[]'; #protect string to be "stringified" within dxbind
223  
224 #\"" is to protect string to be "stringified" within dxbind
225 1 $attrs->{dataSource} = \"{store:{type:'odata',url:'$dataSource'}}";
226 }
227 3 ▶ if (exists $attrs->{options}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $attrs->{"options"}) 1 2 3
228 1 $attrs = $attrs->{options};
229 }
230
231 3 dxbind( $c, 'dxDataGrid' => $id => $attrs, \@extensions);
232 }
233  
234  
235 0 ▶sub dxform{
Subroutine dxform: not called CC=2 SCAR=17.9
Pod documented
236 0 my $c = shift;
237 0 my $attrs = parse_attributs( $c, [qw(id %formData @items)], @_ );
238 0 ▶ my $id = delete($attrs->{id}) // new_id( $c, $attrs );
Condition0%0/3
delete $attrs->{"id"} // new_id($c, $attrs)
l!l&&r!l&&!r
000
MC/DC0%0/2
delete $attrs->{"id"} // new_id($c, $attrs)
delete $attrs->{"id"} new_id($c, $attrs)
Truth table0%0/3
A // B
A= delete $attrs->{"id"}B= new_id($c, $attrs)
ABresult
1X1
011
000
239
240 0 dxbind( $c, 'dxForm' => $id => $attrs );
241 }
242  
243  
244 1 ▶sub dxpopup{
Subroutine dxpopup: called CC=2 SCAR=7.4
Pod documented
245 1 my $c = shift;
246 1 my $attrs = parse_attributs( $c, [qw(id title contentTemplate)], @_ );
247 1 ▶ my $id = delete($attrs->{id}) // new_id( $c, $attrs );
Condition33%1/3
delete $attrs->{"id"} // new_id($c, $attrs)
l!l&&r!l&&!r
010
MC/DC0%0/2
delete $attrs->{"id"} // new_id($c, $attrs)
delete $attrs->{"id"} new_id($c, $attrs)
Truth table33%1/3
A // B
A= delete $attrs->{"id"}B= new_id($c, $attrs)
ABresult
1X1
011
000
248
249 1 dxbind( $c, 'dxPopup' => $id => $attrs );
250 }
251  
252  
253  
254 258 ▶sub mk_dxcontrol{
Subroutine mk_dxcontrol: called CC=1 SCAR=0.0
Pod documented
255 258 my $dxControl = shift;
256 3 ▶ my $generic = sub{
Subroutine __ANON__: called CC=4 SCAR=14.1
257 3 my $c = shift;
258 3 my $attrs = parse_attributs( $c, [qw(id value label)], @_ );
259 3 my $id = delete($attrs->{id});
260 3 ▶ if (my $name = $id) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $name = $id) 3 0 3
261 3 $attrs->{name}=$name;
262 }
263
264 3 ▶ $id //= new_id( $c, $attrs );
Condition33%1/3
$id //= new_id($c, $attrs)
l!l&&r!l&&!r
300
MC/DC0%0/2
$id //= new_id($c, $attrs)
$id new_id($c, $attrs)
Truth table33%1/3
A //= B
A= $idB= new_id($c, $attrs)
ABresult
1X1
011
000
265
266 3 my (@before, @after);
267 3 ▶ if(my $label = delete($attrs->{label})){
Branch: 1 branch
BranchTrueFalseTotal
if (my $label = delete $attrs->{"label"}) 3 0 3
268 3 push @before, '<div class="dx-field">';
269 3 push @before, '<div class="dx-field-label">'.$label.'</div>';
270 3 push @before, '<div class="dx-field-value">';
271 3 push @after, '</div>';
272 3 push @after, '</div>';
273 }
274
275 3 dxbind( $c, $dxControl => $id => $attrs, undef, \@before, \@after );
276 258 };
277
278 {
279 7 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
280 258 *{__PACKAGE__.'::'.lc $dxControl} = $generic;
281 }
282 }
283  
284  
285 10 ▶sub dxbuild {
Subroutine dxbuild: called CC=6 SCAR=19.6
Pod documented
286 10 my $c = shift;
287 10 my %opts = @_;
288 10 ▶ my $dxhelper = $c->stash('dxHelper') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $dxhelper = $c->stash("dxHelper") or return 10 0 10
289 10 ▶ if($dxhelper->{bindings}){
Branch: 1 branch
BranchTrueFalseTotal
if ($dxhelper->{"bindings"}) 10 0 10
290 out '<script language="javascript">'.
291 ($opts{js_prefix}//'$(window).on("load",function(){') .
292 "\n".
293 join("\n",
294 30 ▶ grep{ ($_//'') ne ''}
Condition50%2/4
$_ // ""
l!l
300
$opts{"js_sufix"} // "});"
l!l
010
MC/DC0%0/1
$_ // ""
$_
MC/DC0%0/1
$opts{"js_sufix"} // "});"
$opts{"js_sufix"}
Truth table50%1/2
A
A= $_
Aresult
11
00
Truth table50%1/2
A
A= $opts{"js_sufix"}
Aresult
11
00
295 @$dxhelper{'before_bindings','bindings','after_bindings'}
296 ).
297 "\n".
298 10 ▶ ($opts{js_sufix}//'});').'</script>';
Condition50%1/2
$opts{"js_prefix"} // "\$(window).on(\"load\",function(){"
l!l
010
MC/DC0%0/1
$opts{"js_prefix"} // "\$(window).on(\"load\",function(){"
$opts{"js_prefix"}
Truth table50%1/2
A
A= $opts{"js_prefix"}
Aresult
11
00
299 }
300 }
301  
302  
303 3 ▶sub require_asset{
Subroutine require_asset: called CC=3 SCAR=11.1
Pod documented
304 3 my $c = shift;
305 3 ▶ my $dxhelper = $c->stash('dxHelper') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $dxhelper = $c->stash("dxHelper") or return 3 0 3
306
307 3 push @{ $dxhelper->{required_assets} }, $_ for @_;
308
309 3 return $c;
310 }
311  
312  
313 2 ▶sub required_assets{
Subroutine required_assets: called CC=4 SCAR=14.0
Pod documented
314 2 my $c = shift;
315 2 ▶ my $dxhelper = $c->stash('dxHelper') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $dxhelper = $c->stash("dxHelper") or return 2 0 2
316 2 ▶ my $required_assets = $dxhelper->{required_assets} // [];
Condition50%1/2
$dxhelper->{"required_assets"} // []
l!l
20
MC/DC0%0/1
$dxhelper->{"required_assets"} // []
$dxhelper->{"required_assets"}
Truth table50%1/2
A
A= $dxhelper->{"required_assets"}
Aresult
11
00
317 2 my $results = Mojo::ByteStream->new();
318 ASSET:
319 2 for my $asset (@$required_assets){
320 #not sure about how to simulate " %= asset 'resource' " that we can use in template rendering,
321 #nor how to output multiple Mojo::ByteStream objets at a time (is returning required ?)
322 3 $$results .= ${ $c->asset($asset) };
323 }
324 2 return $results;
325 }
326  
327 0 ▶sub prepend_js{
Subroutine prepend_js: not called CC=4 SCAR=30.0
Pod documented
328 0 my ($c, @js) = @_;
329 0 ▶ my $dxhelper = $c->stash('dxHelper') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $dxhelper = $c->stash("dxHelper") or return 0 0 0
330 0 for(@js){
331 0 ▶ $dxhelper->{before_bindings} .= "\n" if $INDENT_BINDING;
Branch: 1 branch
BranchTrueFalseTotal
if $Mojolicious::Plugin::DevexpressHelpers::Helpers::INDENT_BINDING 0 0 0
332 0 $dxhelper->{before_bindings} .= $_;
333 }
334 }
335  
336  
337 0 ▶sub append_js{
Subroutine append_js: not called CC=4 SCAR=30.0
Pod documented
338 0 my ($c, @js) = @_;
339 0 ▶ my $dxhelper = $c->stash('dxHelper') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $dxhelper = $c->stash("dxHelper") or return 0 0 0
340 0 for(@js){
341 0 ▶ $dxhelper->{after_bindings} .= "\n" if $INDENT_BINDING;
Branch: 1 branch
BranchTrueFalseTotal
if $Mojolicious::Plugin::DevexpressHelpers::Helpers::INDENT_BINDING 0 0 0
342 0 $dxhelper->{after_bindings} .= $_;
343 }
344 }
345  
346 6 ▶sub register {
Subroutine register: called CC=7 SCAR=20.7
Pod documented
347 6 my ( $self, $app, $args ) = @_;
348 6 my $tp = $args->{tag_prefix};
349
350 #build generic dx-controls
351 6 mk_dxcontrol( "dx$_" ) for @generic_controls;
352
353 SUB_NO_PREFIX:
354 6 for my $subname ( @without_prefix ){
355 36 my $lc_name = lc $subname;
356 36 my $sub = __PACKAGE__->can( $lc_name );
357 36 ▶ unless($sub){
Branch: 1 branch
BranchTrueFalseTotal
unless ($sub) 0 36 36
358 0 $app->log->debug(__PACKAGE__." helper '$lc_name' does not exists!");
359 0 next SUB_NO_PREFIX;
360 }
361 36 $app->helper( $lc_name => $sub );
362 }
363  
364 SUB_WITH_PREFIX:
365 6 for my $subname ( @with_prefix ){
366 300 my $lc_name = lc $subname;
367 300 my $sub = __PACKAGE__->can( 'dx' . $lc_name );
368 300 ▶ unless($sub){
Branch: 1 branch
BranchTrueFalseTotal
unless ($sub) 0 300 300
369 0 $app->log->debug(__PACKAGE__." helper 'dx$lc_name' does not exists!");
370 0 next SUB_WITH_PREFIX;
371 }
372 300 say STDERR "## adding helper '$tp$lc_name'" if DEBUG;
373 300 $app->helper( $tp . $lc_name => $sub );
374 300 say STDERR "## adding helper '$tp$subname'" if DEBUG and $args->{tag_camelcase};
375 300 ▶ $app->helper( $tp . $subname => $sub ) if $args->{tag_camelcase};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"tag_camelcase"} 300 0 300
376 }
377
378 }
379  
380 7 1;
381  
382 __END__
↑ Summary DevexpressHelpers.pm »