lib/MojoMojo/Controller/JSON.pm

filter: Statementstmt 50.0% 19 / 38 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 60.0% 6 / 10 Podpod 100% 3 / 3 totaltotal 45.1% 28 / 62 CC 5 SCAR 19.9
CC
5
Cov
40%
tagsearch
20.0
container_maximize_width
6.0
container_set_default_width
2.0
CRAP 7.3
« lib/MojoMojo/Schema/ResultSet/Page.pm ↑ Summary lib/MojoMojo/Schema/Result/Photo.pm »
1 package MojoMojo::Controller::JSON;
2  
3 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 35 ▶use parent 'Catalyst::Controller';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 MojoMojo::Controller::JSON - Various functions that return JSON data.
9  
10 =head1 SYNOPSIS
11  
12 This is the Mojo for various functions that return JSON data.
13  
14 =head1 DESCRIPTION
15  
16 This controller dispatches various JSON data to AJAX methods in MojoMojo.
17 These methods will be called indirectly through JavaScript functions.
18  
19 =head1 ACTIONS
20  
21 =head2 tagsearch (json/tagsearch)
22  
23 Backend which handles jQuery autocomplete requests for tag.
24  
25 =cut
26  
27 0 ▶sub tagsearch : Local {
Subroutine tagsearch: not called CC=4 SCAR=30.0
28 0 my ($self, $c) = @_;
29 0 my $query = $c->req->param('q');
30  
31 0 ▶ if (defined($query) && length($query)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $query and length $query) 0 0 0
Condition0%0/3
defined $query and length $query
!ll&&!rl&&r
000
MC/DC0%0/2
defined $query and length $query
defined $query length $query
Truth table0%0/3
A and B
A= defined $queryB= length $query
ABresult
0X0
100
111
32 0 my $rs = $c->model('DBIC::Tag')->search({
33 tag => { -like => $query.'%' },
34 }, {
35 select => [ 'tag' ],
36 as => [ 'tag' ],
37 group_by => [ 'tag' ],
38 });
39  
40 0 my @tags;
41 0 ▶ while( my $each_rs = $rs->next )
Branch: 1 branch
BranchTrueFalseTotal
if (my $each_rs = $rs->next) 0 0 0
42 {
43 0 push(@tags, $each_rs->tag);
44 }
45 0 $c->stash->{json}->{tags} = \@tags;
46 }
47 35 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 =head2 container_set_default_width (json/container_set_default_width)
50  
51 Store width in session variable I<container_default_width>.
52  
53 =cut
54  
55 0 ▶sub container_set_default_width : Local {
Subroutine container_set_default_width: not called CC=1 SCAR=6.9
Pod documented
56 0 my ($self, $c, $width) = @_;
57 0 $c->session->{container_default_width} = $width;
58 0 $c->stash->{json}->{width} = $width;
59 35 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61  
62 =head2 container_maximize_width (json/container_maximize_width)
63  
64 Set or unset session variable I<maximize_width>, which is used to toggle maximum
65 width when displaying the page.
66  
67 =cut
68  
69 0 ▶sub container_maximize_width : Local {
Subroutine container_maximize_width: not called CC=2 SCAR=17.9
Pod documented
70 0 my ($self, $c, $width) = @_;
71 0 ▶ if ($width){
Branch: 1 branch
BranchTrueFalseTotal
if ($width) { } 0 0 0
72 0 $c->session->{maximize_width}=1;
73 } else {
74 0 delete ($c->session->{maximize_width});
75 }
76 0 $c->stash->{json}->{width}=$c->session->{container_set_default_width};
77 35 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
78  
79  
80 =head2 auto
81  
82 Set default view
83  
84 =cut
85  
86 0 ▶sub auto : Private {
Subroutine auto: not called CC=1 SCAR=6.9
Pod documented
87 0 my ($self, $c) = @_;
88  
89 0 $c->stash->{current_view} = 'JSON';
90 0 return 1;
91 35 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
92  
93 35 1;
94  
95 =head1 AUTHOR
96  
97 Sachin Sebastian <sachinjsk at cpan.org>
98  
99 Robert Litwiniec <linio at wonder.pl>
100  
101 =head1 LICENSE
102  
103 This library is free software. You can redistribute it and/or modify it under
104 the same terms as Perl itself.
105  
106 =cut
« lib/MojoMojo/Schema/ResultSet/Page.pm ↑ Summary lib/MojoMojo/Schema/Result/Photo.pm »