blib/lib/Mojolicious/Command/generate/routes_restsful.pm

filter: Statementstmt 11.9% 20 / 168 Branchbran 0.0% 0 / 86 Conditioncond 0.0% 0 / 56 MC/DCmcdc 0.0% 0 / 34 Subroutinesub 40.0% 4 / 10 Podpod 100% 1 / 1 totaltotal 7.0% 25 / 355 CC 73 SCAR 56.4
CC
73
Cov
6%
_make_site
506.0
_sub_api_site
306.0
_api_site
272.0
CRAP 280.3
↑ Summary
1 package Mojolicious::Command::generate::routes_restsful;
2 1 ▶use Lingua::EN::Inflect 'PL';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Mojo::Base 'Mojolicious::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Mojo::Util qw(class_to_file class_to_path camelize class_to_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 has description =>
8 'Generate Mojolicious App using a Mojolicious::Plugin::Routes::Restful hash';
9 1 has usage =>
10 "Usage: $0 generate Stub App with a Mojolicious::Plugin::Routes::Restful hash\n";
11  
12 1 our $VERSION = '0.0.2';
13 1 our $site = {};
14 1 our $site_api = {};
15 1 our @site_urls = ();
16 1 our %api_urls = ();
17 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 0 ▶sub run {
Subroutine run: not called CC=11 SCAR=48.8
Pod documented
20 0 my ( $self, $class, $in_routes ) = @_;
21  
22 0 ▶ die <<EOF unless $class =~ /^[A-Z](?:\w|::)+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $class =~ /^[A-Z](?:\w|::)+$/u 0 0 0
23 Your application name has to be a well formed (CamelCase) Perl module name
24 like "RoutesRestfulApp".
25 EOF
26  
27 # Script
28  
29 0 for my $sub_ref (qw/ PARENT CONFIG /) {
30 die __PACKAGE__, ": missing '$sub_ref' hash in parameters\n"
31 0 ▶ unless exists( $in_routes->{$sub_ref} );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $in_routes->{$sub_ref} 0 0 0
32 }
33  
34 0 my $config = $in_routes->{CONFIG};
35  
36 0 my $routes = $in_routes->{PARENT};
37 0 my @namespaces = ( $class . "::Controller" );
38  
39 0 foreach my $key ( keys( %{$routes} ) ) {
40  
41 my $resource =
42 0 _make_site( "PARENT", $key, $routes->{$key}, $config, $key, $key );
43  
44 0 my $route = $routes->{$key};
45  
46 0 foreach my $inline_key ( keys( %{ $route->{INLINE} } ) ) {
47  
48 die __PACKAGE__, ": INLINE must be a Hash Ref\n"
49 0 ▶ if ( ref( $route->{INLINE} ) ne 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $route->{"INLINE"} ne "HASH" 0 0 0
50  
51 _make_site( "INLINE", $inline_key, $route->{INLINE}->{$inline_key},
52 0 $config, $key, $resource, $routes->{$key}->{STASH} );
53  
54 }
55  
56 0 foreach my $sub_route_key ( keys( %{ $route->{CHILD} } ) ) {
57  
58 _make_site( "CHILD", $sub_route_key,
59 $route->{CHILD}->{$sub_route_key},
60 0 $config, $key, $resource, $routes->{$key}->{STASH} );
61  
62 }
63 }
64 0 my $name = class_to_file $class;
65 0 $self->render_to_rel_file( 'mojo', "$name/script/$name", $class, $routes );
66 0 $self->chmod_rel_file( "$name/script/$name", 0744 );
67  
68 # # content Controllers
69 0 foreach my $key ( keys( %{$site} ) ) {
70 0 my $controller = camelize($class) . "::Controller::" . camelize($key);
71 0 push( @namespaces, $controller );
72 0 my $path = class_to_path $controller;
73 $self->render_to_rel_file( 'controller', "$name/lib/$path", $controller,
74 0 $site->{$key} );
75  
76 # Templates
77 0 foreach my $action ( keys( %{ $site->{$key} } ) ) {
78 0 my $dir =
79 substr( class_to_path( camelize( lcfirst($key) ) ), 0, -3 );
80  
81 0 $self->render_to_rel_file(
82 'page',
83 "$name/templates/" . $dir . "/" . lcfirst($action) . ".html.ep",
84 $dir,
85 $action
86 );
87 }
88 }
89  
90 # API controllers
91  
92 0 foreach my $key ( keys( %{$site_api} ) ) {
93 0 my $controller = camelize($class) . "::Controller::" . camelize($key);
94 0 push( @namespaces, $controller );
95  
96 0 my $path = class_to_path $controller;
97 $self->render_to_rel_file(
98 'api_controller', "$name/lib/$path",
99 0 $controller, $site_api->{$key}
100 );
101  
102 }
103  
104 0 $in_routes->{CONFIG}->{NAMESPACES} = \@namespaces;
105 0 $Data::Dumper::Indent = 1;
106 0 $Data::Dumper::Terse = 1;
107 0 my $str_routes = Dumper($in_routes);
108  
109 0 my $app = class_to_path $class;
110 0 $self->render_to_rel_file( 'appclass', "$name/lib/$app", $class,
111 $str_routes );
112  
113 0 $self->render_to_rel_file( 'api_test', "$name/t/api_basic.t", $class,
114 \%api_urls );
115  
116 # Static file
117 0 $self->render_to_rel_file( 'static', "$name/public/index.html" );
118  
119 }
120  
121 0 ▶sub _make_site {
Subroutine _make_site: not called CC=22 SCAR=62.3
122  
123 0 my ( $type, $key, $route, $config, $parent, $resource, $parent_stash ) = @_;
124  
125 0 ▶ my $route_stash = $route->{STASH} || {};
Condition0%0/2
$route->{'STASH'} || {}
l!l
00
MC/DC0%0/1
$route->{'STASH'} || {}
$route->{'STASH'}
Truth table0%0/2
A
A= $route->{'STASH'}
Aresult
11
00
126 0 ▶ $route_stash = { %{$route_stash}, %{$parent_stash} }
Branch: 1 branch
BranchTrueFalseTotal
if $parent_stash 0 0 0
127 if ($parent_stash);
128 0 ▶ my $action = $route->{ACTION} || "show";
Condition0%0/2
$route->{'ACTION'} || 'show'
l!l
00
MC/DC0%0/1
$route->{'ACTION'} || 'show'
$route->{'ACTION'}
Truth table0%0/2
A
A= $route->{'ACTION'}
Aresult
11
00
129  
130 0 ▶ my $controller = $route->{CONTROLLER} || $key;
Condition0%0/3
$route->{'CONTROLLER'} || $key
l!l&&r!l&&!r
000
MC/DC0%0/2
$route->{'CONTROLLER'} || $key
$route->{'CONTROLLER'} $key
Truth table0%0/3
A || B
A= $route->{'CONTROLLER'}B= $key
ABresult
1X1
011
000
131  
132 0 ▶ if ( $type eq 'PARENT' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "PARENT") 0 0 0
133  
134 $resource = _api_site( $key, $route->{API}, $config->{API} )
135 0 ▶ if ( exists( $route->{API} ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $route->{"API"} 0 0 0
136  
137 return $resource || $key
138 0 ▶ if ( exists( $route->{API_ONLY} ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $route->{"API_ONLY"} 0 0 0
Condition0%0/3
$resource || $key
l!l&&r!l&&!r
000
MC/DC0%0/2
$resource || $key
$resource $key
Truth table0%0/3
A || B
A= $resourceB= $key
ABresult
1X1
011
000
139  
140 push( @site_urls, "/$key" )
141 0 ▶ unless ( exists( $route->{NO_ROOT} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $route->{"NO_ROOT"} 0 0 0
142  
143 push( @site_urls, "/$key/1" )
144 0 ▶ unless ( exists( $route->{NO_ID} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $route->{"NO_ID"} 0 0 0
145  
146 0 $site->{$controller}->{$action} = 1;
147  
148 0 ▶ return $resource || $key
Condition0%0/3
$resource || $key
l!l&&r!l&&!r
000
MC/DC0%0/2
$resource || $key
$resource $key
Truth table0%0/3
A || B
A= $resourceB= $key
ABresult
1X1
011
000
149  
150 }
151 0 ▶ $controller = $route->{CONTROLLER} || $parent; #aways use parent on kids
Condition0%0/3
$route->{'CONTROLLER'} || $parent
l!l&&r!l&&!r
000
MC/DC0%0/2
$route->{'CONTROLLER'} || $parent
$route->{'CONTROLLER'} $parent
Truth table0%0/3
A || B
A= $route->{'CONTROLLER'}B= $parent
ABresult
1X1
011
000
152 0 $route_stash->{parent} = $resource;
153 0 $route_stash->{child} = $key;
154 0 ▶ if ( $type eq 'INLINE' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'INLINE') { } 0 0 0
elsif ($type eq 'CHILD') { } 0 0 0
155  
156 0 ▶ $action = $route->{ACTION} || $key;
Condition0%0/3
$route->{'ACTION'} || $key
l!l&&r!l&&!r
000
MC/DC0%0/2
$route->{'ACTION'} || $key
$route->{'ACTION'} $key
Truth table0%0/3
A || B
A= $route->{'ACTION'}B= $key
ABresult
1X1
011
000
157  
158 _sub_inline_api_site( $resource, $key, $route->{API}, $config->{API} )
159 0 ▶ if ( exists( $route->{API} ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $route->{"API"} 0 0 0
160  
161 return
162 0 ▶ if ( exists( $route->{API_ONLY} ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $route->{"API_ONLY"} 0 0 0
163  
164 0 ▶ if ( exists( $route->{NO_ID} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $route->{'NO_ID'}) { } 0 0 0
165 0 push( @site_urls, "/$parent/$key" );
166 }
167 else {
168 0 push( @site_urls, "/$parent/1/$key" );
169 }
170 0 $site->{$controller}->{$action} = $parent;
171 }
172 elsif ( $type eq 'CHILD' ) {
173  
174 _sub_api_site( $resource, $key, $route->{API}, $config->{API} )
175 0 ▶ if ( exists( $route->{API} ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $route->{"API"} 0 0 0
176  
177 return
178 0 ▶ if ( exists( $route->{API_ONLY} ) );
Branch: 1 branch
BranchTrueFalseTotal
if exists $route->{"API_ONLY"} 0 0 0
179  
180 0 ▶ $action = $route->{ACTION} || $key;
Condition0%0/3
$route->{'ACTION'} || $key
l!l&&r!l&&!r
000
MC/DC0%0/2
$route->{'ACTION'} || $key
$route->{'ACTION'} $key
Truth table0%0/3
A || B
A= $route->{'ACTION'}B= $key
ABresult
1X1
011
000
181 0 push( @site_urls, "/$parent/1/$key" );
182 0 push( @site_urls, "/$parent/1/$key/1" );
183 0 $site->{$controller}->{$action} = $parent;
184  
185 }
186  
187 }
188  
189 0 ▶sub _api_url {
Subroutine _api_url: not called CC=3 SCAR=24.8
190  
191 0 my ( $resource, $config ) = @_;
192 0 ▶ my $ver = $config->{VERSION} || "";
Condition0%0/2
$config->{'VERSION'} || ''
l!l
00
MC/DC0%0/1
$config->{'VERSION'} || ''
$config->{'VERSION'}
Truth table0%0/2
A
A= $config->{'VERSION'}
Aresult
11
00
193 0 ▶ my $prefix = $config->{RESOURCE_PREFIX} || "";
Condition0%0/2
$config->{'RESOURCE_PREFIX'} || ''
l!l
00
MC/DC0%0/1
$config->{'RESOURCE_PREFIX'} || ''
$config->{'RESOURCE_PREFIX'}
Truth table0%0/2
A
A= $config->{'RESOURCE_PREFIX'}
Aresult
11
00
194 0 my $url = join( "/", grep( $_ ne "", ( $ver, $prefix, $resource ) ) );
195 0 return $url;
196 }
197  
198 0 ▶sub _api_site {
Subroutine _api_site: not called CC=16 SCAR=56.1
199  
200 0 my ( $key, $api, $config ) = @_;
201  
202 0 ▶ my $resource = $api->{RESOURCE} || PL($key);
Condition0%0/3
$api->{'RESOURCE'} || PL($key)
l!l&&r!l&&!r
000
MC/DC0%0/2
$api->{'RESOURCE'} || PL($key)
$api->{'RESOURCE'} PL($key)
Truth table0%0/3
A || B
A= $api->{'RESOURCE'}B= PL($key)
ABresult
1X1
011
000
203 0 my $verbs = $api->{VERBS};
204 0 ▶ my $stash = $api->{STASH} || {};
Condition0%0/2
$api->{'STASH'} || {}
l!l
00
MC/DC0%0/1
$api->{'STASH'} || {}
$api->{'STASH'}
Truth table0%0/2
A
A= $api->{'STASH'}
Aresult
11
00
205 0 ▶ my $contoller = $api->{CONTROLLER} || $resource;
Condition0%0/3
$api->{'CONTROLLER'} || $resource
l!l&&r!l&&!r
000
MC/DC0%0/2
$api->{'CONTROLLER'} || $resource
$api->{'CONTROLLER'} $resource
Truth table0%0/3
A || B
A= $api->{'CONTROLLER'}B= $resource
ABresult
1X1
011
000
206 0 ▶ my $contoller_prefix = $config->{PREFIX} || "api";
Condition0%0/2
$config->{'PREFIX'} || 'api'
l!l
00
MC/DC0%0/1
$config->{'PREFIX'} || 'api'
$config->{'PREFIX'}
Truth table0%0/2
A
A= $config->{'PREFIX'}
Aresult
11
00
207 0 my $url = _api_url( $resource, $config );
208  
209 $site_api->{"$contoller_prefix-$contoller"}->{get} = 1
210 0 ▶ if ( $verbs->{RETRIEVE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"RETRIEVE"} 0 0 0
211  
212 0 push( @{ $api_urls{GET} }, "/" . $url )
213 0 ▶ if ( $verbs->{RETRIEVE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"RETRIEVE"} 0 0 0
214  
215 0 push( @{ $api_urls{GET} }, "/" . $url . "/1" )
216 0 ▶ if ( $verbs->{RETRIEVE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"RETRIEVE"} 0 0 0
217  
218 $site_api->{"$contoller_prefix-$contoller"}->{create} = 1
219 0 ▶ if ( $verbs->{CREATE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"CREATE"} 0 0 0
220  
221 0 push( @{ $api_urls{POST} }, ( "/" . $url ) )
222 0 ▶ if ( $verbs->{CREATE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"CREATE"} 0 0 0
223  
224 $site_api->{"$contoller_prefix-$contoller"}->{update} = 1
225 0 ▶ if ( $verbs->{UPDATE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"UPDATE"} 0 0 0
226  
227 0 push( @{ $api_urls{PATCH} }, ( "/" . $url . "/1" ) )
228 0 ▶ if ( $verbs->{UPDATE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"UPDATE"} 0 0 0
229  
230 $site_api->{"$contoller_prefix-$contoller"}->{replace} = 1
231 0 ▶ if ( $verbs->{REPLACE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"REPLACE"} 0 0 0
232  
233 0 push( @{ $api_urls{PUT} }, ( "/" . $url . "/1" ) )
234 0 ▶ if ( $verbs->{REPLACE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"REPLACE"} 0 0 0
235  
236 $site_api->{"$contoller_prefix-$contoller"}->{delete} = 1
237 0 ▶ if ( $verbs->{DELETE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"DELETE"} 0 0 0
238  
239 0 push( @{ $api_urls{POST} }, ( "/" . $url . "/1" ) )
240 0 ▶ if ( $verbs->{DELETE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"DELETE"} 0 0 0
241  
242 0 return $resource;
243  
244 }
245  
246 0 ▶sub _sub_api_site {
Subroutine _sub_api_site: not called CC=17 SCAR=57.2
247  
248 0 my ( $parent, $key, $api, $config ) = @_;
249  
250 0 ▶ my $child_resource = $api->{RESOURCE} || PL($key);
Condition0%0/3
$api->{'RESOURCE'} || PL($key)
l!l&&r!l&&!r
000
MC/DC0%0/2
$api->{'RESOURCE'} || PL($key)
$api->{'RESOURCE'} PL($key)
Truth table0%0/3
A || B
A= $api->{'RESOURCE'}B= PL($key)
ABresult
1X1
011
000
251 0 my $verbs = $api->{VERBS};
252 0 ▶ my $stash = $api->{STASH} || {};
Condition0%0/2
$api->{'STASH'} || {}
l!l
00
MC/DC0%0/1
$api->{'STASH'} || {}
$api->{'STASH'}
Truth table0%0/2
A
A= $api->{'STASH'}
Aresult
11
00
253 0 ▶ my $child_controller = $api->{CONTROLLER} || $child_resource;
Condition0%0/3
$api->{'CONTROLLER'} || $child_resource
l!l&&r!l&&!r
000
MC/DC0%0/2
$api->{'CONTROLLER'} || $child_resource
$api->{'CONTROLLER'} $child_resource
Truth table0%0/3
A || B
A= $api->{'CONTROLLER'}B= $child_resource
ABresult
1X1
011
000
254 0 ▶ my $contoller_prefix = $config->{PREFIX} || "api";
Condition0%0/2
$config->{'PREFIX'} || 'api'
l!l
00
MC/DC0%0/1
$config->{'PREFIX'} || 'api'
$config->{'PREFIX'}
Truth table0%0/2
A
A= $config->{'PREFIX'}
Aresult
11
00
255 0 my $url = _api_url( $parent, $config );
256 0 $stash->{parent} = $parent;
257 0 $stash->{child} = $child_resource;
258  
259 $site_api->{"$contoller_prefix-$parent"}->{$child_resource} = 1
260 0 ▶ if ( $verbs->{RETRIEVE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"RETRIEVE"} 0 0 0
261  
262 $site_api->{"$contoller_prefix-$child_controller"}->{get} = 1
263 0 ▶ if ( $verbs->{RETRIEVE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"RETRIEVE"} 0 0 0
264  
265 0 push( @{ $api_urls{GET} }, "/" . $url . "/1/" . $child_resource )
266 0 ▶ if ( $verbs->{RETRIEVE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"RETRIEVE"} 0 0 0
267  
268 0 push( @{ $api_urls{GET} }, "/" . $url . "/1/" . $child_resource . "/1" )
269 0 ▶ if ( $verbs->{RETRIEVE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"RETRIEVE"} 0 0 0
270  
271 $site_api->{"$contoller_prefix-$child_controller"}->{create} = 1
272 0 ▶ if ( $verbs->{CREATE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"CREATE"} 0 0 0
273  
274 0 push( @{ $api_urls{POST} }, "/" . $url . "/1/" . $child_resource )
275 0 ▶ if ( $verbs->{CREATE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"CREATE"} 0 0 0
276  
277 $site_api->{"$contoller_prefix-$child_controller"}->{replace} = 1
278 0 ▶ if ( $verbs->{REPLACE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"REPLACE"} 0 0 0
279  
280 0 push( @{ $api_urls{PUT} }, "/" . $url . "/1/" . $child_resource . "/1" )
281 0 ▶ if ( $verbs->{REPLACE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"REPLACE"} 0 0 0
282  
283 $site_api->{"$contoller_prefix-$child_controller"}->{update} = 1
284 0 ▶ if ( $verbs->{UPDATE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"UPDATE"} 0 0 0
285  
286 0 push( @{ $api_urls{PATCH} }, "/" . $url . "/1/" . $child_resource . "/1" )
287 0 ▶ if ( $verbs->{UPDATE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"UPDATE"} 0 0 0
288  
289 $site_api->{"$contoller_prefix-$child_controller"}->{delete} = 1
290 0 ▶ if ( $verbs->{DELETE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"DELETE"} 0 0 0
291  
292 0 push( @{ $api_urls{DELETE} }, "/" . $url . "/1/" . $child_resource . "/1" )
293 0 ▶ if ( $verbs->{DELETE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"DELETE"} 0 0 0
294 }
295  
296 0 ▶sub _sub_inline_api_site {
Subroutine _sub_inline_api_site: not called CC=9 SCAR=45.0
297  
298 0 my ( $parent, $key, $api, $config ) = @_;
299 0 my $verbs = $api->{VERBS};
300 0 ▶ my $child_resource = $api->{RESOURCE} || PL($key); #this should be action
Condition0%0/3
$api->{'RESOURCE'} || PL($key)
l!l&&r!l&&!r
000
MC/DC0%0/2
$api->{'RESOURCE'} || PL($key)
$api->{'RESOURCE'} PL($key)
Truth table0%0/3
A || B
A= $api->{'RESOURCE'}B= PL($key)
ABresult
1X1
011
000
301 0 ▶ my $stash = $api->{STASH} || {};
Condition0%0/2
$api->{'STASH'} || {}
l!l
00
MC/DC0%0/1
$api->{'STASH'} || {}
$api->{'STASH'}
Truth table0%0/2
A
A= $api->{'STASH'}
Aresult
11
00
302 0 ▶ my $action = $api->{ACTION} || $child_resource;
Condition0%0/3
$api->{'ACTION'} || $child_resource
l!l&&r!l&&!r
000
MC/DC0%0/2
$api->{'ACTION'} || $child_resource
$api->{'ACTION'} $child_resource
Truth table0%0/3
A || B
A= $api->{'ACTION'}B= $child_resource
ABresult
1X1
011
000
303 0 ▶ my $contoller_prefix = $config->{PREFIX} || "api";
Condition0%0/2
$config->{'PREFIX'} || 'api'
l!l
00
MC/DC0%0/1
$config->{'PREFIX'} || 'api'
$config->{'PREFIX'}
Truth table0%0/2
A
A= $config->{'PREFIX'}
Aresult
11
00
304 0 my $url = _api_url( $parent, $config );
305 0 $stash->{parent} = $parent;
306 0 $stash->{child} = $child_resource;
307  
308 $site_api->{"$contoller_prefix-$parent"}->{$action} = 1
309 0 ▶ if ( $verbs->{RETRIEVE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"RETRIEVE"} 0 0 0
310  
311 0 push( @{ $api_urls{RETRIEVE} }, "/" . $url . "/1/" . $child_resource )
312 0 ▶ if ( $verbs->{RETRIEVE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"RETRIEVE"} 0 0 0
313  
314 0 push( @{ $api_urls{UPDATE} }, "/" . $url . "/1/" . $child_resource )
315 0 ▶ if ( $verbs->{UPDATE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"UPDATE"} 0 0 0
316  
317 $site_api->{"$contoller_prefix-$parent"}->{$action} = 1
318 0 ▶ if ( $verbs->{UPDATE} );
Branch: 1 branch
BranchTrueFalseTotal
if $verbs->{"UPDATE"} 0 0 0
319  
320 }
321  
322 # Shut up friends.
323 # My internet browser heard us saying the word Fry and it found a movie about Philip J. Fry for us.
324 # It also opened my calendar to Friday and ordered me some french fries.
325 1 1;
326  
327 =pod
328  
329
330 =head1 NAME
331
332 Mojolicious::Command::generate::routes_restsful - Generate an App from a Mojolicious::Plugin::Routes::Restful HASH
333
334 =head1 SYNOPSIS
335
336 my $commands = Mojolicious::Commands->new;
337 my $gen = Mojolicious::Command::generate::routes_restsful->new;
338 $gen->run('RoutesRestfulApp',{
339 CONFIG => { Namespaces => ['RouteRestfulApp::Controller'] },
340 PARENT => {...
341
342 =head1 DESCRIPTION
343
344 Give L<Mojolicious::Command::generate::routes_restsful> a hash that was created for L<Mojolicious::Plugin::Routes::Restful>
345 and it will generate a stub site for you. You get a stub working in version of your app made up of
346  
347 An App Class
348 Content Contollers
349 API Controllers
350 A Startup Script
351 A Template set based on your content controlers
352 A basic test suite for your API
353
354 Please note that this generator overwrites the NAMESPACE attribute of you hash. It is not intended to use this generator from the command line.
355 Best to use it in a script. See the script dir for an example.
356  
357 See L<Mojolicious::Plugin::Routes::Restful> for details on how to make a Hash for this generator.
358
359 =head1 ATTRIBUTES
360
361 L<Mojolicious::Command::generate::app> inherits all attributes from
362 L<Mojolicious::Command> and implements the following new ones.
363
364 =head2 description
365
366 my $description = $app->description;
367 $app = $app->description('Foo');
368
369 Short description of this command, used for the command list.
370
371 =head2 usage
372
373 my $usage = $app->usage;
374 $app = $app->usage('Foo');
375
376 Usage information for this command, used for the help screen.
377
378 =head1 METHODS
379
380 L<Mojolicious::Command::generate::routes_restsful> inherits all methods from
381 L<Mojolicious::Command> and implements the following new ones.
382
383 =head2 run
384
385 $app->run($class,$hash);
386
387 Generates the App. Where $class is the name of the App you want to create, and $hash is a valid L<Mojolicious::Plugin::Routes::Restful> hash.
388  
389
390 =head1 SEE ALSO
391
392 L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>, L<Mojolicious::Plugin::Routes::Restful>.
393
394 =cut
395  
396 __DATA__
↑ Summary