Design/Controller/GetTable.pm untested

filter: Statementstmt 0.0% 0 / 50 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 75 CC 3 SCAR 12.4
CC
3
Cov
0%
design_feature
6.0
design_flower
6.0
attribute_types
2.0
CRAP 3.5
1 package WWW::Garden::Design::Controller::GetTable;
2  
3 use Mojo::Base 'Mojolicious::Controller';
4  
5 use Date::Simple;
6  
7 use Moo;
8  
9 our $VERSION = '0.97';
10  
11 # -----------------------------------------------
12  
13 sub attribute_types
14 {
15 my($self) = @_;
16  
17 $self -> app -> log -> debug('GetTable.attribute_types()');
18  
19 my($defaults) = $self -> app -> defaults;
20  
21 $self -> render(json => $$defaults{db} -> read_table('attribute_types') );
22  
23 } # End of attribute_types.
24  
25 # -----------------------------------------------
26  
27 sub design_feature
28 {
29 my($self) = @_;
30 my($design_feature) = $self -> param('design_feature') || '';
31  
32 $self -> app -> log -> debug('GetTable.design_feature()');
33  
34 if (length($design_feature) < 2)
35 {
36 $self -> stash(feature_name => '');
37 $self -> render();
38 }
39 else
40 {
41 my($defaults) = $self -> app -> defaults;
42  
43 $self -> stash(feature_name => $$defaults{db} -> get_feature_by_name($design_feature) );
44 $self -> render;
45 }
46  
47 } # End of design_feature.
48  
49 # -----------------------------------------------
50  
51 sub design_flower
52 {
53 my($self) = @_;
54 my($design_flower) = $self -> param('design_flower') || '';
55  
56 $self -> app -> log -> debug('GetTable.design_flower()');
57  
58 if (length($design_flower) < 2)
59 {
60 $self -> stash(thumbnail_name => '');
61 $self -> render();
62 }
63 else
64 {
65 my($defaults) = $self -> app -> defaults;
66  
67 $self -> stash(thumbnail_name => $$defaults{db} -> get_flower_by_both_names($design_flower) );
68 $self -> render;
69 }
70  
71 } # End of design_flower.
72  
73 # -----------------------------------------------
74  
75 sub features
76 {
77 my($self) = @_;
78  
79 $self -> app -> log -> debug('GetTable.features()');
80  
81 my($defaults) = $self -> app -> defaults;
82 my($features_table) = $$defaults{db} -> read_features_table;
83  
84 $self -> app -> log -> debug('GetTable.features(). Size of features_table: ' . scalar @$features_table);
85 $self -> render(json => $features_table);
86  
87 } # End of features.
88  
89 # -----------------------------------------------
90  
91 sub gardens
92 {
93 my($self) = @_;
94  
95 $self -> app -> log -> debug('GetTable.gardens()');
96  
97 my($defaults) = $self -> app -> defaults;
98 my($gardens_table) = $$defaults{db} -> read_gardens_table;
99  
100 $self -> app -> log -> debug('GetTable.gardens(). Size of gardens_table: ' . scalar @$gardens_table);
101 $self -> render(json => $gardens_table);
102  
103 } # End of gardens.
104  
105 # -----------------------------------------------
106  
107 sub properties
108 {
109 my($self) = @_;
110  
111 $self -> app -> log -> debug('GetTable.properties()');
112  
113 my($defaults) = $self -> app -> defaults;
114 my($properties_table) = $$defaults{db} -> read_properties_table;
115  
116 $self -> app -> log -> debug('GetTable.properties(). Size of properties_table: ' . scalar @$properties_table);
117 $self -> render(json => $properties_table);
118  
119 } # End of properties.
120  
121 # -----------------------------------------------
122  
123 1;
124  
125 =pod
126  
127 =head1 NAME
128  
129 WWW::Garden::Design::Controller::GetTable - Manage the 'flowers' database
130  
131 =head1 Machine-Readable Change Log
132  
133 The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>.
134  
135 =head1 Version Numbers
136  
137 Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.
138  
139 =head1 Repository
140  
141 L<https://github.com/ronsavage/WWW-Garden-Design>
142  
143 =head1 Support
144  
145 Email the author, or log a bug on RT:
146  
147 L<https://rt.cpan.org/Public/Dist/Display.html?Name=WWW::Garden::Design>.
148  
149 =head1 Author
150  
151 L<WWW::Garden::Design> was written by Ron Savage I<E<lt>ron@savage.net.auE<gt>> in 2014.
152  
153 My homepage: L<https://savage.net.au/>.
154  
155 =head1 Copyright
156  
157 Australian copyright (c) 2018, Ron Savage.
158  
159 All Programs of mine are 'OSI Certified Open Source Software';
160 you can redistribute them and/or modify them under the terms of
161 The Perl License, a copy of which is available at:
162 http://dev.perl.org/licenses/
163  
164 =cut