blib/lib/Net/Jenkins/Job.pm

filter: Statementstmt 49.5% 51 / 103 Branchbran 25.0% 2 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 57.1% 20 / 35 Podpod n/a totaltotal 46.7% 73 / 156 CC 7 SCAR 9.4
CC
7
Cov
45%
last_build
9.6
first_build
9.6
to_hashref
3.2
CRAP 2.6
« blib/lib/Net/Jenkins.pm ↑ Summary blib/lib/Net/Jenkins/Job/Build.pm »
1 package Net::Jenkins::Job;
2 2 ▶use methods;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Net::Jenkins::Job::Build;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Net::Jenkins::Job::QueueItem;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 has name => ( is => 'rw' , isa => 'Str' );
8  
9 # 'color' => 'grey',
10 2 has color => ( is => 'rw' );
11  
12 # 'url' => 'http://localhost:8080/job/Phifty/',
13 2 has url => ( is => 'rw' , isa => 'Str' );
14  
15 2 has api => ( is => 'rw' , isa => 'Net::Jenkins' );
16  
17 0 ▶method delete {
Subroutine BEGIN: called CC=1 SCAR=4.1
Subroutine delete: not called CC=1 SCAR=4.9
Subroutine __ANON__: not called CC=1 SCAR=4.9
18 0 return $self->api->delete_job( $self->name );
19 2 }
20  
21 0 ▶method update ($xml) {
Subroutine BEGIN: called CC=1 SCAR=3.5
Subroutine update: not called CC=1 SCAR=4.1
22 0 return $self->api->update_job( $self->name, $xml );
23 2 }
24  
25 0 ▶method copy ($new_job_name) {
Subroutine BEGIN: called CC=1 SCAR=3.5
Subroutine copy: not called CC=1 SCAR=4.1
26 0 return $self->api->copy_job( $new_job_name , $self->name );
27 2 }
28  
29  
30 0 ▶method enable {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine enable: not called CC=1 SCAR=3.5
31 0 return $self->api->enable_job($self->name);
32 2 }
33  
34 0 ▶method disable {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine disable: not called CC=1 SCAR=3.5
35 0 return $self->api->disable_job($self->name);
36 2 }
37  
38  
39 # trigger a build
40 0 ▶method build {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=3.5
41 0 return $self->api->build_job($self->name);
42 2 }
43  
44  
45 # get job configuration
46 0 ▶method details {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine details: not called CC=1 SCAR=3.5
47 0 return $self->api->get_job_details( $self->name );
48 2 }
49  
50 0 ▶method description {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine description: not called CC=1 SCAR=3.5
51 0 return $self->details->{description};
52 2 }
53  
54 0 ▶method desc {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine desc: not called CC=1 SCAR=3.5
55 0 return $self->description;
56 2 }
57  
58 0 ▶method in_queue {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine in_queue: not called CC=1 SCAR=3.5
59 0 return $self->details->{inQueue};
60 2 }
61  
62 0 ▶method queue_item {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=4.1
63 0 return Net::Jenkins::Job::QueueItem->new( %{ $self->details->{queueItem} } , api => $self->api , job => $self );
64 2 }
65  
66 # get builds
67 0 ▶method builds {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine builds: not called CC=1 SCAR=4.1
68 0 return map { Net::Jenkins::Job::Build->new( %$_ , api => $self->api, job => $self ) }
69 $self->api->get_builds( $self->name );
70 2 }
71  
72 0 ▶method last_build {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine last_build: not called CC=3 SCAR=22.6
73 0 my $b = $self->details->{lastBuild};
74 0 ▶ return Net::Jenkins::Job::Build->new( %$b , api => $self->api , job => $self ) if $b && %$b;
Branch: 1 branch
BranchTrueFalseTotal
if $b and %$b 0 0 0
Condition0%0/3
$b and %$b
!ll&&!rl&&r
000
MC/DC0%0/2
$b and %$b
$b %$b
Truth table0%0/3
A and B
A= $bB= %$b
ABresult
0X0
100
111
75 2 }
76  
77 0 ▶method first_build {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine first_build: not called CC=3 SCAR=22.6
78 0 my $b = $self->details->{firstBuild};
79 0 ▶ return Net::Jenkins::Job::Build->new( %$b , api => $self->api , job => $self ) if $b && %$b;
Branch: 1 branch
BranchTrueFalseTotal
if $b and %$b 0 0 0
Condition0%0/3
$b and %$b
!ll&&!rl&&r
000
MC/DC0%0/2
$b and %$b
$b %$b
Truth table0%0/3
A and B
A= $bB= %$b
ABresult
0X0
100
111
80 2 }
81  
82 2 ▶method to_hashref ($with_details,$with_builds) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine to_hashref: called CC=3 SCAR=11.8
83 return {
84 name => $self->name,
85 color => $self->color,
86 url => $self->url,
87 ($with_details) ? ( details => $self->details ) : (),
88 ($with_builds) ? (
89 builds => [ map {
90 0 ▶ $_->to_hashref($with_details)
Branch: 2 branches
BranchTrueFalseTotal
$with_details ? : 0 1 1
$with_builds ? : 0 1 1
91 } $self->builds ],
92 ) : (),
93 };
94 2 }
95  
96 2 1;
97 __END__
« blib/lib/Net/Jenkins.pm ↑ Summary blib/lib/Net/Jenkins/Job/Build.pm »