blib/lib/Pinto/DifferenceEntry.pm

filter: Statementstmt 81.8% 27 / 33 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 63.6% 7 / 11 Podpod 0.0% 0 / 5 totaltotal 64.8% 35 / 54 CC 2 SCAR 4.2
CC
2
Cov
78%
to_string
2.1
is_addition
2.0
is_deletion
2.0
CRAP 1.5
« blib/lib/App/Pinto/Command/delete.pm ↑ Summary blib/lib/App/Pinto/Command/add.pm »
1 # ABSTRACT: Represents one addition or deletion in a diff
2  
3 package Pinto::DifferenceEntry;
4  
5 8 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use MooseX::MarkAsMethods ( autoclean => 1 );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use MooseX::Types::Moose qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 ▶use String::Format;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #------------------------------------------------------------------------------
13  
14 8 ▶use overload (
Subroutine BEGIN: called CC=1 SCAR=0.0
15 8 q{""} => 'to_string',
16 'cmp' => 'string_compare',
17 8 );
18  
19 #------------------------------------------------------------------------------
20  
21 8 our $VERSION = '0.14'; # VERSION
22  
23 #------------------------------------------------------------------------------
24  
25 # TODO: Consider breaking this into separate Addition and Deletion subclasses,
26 # rather than using an "op" attribute to indicate which kind it is. That sort
27 # of "type" flag is always a code smell to me.
28  
29 #------------------------------------------------------------------------------
30  
31 8 has op => (
32 is => 'ro',
33 isa => Str,
34 required => 1
35 );
36  
37 8 has registration => (
38 is => 'ro',
39 isa => 'Pinto::Schema::Result::Registration',
40 required => 1,
41 );
42  
43 #------------------------------------------------------------------------------
44  
45 0 ▶sub is_addition { shift->op eq '+' }
Subroutine is_addition: not called CC=1 SCAR=6.9
Pod undocumented
46  
47 0 ▶sub is_deletion { shift->op eq '-' }
Subroutine is_deletion: not called CC=1 SCAR=6.9
Pod undocumented
48  
49 #------------------------------------------------------------------------------
50  
51 2 ▶sub to_string {
Subroutine to_string: called CC=2 SCAR=7.4
Pod undocumented
52 2 my ( $self, $format ) = @_;
53  
54 2 my %fspec = ( o => $self->op );
55  
56 2 ▶ $format ||= $self->default_format;
Condition33%1/3
$format ||= $self->default_format
l!l&&r!l&&!r
200
MC/DC0%0/2
$format ||= $self->default_format
$format $self->default_format
Truth table33%1/3
A ||= B
A= $formatB= $self->default_format
ABresult
1X1
011
000
57 2 return $self->registration->to_string( String::Format::stringf($format, %fspec) );
58 }
59  
60 #------------------------------------------------------------------------------
61  
62 0 ▶sub default_format {
Subroutine default_format: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my ($self) = @_;
64  
65 0 return '%o[%F] %-40p %12v %a/%f',
66 }
67  
68 #------------------------------------------------------------------------------
69  
70 0 ▶sub string_compare {
Subroutine string_compare: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my ( $self, $other ) = @_;
72  
73 0 return $self->registration->distribution->name
74 cmp $other->registration->distribution->name;
75 }
76  
77 #------------------------------------------------------------------------------
78  
79 8 __PACKAGE__->meta->make_immutable;
80  
81 #------------------------------------------------------------------------------
82 8 1;
83  
84 __END__
« blib/lib/App/Pinto/Command/delete.pm ↑ Summary blib/lib/App/Pinto/Command/add.pm »