Comskil/JWand.pm

filter: Statementstmt 14.8% 49 / 329 Branchbran 0.0% 0 / 116 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 40.0% 14 / 35 Podpod 100% 18 / 18 totaltotal 15.2% 81 / 531 CC 81 SCAR 52.3
CC
81
Cov
11%
grabAttachments
702.0
__new
90.0
grabPriorities
56.0
CRAP 186.6
↑ Summary Comskil.pm »
1 # File: Comskil/JWand.pm
2 # Desc: A package that performs magic with remote JIRA services.
3
4 # #TODO Add in the sophisticated BEGIN/END package initialization blocks
5 # #TODO Add in the ability to log to a file.
6 # #TODO Run Perl Critic and Source code cleaner.
7
8
9 package Comskil::JWand;
10
11 =head1 NAME
12
13 Comskil::JWand - The great new Comskil::JWand!
14
15 =head1 VERSION
16
17 Version 0.1
18
19 =cut
20
21 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
24
25 1 our $VERSION = "0.1";
26 1 our $COPYRIGHT = "Copyright (c) 2011 Comskil, Inc. All Rights Reserved Worldwide";
27 1 our $PRODUCT = "Comskil::JWand";
28 1 our $USER_AGENT = "$PRODUCT\\$VERSION ($COPYRIGHT)";
29
30 =head1 SYNOPSIS
31
32 Quick summary of what the module does.
33
34 Perhaps a little code snippet.
35
36 use Comskil::JWand;
37
38 my $foo = Comskil::JWand->new();
39 ...
40 =cut
41
42 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶ use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
45 1 $VERSION = $Comskil::VERSION;
46 1 @ISA = qw(Exporter);
47 1 @EXPORT = qw(
48 buildProjectImportFile
49 );
50 1 @EXPORT_OK = qw(
51 getDebug
52 getVerbose
53 setDebug
54 setVerbose
55 grabPriorities
56 grabProjectRoles
57 grabResolutions
58 grabStatuses
59 grabAttachments
60 grabComponents
61 grabProjectInfo
62 grabServerInfo
63 grabVersions
64 );
65 1 %EXPORT_TAGS = (
66 ALL => [ qw(
67 buildProjectImportFile
68 getDebug
69 getVerbose
70 setDebug
71 setVerbose
72 grabAttachments
73 grabComponents
74 grabPriorities
75 grabProjectInfo
76 grabProjectRoles
77 grabServerInfo
78 grabStatuses
79 grabResolutions
80 grabVersions
81 ) ]
82 );
83 }
84
85 1 ▶END { }
Subroutine END: called CC=1 SCAR=0.0
86
87 =head1 EXPORT
88 A list of functions that can be exported. You can delete this section
89 if you don't export anything, such as for a purely object-oriented module.
90 =over 8
91 =item * new()
92 =item * grabVersions()
93 =item * grabStatuses()
94 =head1 SUBROUTINES/METHODS
95 =cut
96
97 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
98
99 1 ▶use Data::Dumper; my $dd;
Subroutine BEGIN: called CC=1 SCAR=0.0
100
101 1 ▶use File::Path qw(make_path remove_tree);
Subroutine BEGIN: called CC=1 SCAR=0.0
102 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 1 ▶use HTTP::Headers;
Subroutine BEGIN: called CC=1 SCAR=0.0
104 1 ▶use HTTP::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
105 1 ▶use HTTP::Status qw(:constants :is status_message);
Subroutine BEGIN: called CC=1 SCAR=0.0
106 1 ▶use JIRA::Client;
Subroutine BEGIN: called CC=1 SCAR=0.0
107
108
109 0 ▶sub _connect {
Subroutine _connect: not called CC=1 SCAR=6.9
110 0 my ($self,@args) = @_;
111
112 return($self->{client_handle})
113 0 }
114
115 0 ▶sub _grab_list {
Subroutine _grab_list: not called CC=1 SCAR=6.9
116 0 my ($self,@args) = @_;
117 0 my $ulist = [ ];
118 0 return(\$ulist);
119 }
120
121
122
123 =head2 new()
124 =over 8
125 =item :username
126 =item :password
127 =item :baseurl
128 =item :
129 =back
130 =cut
131
132 # Func: new(class_name [, options-hash] )
133 # Desc:
134 #
135 # Args: A hash containing key => value pairs to initialize the class. The
136 # valid option keys are:
137 0 ▶sub __new {
Subroutine __new: not called CC=9 SCAR=45.0
138 0 my ($class,@args) = @_;
139 0 my $self = {
140 client_handle => undef ## #FIX Get rid of the leading colon on options
141 ,':user_agent' => undef
142 ,':max_results' => 13
143 ,':max_issues' => undef
144 ,':max_attachments' => undef
145 ,':max_filesize' => undef
146 ,':grab_thumbs' => 1
147 ,'_server_info' => undef
148 ,'_user_agent' => undef
149 };
150 0 foreach my $href (@args) {
151 0 @$self{ keys %{$href} } = values %{$href};
152 }
153 0 bless($self,$class);
154
155 0 ▶ if ( (! $self->{client_handle}) && (! $self->{fileset}) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"client_handle"} or $self->{"fileset"}) 0 0 0
Condition0%0/3
$self->{"client_handle"} or $self->{"fileset"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"client_handle"} or $self->{"fileset"}
$self->{"client_handle"} $self->{"fileset"}
Truth table0%0/3
A or B
A= $self->{"client_handle"}B= $self->{"fileset"}
ABresult
1X1
011
000
156 $self->{client_handle} = JIRA::Client->new(
157 $self->{url}
158 ,$self->{username}
159 ,$self->{password}
160 0 );
161 0 $self->{'_server_info'} = eval { $self->{client_handle}->getServerInfo() };
162 0 ▶ croak sprintf("getServerInfo(): %s",$@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
163
164 0 ▶ if ($self->{debug} >= 1) { $dd = Data::Dumper->new([$self->{_server_info}]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 1) 0 0 0
165 0 ▶ if ($self->{verbose}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"verbose"}) 0 0 0
166 0 print("connected to: ".$self->{_server_info}->{baseUrl}." as '".$self->{username}."'\n");
167 print("server version: ".$self->{_server_info}->{version}.
168 0 " build: ".$self->{_server_info}->{buildNumber}."\n");
169 }
170 }
171
172 0 ▶ if ($self->{debug} >= 3) { $dd = Data::Dumper->new([$self]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 3) 0 0 0
173 0 ▶ return( $self->{client_handle} ? $self : undef);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'client_handle'} ? : 0 0 0
174 }
175
176
177 =head2 appendToChain()
178 =cut
179
180 0 ▶sub appendToChain {
Subroutine appendToChain: not called CC=6 SCAR=37.4
Pod documented
181 0 my ($self,$wand) = @_;
182 0 ▶ croak "appendToChain(undef) failed, undef not a JWand\n" if (! $wand);
Branch: 1 branch
BranchTrueFalseTotal
unless $wand 0 0 0
183 0 ▶ if ($self->{_next_wand}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_next_wand'}) { } 0 0 0
184 0 ▶ print($self->{bname}," -> ") if ($self->{verbose});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"verbose"} 0 0 0
185 0 $self->{_next_wand}->appendToChain($wand);
186 } else {
187 0 ▶ print($self->{bname}," => ",$wand->{bname},"\n") if ($self->{verbose});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"verbose"} 0 0 0
188 0 $self->{_next_wand} = $wand;
189 }
190
191 0 ▶ if ($self->{debug} >= 3) { $dd = Data::Dumper->new([$self]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 3) 0 0 0
192 0 return($self);
193 }
194
195 =head2 jira_handle()
196 =cut
197
198 0 ▶sub jira_handle {
Subroutine jira_handle: not called CC=1 SCAR=6.9
Pod documented
199 0 my $self = shift;
200 0 return($self->{client_handle});
201 }
202
203 =head2 grabProjectKeys()
204 =cut
205
206 0 ▶sub grabProjectKeys {
Subroutine grabProjectKeys: not called CC=1 SCAR=6.9
Pod documented
207 0 my($self,$regx) = @_;
208 }
209
210 =head2 grabPriorities()
211 =cut
212
213 0 ▶sub grabPriorities {
Subroutine grabPriorities: not called CC=7 SCAR=40.3
Pod documented
214 0 my ($self,@args) = @_;
215 0 my ($rslt,$ulist);
216
217 0 $ulist = eval { $self->{client_handle}->getPriorities() };
218 0 ▶ croak sprintf("getPriorities(): %s",$@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
219 0 foreach my $key (@{$ulist}) { $key->{bname} = $self->{bname}; }
220 0 ▶ if ($self->{debug} >= 1) { $dd = Data::Dumper->new([$ulist]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 1) 0 0 0
221
222 0 ▶ if ($self->{_next_wand}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_next_wand"}) 0 0 0
223 0 $rslt = $self->{_next_wand}->grabPriorities(@args);
224 0 ▶ if ($self->{debug} >= 2) { $dd = Data::Dumper->new([$rslt]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 2) 0 0 0
225 0 $ulist = [ @{$ulist}, @{$rslt} ];
226 }
227
228 0 ▶ if ($self->{debug} >= 3) { $dd = Data::Dumper->new([$ulist]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 3) 0 0 0
229 0 return($ulist);
230 }
231
232 =head2 grabStatuses()
233 =cut
234
235 0 ▶sub grabStatuses {
Subroutine grabStatuses: not called CC=7 SCAR=40.3
Pod documented
236 0 my ($self,@args) = @_;
237 0 my ($rslt,$ulist);
238
239 0 $ulist = eval { $self->{client_handle}->getStatuses() };
240 0 ▶ croak sprintf("getStatuses(): %s",$@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
241 0 foreach my $key (@{$ulist}) { $key->{bname} = $self->{bname}; }
242 0 ▶ if ($self->{debug} >= 1) { $dd = Data::Dumper->new([$ulist]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 1) 0 0 0
243
244 0 ▶ if ($self->{_next_wand}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_next_wand"}) 0 0 0
245 0 $rslt = $self->{_next_wand}->grabStatuses(@args);
246 0 ▶ if ($self->{debug} >= 2) { $dd = Data::Dumper->new([$rslt]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 2) 0 0 0
247 0 $ulist = [ @{$ulist}, @{$rslt} ];
248 }
249
250 0 ▶ if ($self->{debug} >= 3) { $dd = Data::Dumper->new([$ulist]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 3) 0 0 0
251 0 return($ulist);
252 }
253
254 =head2 grabResolutions()
255 =cut
256
257 0 ▶sub grabResolutions {
Subroutine grabResolutions: not called CC=7 SCAR=40.3
Pod documented
258 0 my ($self,@args) = @_;
259 0 my ($rslt,$ulist);
260
261 0 $ulist = eval { $self->{client_handle}->getResolutions() };
262 0 ▶ croak sprintf("getResolutions(): %s",$@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
263 0 foreach my $key (@{$ulist}) { $key->{bname} = $self->{bname}; }
264 0 ▶ if ($self->{debug} >= 1) { $dd = Data::Dumper->new([$ulist]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 1) 0 0 0
265
266 0 ▶ if ($self->{_next_wand}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_next_wand"}) 0 0 0
267 0 $rslt = $self->{_next_wand}->grabResolutions(@args);
268 0 ▶ if ($self->{debug} >= 2) { $dd = Data::Dumper->new([$rslt]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 2) 0 0 0
269 0 $ulist = [ @{$ulist}, @{$rslt} ];
270 }
271
272 0 ▶ if ($self->{debug} >= 3) { $dd = Data::Dumper->new([$ulist]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 3) 0 0 0
273 0 return($ulist);
274 }
275
276 =head2 grabProjectRoles()
277 =cut
278
279 0 ▶sub grabProjectRoles {
Subroutine grabProjectRoles: not called CC=7 SCAR=40.3
Pod documented
280 0 my ($self,@args) = @_;
281 0 my ($rslt,$ulist);
282
283 0 $ulist = eval { $self->{client_handle}->getProjectRoles() };
284 0 ▶ croak sprintf("getProjectRoles(): %s",$@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
285 0 foreach my $key (@{$ulist}) { $key->{bname} = $self->{bname}; }
286 0 ▶ if ($self->{debug} >= 1) { $dd = Data::Dumper->new([$ulist]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 1) 0 0 0
287
288 0 ▶ if ($self->{_next_wand}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_next_wand"}) 0 0 0
289 0 $rslt = $self->{_next_wand}->grabProjectRoles(@args);
290 0 ▶ if ($self->{debug} >= 2) { $dd = Data::Dumper->new([$rslt]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 2) 0 0 0
291 0 $ulist = [ @{$ulist}, @{$rslt} ];
292 }
293
294 0 ▶ if ($self->{debug} >= 3) { $dd = Data::Dumper->new([$ulist]); print $dd->Dump(); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"} >= 3) 0 0 0
295 0 return($ulist);
296 }
297
298 =head2 grabComponents()
299 =cut
300 0 ▶sub grabComponents {
Subroutine grabComponents: not called CC=4 SCAR=30.0
Pod documented
301 0 my ($self,@args) = @_;
302 0 my $ulist = [ ];
303
304 0 foreach my $pkey (@args) {
305 0 my $temp = eval { $self->{client_handle}->getComponents($pkey) };
306 0 ▶ croak sprintf("getComponents(%s): %s",$pkey,$@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
307 0 ▶ $ulist = [ @{$ulist}, @{$temp} ] if ($temp);
Branch: 1 branch
BranchTrueFalseTotal
if $temp 0 0 0
308 }
309
310 0 $dd = Data::Dumper->new([$ulist]); print $dd->Dump();
311 0 return(\$ulist);
312 }
313
314 =head2 grabVersions()
315 =cut
316
317 0 ▶sub grabVersions {
Subroutine grabVersions: not called CC=4 SCAR=30.0
Pod documented
318 0 my ($self,@args) = @_;
319 0 my $ulist = [ ];
320
321 0 foreach my $pkey (@args) {
322 0 my $temp = eval { $self->{client_handle}->getVersions($pkey) };
323 0 ▶ croak sprintf("getVersions(%s): %s",$pkey,$@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
324 0 ▶ $ulist = [ @{$ulist}, @{$temp} ] if ($temp);
Branch: 1 branch
BranchTrueFalseTotal
if $temp 0 0 0
325 }
326
327 0 $dd = Data::Dumper->new([$ulist]); print $dd->Dump();
328 0 return(\$ulist);
329 }
330
331 =head2 grabProjectInfo()
332 =cut
333
334 0 ▶sub grabProjectInfo {
Subroutine grabProjectInfo: not called CC=4 SCAR=30.0
Pod documented
335 0 my ($self,@args) = @_;
336 0 my $ulist = [ ];
337
338 0 foreach my $pkey (@args) {
339 0 my $temp = eval { $self->{client_handle}->getProjectByKey($pkey) };
340 0 ▶ croak sprintf("getProjectByKey(%s): %s",$pkey,$@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
341 0 ▶ $ulist = [ @{$ulist}, [ $temp ] ] if ($temp);
Branch: 1 branch
BranchTrueFalseTotal
if $temp 0 0 0
342 }
343
344 0 $dd = Data::Dumper->new([$ulist]); print $dd->Dump();
345 0 return(\$ulist);
346 }
347
348 =head3 grabProjectRoleActors()
349 =cut
350
351 0 ▶sub grabProjectRoleActors {
Subroutine grabProjectRoleActors: not called CC=5 SCAR=34.0
Pod documented
352 0 my ($self,$refpl,$refrl) = @_;
353 0 my $ulist = [ ];
354
355 0 $dd = Data::Dumper->new([$refpl]); print $dd->Dump();
356 0 $dd = Data::Dumper->new([$refrl]); print $dd->Dump();
357
358 0 foreach my $pkey (@{$refpl}) {
359 0 $dd = Data::Dumper->new([$pkey]); print $dd->Dump();
360 0 foreach my $rkey ($refrl) {
361 0 $dd = Data::Dumper->new([$rkey]); print $dd->Dump();
362 0 my $temp = eval { $self->{client_handle}->getProjectRoleActors($rkey->[0],$pkey) };
363 0 $dd = Data::Dumper->new([$temp]); print $dd->Dump();
364 0 ▶ croak sprintf("getProjectRoleActors(%s,%s): %s",$rkey,$pkey,$@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
365 0 ▶ $ulist = [ @{$ulist}, [ $temp ] ] if ($temp);
Branch: 1 branch
BranchTrueFalseTotal
if $temp 0 0 0
366 }
367 }
368
369 0 $dd = Data::Dumper->new([$ulist]); print $dd->Dump();
370 0 return(\$ulist);
371 }
372
373 =over 4
374
375 =item B<grabAttachments> OUTPATH [, (<project-key>[,...])]]
376 asdfasdf
377
378 =back
379
380 =cut
381
382 0 ▶sub grabAttachments {
Subroutine grabAttachments: not called CC=26 SCAR=65.5
Pod documented
383 0 my ($self,$path,@args) = @_;
384 0 my ($cnt,$ua) = (undef,undef);
385
386 ## Verify we are connected to a remote JIRA instance.
387
388 0 ▶ return(undef) if (! $self->{client_handle});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"client_handle"} 0 0 0
389
390 ## If no project keys are specified find them all.
391
392 ## Make sure we have a UserAgent to access the remote JIRA instance to grab files.
393
394 0 ▶ if (! $self->{'_user_agent'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_user_agent"}) 0 0 0
395 0 ▶ $self->{':user_agent'} = $USER_AGENT if (! $self->{':user_agent'});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{":user_agent"} 0 0 0
396 0 my $rh = HTTP::Headers->new();
397 0 $rh->authorization_basic($self->{':username'},$self->{':password'});
398 0 $ua = $self->{'_user_agent'} = LWP::UserAgent->new(
399 agent => $USER_AGENT
400 ,default_headers => $rh
401 );
402 ## $dd = Data::Dumper->new([$ua]); print $dd->Dump();
403 }
404
405 ## Loop through the project keys grabbing all of the files on each iteration.
406
407 0 my $cnt_attach = 0;
408 0 my $cnt_issues = 0;
409
410 0 foreach my $pkey (@args) {
411
412 0 my $ikey = "";
413 0 ▶ if ($pkey =~ m/(([A-Z]+)\-\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkey =~ /(([A-Z]+)\-\d+)/) 0 0 0
414 0 $pkey = $2;
415 0 $ikey = $1;
416 }
417
418 0 print "$pkey\n";
419
420 0 my $x = eval { $self->{client_handle}->getProjectByKey($pkey) };
421 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
422 0 carp sprintf("getProjectByKey('%s'): %s",$pkey,$@);
423 0 last;
424 }
425
426 #### Iterate through each issue in the project.
427
428 0 while (1) {
429 0 ▶ my $jql = "project = $pkey " . (($ikey ne "") ? "and issueKey > $ikey " : "") . "order by issueKey asc";
Branch: 1 branch
BranchTrueFalseTotal
$ikey ne '' ? : 0 0 0
430
431 #print "more issues....\n";
432
433 0 my $ilist = eval {
434 0 $self->{client_handle}->getIssuesFromJqlSearch($jql,$self->{':max_results'})
435 };
436 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
437 0 carp sprintf("getIssuesFromJqlSearch('%s',%n): %s",$jql,$self->{':max_results'},$@);
438 0 last;
439 }
440 0 ▶ last if (! @{$ilist});
Branch: 1 branch
BranchTrueFalseTotal
unless @{$ilist;} 0 0 0
441
442 0 foreach my $issue (@$ilist) {
443 0 $cnt_issues++;
444 0 $ikey = $issue->{'key'};
445 0 print "$ikey\n";
446 0 ▶ if (@{$issue->{'attachmentNames'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$issue->{"attachmentNames"};}) 0 0 0
447 0 my $attach_list = eval { $self->{client_handle}->getAttachmentsFromIssue($ikey) };
448 0 ▶ croak sprintf("getAttachmentsFromIssue('%s'): %s",$ikey,$@) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
449
450 ## $dd = Data::Dumper->new([$attach_list]); print $dd->Dump();
451
452 0 my $fpth = "$path/$pkey/$ikey";
453 0 my $thmb = 0;
454 #print "$fpth\n";
455 0 foreach my $attach (@$attach_list) {
456
457 # Attachment Filespec := <jira-attachments>/<project-key>/<issue-key>/<attachment-id>
458 # URL := <base-url>/secure/attachment/<attachment-id>/<attachment-filename>
459 # https://request.siteworx.com/secure/attachment/17871/Wrong+FTP.jpg
460 # '+' := <space_char>
461 # Thumbnail Filespec := <jira-attachments>/<project-key>/<issue-key>/thumbs/_thumb_<attachment-id>.png
462 # URL := <base-url>/secure/thumbnail/<attachment-id>/_thumb_<attachment-id>.png
463 # https://request.siteworx.com/secure/thumbnail/17871/_thumb_17871.png
464
465 0 ▶ next if (defined($self->{':max_filesize'}) && ($attach->{'filesize'} > $self->{':max_filesize'}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{":max_filesize"} and $attach->{"filesize"} > $self->{":max_filesize"} 0 0 0
Condition0%0/3
defined $self->{":max_filesize"} and $attach->{"filesize"} > $self->{":max_filesize"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{":max_filesize"} and $attach->{"filesize"} > $self->{":max_filesize"}
defined $self->{":max_filesize"} $attach->{"filesize"} > $self->{":max_filesize"}
Truth table0%0/3
A and B
A= defined $self->{":max_filesize"}B= $attach->{"filesize"} > $self->{":max_filesize"}
ABresult
0X0
100
111
466
467 0 my $furl = $self->{':url'}."/secure/attachment/".$attach->{'id'}."/".$attach->{'filename'};
468 0 my $fspc = $fpth."/".$attach->{'id'};
469 #print "$furl\n ";
470 0 print "=> $fspc\n";
471
472 0 make_path($fpth);
473 0 my $rh = $self->{'_user_agent'}->mirror($furl,$fspc);
474 0 ▶ $cnt_attach++ if (($rh->code() == HTTP_OK) || ($rh->code() == HTTP_NOT_MODIFIED));
Branch: 1 branch
BranchTrueFalseTotal
if $rh->code == 200 or $rh->code == 304 0 0 0
Condition0%0/3
$rh->code == 200 or $rh->code == 304
l!l&&r!l&&!r
000
MC/DC0%0/2
$rh->code == 200 or $rh->code == 304
$rh->code == 200 $rh->code == 304
Truth table0%0/3
A or B
A= $rh->code == 200B= $rh->code == 304
ABresult
1X1
011
000
475
476 0 ▶ next if (! $self->{':grab_thumbs'});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{":grab_thumbs"} 0 0 0
477
478 0 my $turl = $self->{':url'}."/secure/thumbnail/".$attach->{'id'}."/_thumb_".$attach->{'id'}.".png";
479 0 my $tspc = $fpth."/thumbs/_thumb_".$attach->{'id'}.".png";
480 #print "$turl\n ";
481 0 print "=> $tspc\n";
482
483 0 make_path("$fpth/thumbs");
484 0 $rh = $self->{'_user_agent'}->mirror($turl,$tspc);
485 0 ▶ $thmb++ if (($rh->code() == HTTP_OK) || ($rh->code() == HTTP_NOT_MODIFIED));
Branch: 1 branch
BranchTrueFalseTotal
if $rh->code == 200 or $rh->code == 304 0 0 0
Condition0%0/3
$rh->code == 200 or $rh->code == 304
l!l&&r!l&&!r
000
MC/DC0%0/2
$rh->code == 200 or $rh->code == 304
$rh->code == 200 $rh->code == 304
Truth table0%0/3
A or B
A= $rh->code == 200B= $rh->code == 304
ABresult
1X1
011
000
486
487 ## $dd = Data::Dumper->new([$attach]); print $dd->Dump();
488 }
489 0 ▶ remove_tree("$fpth/thumbs") if (! $thmb);
Branch: 1 branch
BranchTrueFalseTotal
unless $thmb 0 0 0
490 return($cnt_issues,$cnt_attach) if ((defined($self->{':max_attachments'}) &&
491 ($cnt_attach >= $self->{':max_attachments'})) ||
492 (defined($self->{':max_issues'}) &&
493 0 ▶ ($cnt_issues >= $self->{':max_issues'})));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{":max_attachments"} and $cnt_attach >= $self->{":max_attachments"} or defined $self->{":max_issues"} and $cnt_issues >= $self->{":max_issues"} 0 0 0
Condition0%0/9
defined $self->{":max_attachments"} and $cnt_attach >= $self->{":max_attachments"} or defined $self->{":max_issues"} and $cnt_issues >= $self->{":max_issues"}
l!l&&r!l&&!r
000
defined $self->{":max_attachments"} and $cnt_attach >= $self->{":max_attachments"}
!ll&&!rl&&r
000
defined $self->{":max_issues"} and $cnt_issues >= $self->{":max_issues"}
!ll&&!rl&&r
000
MC/DC0%0/4
defined $self->{":max_attachments"} and $cnt_attach >= $self->{":max_attachments"} or defined $self->{":max_issues"} and $cnt_issues >= $self->{":max_issues"}
defined $self->{":max_attachments"} $cnt_attach >= $self->{":max_attachments"} defined $self->{":max_issues"} $cnt_issues >= $self->{":max_issues"}
Truth table0%0/7
A and B or C and D
A= defined $self->{":max_attachments"}B= $cnt_attach >= $self->{":max_attachments"}C= defined $self->{":max_issues"}D= $cnt_issues >= $self->{":max_issues"}
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
494 }
495 }
496 }
497 }
498 0 return($cnt_issues,$cnt_attach);
499 }
500
501
502
503 =head2 getDebug()
504 =cut
505 0 ▶sub getDebug {
Subroutine getDebug: not called CC=1 SCAR=6.9
Pod documented
506 0 my ($self,@args) = @_;
507 0 carp "getDebug() is not implemented";
508 0 return(undef);
509 }
510
511 =head2 getVerbose()
512 =cut
513 0 ▶sub getVerbose {
Subroutine getVerbose: not called CC=1 SCAR=6.9
Pod documented
514 0 my ($self,@args) = @_;
515 0 carp "getVerbose() is not implemented";
516 0 return(undef);
517 }
518
519 =head2 setDebug()
520 =cut
521
522 0 ▶sub setDebug {
Subroutine setDebug: not called CC=1 SCAR=6.9
Pod documented
523 0 my ($self,@args) = @_;
524 0 carp "setDebug() is not implemented";
525 0 return(undef);
526 }
527
528 =head2 setVerbose()
529 =cut
530
531 0 ▶sub setVerbose {
Subroutine setVerbose: not called CC=1 SCAR=6.9
Pod documented
532 0 my ($self,@args) = @_;
533 0 carp "setVerbose() is not implemented";
534 0 return(undef);
535 }
536
537 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
538 0 my ($class,@args) = @_;
539 0 my $self = ( );
540 0 foreach my $href (@args) {
541 0 @$self{ keys %{$href} } = values %{$href};
542 }
543 0 bless($self,$class);
544
545 0 ▶ croak "error: configuration filename is missing" if (! $self->{filename});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"filename"} 0 0 0
546 0 ▶ croak "error: configuration file '".$self->{filename}."' not found" if (! -f $self->{filename});
Branch: 1 branch
BranchTrueFalseTotal
unless -f $self->{"filename"} 0 0 0
547 0 ▶ if (! ($self->{config} = _get_configuration($self->{filename}))) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"config"} = _get_configuration($self->{"filename"})) 0 0 0
548 0 croak "error: configuration file contains errors";
549 }
550 0 return($self);
551 }
552
553
554 1 my %attribs = (
555 'id' => [ 'integer', '' ]
556 ,'issue' => [ 'integer', 'as' ]
557 ,'author' => [ 'string', '' ]
558 ,'body' => [ 'text', '' ]
559 ,'created' => [ 'timestamp', '' ]
560 ,'updated' => [ 'timestamp', 'asd' ]
561 ,'key' => [ 'string', 'asd' ]
562 ,'project' => [ 'string', 'asd' ]
563 ,'reporter' => [ 'string', 'asd' ]
564 ,'assignee' => [ 'string', 'asd' ]
565 ,'type' => [ 'integer', 'type' ]
566 ,'summary' => [ 'string', 'asd' ]
567 ,'priority' => [ 'integer', 'priorities' ]
568 ,'resolution' => [ 'integer', 'resolutions' ]
569 ,'status' => [ 'integer', 'statuses' ]
570 ,'votes' => [ 'integer', 0 ]
571 ,'watched' => [ 'integer', 0 ]
572 ,'workflowId' => [ 'integer', 'asd' ]
573 ,'security' => [ 'integer', 'asd' ]
574 ,'description' => [ 'text', 'asd' ]
575 );
576
577 1 my %entities = (
578 'WorkLog' => [ 'id', 'issue', 'author', 'body', 'created', 'updated', 'startdate', 'timeworked' ]
579 ,'Issue' => [ 'id', 'key', 'project', 'reporter', 'assignee', 'type', 'summary',
580 'priority', 'resolution', 'status', 'created', 'updated', 'votes', 'watched',
581 'workflowId', 'security', 'description' ]
582 );
583
584 =head2 buildProjectImportFile
585 =cut
586
587 0 ▶sub buildProjectImportFile {
Subroutine buildProjectImportFile: not called CC=2 SCAR=17.9
Pod documented
588 0 my ($self,@args) = @_;
589 0 foreach my $href (@args) {
590 0 @$self{ keys %{$href} } = values %{$href};
591 }
592
593
594
595 0 return(undef);
596 }
597
598
599 1 1; ### End of 'JWand.pm'
600 __END__
↑ Summary Comskil.pm »