CPAN2Pkg/Lock.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 100% 42 / 42 CC 3 SCAR 4.7
CC
3
Cov
100%
get
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« CPAN2Pkg/Worker/RPM.pm ↑ Summary
1 #
2 # This file is part of App-CPAN2Pkg
3 #
4 # This software is copyright (c) 2009 by Jerome Quelin.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 1 ▶use 5.012;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package App::CPAN2Pkg::Lock;
14 # ABSTRACT: Simple locking mechanism within cpan2pkg
15 1 $App::CPAN2Pkg::Lock::VERSION = '3.004';
16 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use MooseX::Has::Sugar;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # -- attributes
20  
21  
22 1 has owner => (
23 rw,
24 isa => 'Str',
25 writer => '_set_owner',
26 clearer => '_clear_owner',
27 predicate => '_has_owner',
28 );
29  
30  
31 # -- methods
32  
33  
34 3 ▶sub is_available {
Subroutine is_available: called CC=1 SCAR=0.0
Pod documented
35 3 my $self = shift;
36 3 return ! $self->_has_owner;
37 }
38  
39  
40  
41 3 ▶sub get {
Subroutine get: called CC=3 SCAR=11.0
Pod documented
42 3 my ($self, $owner) = @_;
43 3 ▶ die "need to specify owner parameter" unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 1 2 3
44 2 ▶ if ( $self->_has_owner ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_has_owner) 1 1 2
45 1 my $current = $self->owner;
46 1 die "lock already owned by $current";
47 }
48 1 $self->_set_owner( $owner );
49 }
50  
51  
52  
53 1 ▶sub release {
Subroutine release: called CC=1 SCAR=0.0
Pod documented
54 1 my $self = shift;
55 1 $self->_clear_owner;
56 }
57  
58 1 1;
59  
60 __END__
« CPAN2Pkg/Worker/RPM.pm ↑ Summary