| 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
MC/DC0%0/2
$format ||= $self->default_format
$format
$self->default_format
Truth table33%1/3
A ||= B
A= $formatB= $self->default_format
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||