lib/IMDB/Local/Director.pm

filter: Statementstmt 46.6% 28 / 60 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 9 / 15 Podpod 0.0% 0 / 6 totaltotal 39.7% 37 / 93 SCAR 31.2
CC
8
Cov
39%
createNew
12.0
getIDs
12.0
init
6.0
CRAP 22.6
« lib/IMDB/Local/Actor.pm ↑ Summary lib/IMDB/Local/Genre.pm »
1 package IMDB::Local::Director;
2  
3 1 ▶use 5.006;
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 =head1 NAME
8  
9 IMDB::Local::Director - Object representation of Director information.
10  
11 =head1 VERSION
12  
13 Version 1.00
14  
15 =cut
16  
17 1 our $VERSION = '1.00';
18  
19  
20 =head1 SYNOPSIS
21  
22 =head1 EXPORT
23  
24 =head1 SUBROUTINES/METHODS
25  
26 =head2 function1
27  
28 =cut
29  
30 1 ▶use IMDB::Local::DB::BaseObject;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use base qw(IMDB::Local::DB::BaseObject);
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 1 ▶use constant DB_TABLE => 'Directors';
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use constant DB_KEY => 'DirectorID';
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 use Class::MethodMaker
37 [
38 1 scalar => [DB_KEY],
39 array => [qw/ -static db_columns/],
40 new => [qw/ -init -hash new/] ,
41 1 ▶ ];
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 sub init($)
44 {
45 0 ▶ my ($self)=@_;
Subroutine init: not called CC=2 SCAR=17.9
Pod undocumented
46  
47 # static array needs to be initialized only if it isn't already
48 #if ( !$self->db_ignoredColumns_count ) {
49 #$self->db_ignoredColumns_push(DB_COLUMNS_IGNORE);
50 #}
51  
52 0 $self->initHandle(DB_TABLE, DB_KEY);
53  
54 0 ▶ if ( $self->populateUsingKey($self->get(DB_KEY)) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->populateUsingKey($self->get("DirectorID"))) 0 0 0
55 0 return $self;
56 }
57 0 return(undef);
58 }
59  
60 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
61  
62 sub createNew($%)
63 {
64 0 ▶ my ($imdbdb, %args)=@_;
Subroutine createNew: not called CC=3 SCAR=24.8
Pod undocumented
65  
66 0 ▶ carp("no name given") if ( !defined($args{name}) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"name"} 0 0 0
67  
68 0 my $id=$imdbdb->insert_db(DB_TABLE, DB_KEY, %args);
69 0 ▶ if ( !defined($id) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $id) 0 0 0
70 0 return(undef);
71 }
72 0 return new IMDB::Local::Director(imdbdb=>$imdbdb, TableID=>$id);
73 }
74  
75 sub FullName($)
76 {
77 0 ▶ my ($self)=@_;
Subroutine FullName: not called CC=2 SCAR=17.9
Pod undocumented
78  
79 0 my $str=$self->Name();
80 0 $str=~s/\s*\([IVXL]+\)$//o;
81  
82 # convert lastname, firstname
83 0 ▶ if ( $str=~m/^(.+),\s*(.+)$/o ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /^(.+),\s*(.+)$/o) 0 0 0
84 0 return("$2 $1");
85 }
86 # fall back to returning whatever we have
87 0 return($str);
88 }
89  
90 sub findByDirectorID($$)
91 {
92 0 ▶ my ($imdbdb, $id)=@_;
Subroutine findByDirectorID: not called CC=1 SCAR=6.9
Pod undocumented
93 0 return new IMDB::Local::Director(imdbdb=>$imdbdb, DB_KEY, $id);
94 }
95  
96 sub findByName($$)
97 {
98 0 ▶ my ($imdbdb, $name)=@_;
Subroutine findByName: not called CC=2 SCAR=17.9
Pod undocumented
99  
100 0 my $id=$imdbdb->select2Scalar("SELECT ".DB_KEY." from ".DB_TABLE." where name='$name'");
101 0 ▶ if ( defined($id) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $id) 0 0 0
102 0 return new IMDB::Local::Director(imdbdb=>$imdbdb, DB_KEY, $id);
103 }
104 0 return(undef);
105 }
106  
107 sub getIDs($$)
108 {
109 0 ▶ my ($class, $imdbdb)=@_;
Subroutine getIDs: not called CC=3 SCAR=24.8
Pod undocumented
110 0 my @ids;
111  
112 0 my $res=$imdbdb->dbh->selectall_arrayref("SELECT ".DB_KEY." FROM ".DB_TABLE." ORDER BY ".DB_KEY."");
113 0 ▶ if ( !defined($res) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $res) 0 0 0
114 0 return(@ids);
115 }
116  
117 0 for my $list (@$res) {
118 0 push(@ids, $list->[0]);
119 }
120 0 return(@ids);
121 }
122  
123 =head1 AUTHOR
124  
125 jerryv, C<< <jerry.veldhuis at gmail.com> >>
126  
127 =head1 BUGS
128  
129 Please report any bugs or feature requests to C<bug-imdb-local at rt.cpan.org>, or through
130 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IMDB-Local>. I will be notified, and then you'll
131 automatically be notified of progress on your bug as I make changes.
132  
133  
134 =head1 SUPPORT
135  
136 You can find documentation for this module with the perldoc command.
137  
138 perldoc IMDB::Local::Director
139  
140  
141 You can also look for information at:
142  
143 =over 4
144  
145 =item * RT: CPAN's request tracker (report bugs here)
146  
147 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=IMDB-Local>
148  
149 =item * AnnoCPAN: Annotated CPAN documentation
150  
151 L<http://annocpan.org/dist/IMDB-Local>
152  
153 =item * CPAN Ratings
154  
155 L<http://cpanratings.perl.org/d/IMDB-Local>
156  
157 =item * Search CPAN
158  
159 L<http://search.cpan.org/dist/IMDB-Local/>
160  
161 =back
162  
163  
164 =head1 ACKNOWLEDGEMENTS
165  
166  
167 =head1 LICENSE AND COPYRIGHT
168  
169 Copyright 2015 jerryv.
170  
171 This program is free software; you can redistribute it and/or modify it
172 under the terms of the the Artistic License (2.0). You may obtain a
173 copy of the full license at:
174  
175 L<http://www.perlfoundation.org/artistic_license_2_0>
176  
177 Any use, modification, and distribution of the Standard or Modified
178 Versions is governed by this Artistic License. By using, modifying or
179 distributing the Package, you accept this license. Do not use, modify,
180 or distribute the Package, if you do not accept this license.
181  
182 If your Modified Version has been derived from a Modified Version made
183 by someone other than you, you are nevertheless required to ensure that
184 your Modified Version complies with the requirements of this license.
185  
186 This license does not grant you the right to use any trademark, service
187 mark, tradename, or logo of the Copyright Holder.
188  
189 This license includes the non-exclusive, worldwide, free-of-charge
190 patent license to make, have made, use, offer to sell, sell, import and
191 otherwise transfer the Package with respect to any patent claims
192 licensable by the Copyright Holder that are necessarily infringed by the
193 Package. If you institute patent litigation (including a cross-claim or
194 counterclaim) against any party alleging that the Package constitutes
195 direct or contributory patent infringement, then this Artistic License
196 to you shall terminate on the date that such litigation is filed.
197  
198 Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
199 AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
200 THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
201 PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
202 YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
203 CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
204 CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
205 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
206  
207  
208 =cut
209  
210 1 1; # End of IMDB::Local::Director
« lib/IMDB/Local/Actor.pm ↑ Summary lib/IMDB/Local/Genre.pm »