lib/IMDB/Local/Actor.pm

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