File Coverage

lib/Git/Wrapper/Plus/Support/Range.pm
Criterion Covered Total %
statement 26 33 78.7
branch 7 14 50.0
condition 4 9 44.4
subroutine 8 8 100.0
pod 1 2 50.0
total 46 66 69.7


line stmt bran cond sub pod time code
1 6     6   1242 use 5.008; # utf8
  6         68  
  6         256  
2 6     6   35 use strict;
  6         10  
  6         197  
3 6     6   30 use warnings;
  6         11  
  6         163  
4 6     6   957 use utf8;
  6         24  
  6         50  
5              
6             package Git::Wrapper::Plus::Support::Range;
7             $Git::Wrapper::Plus::Support::Range::VERSION = '0.004010';
8             # ABSTRACT: A record describing a range of supported versions
9              
10             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
11              
12              
13              
14              
15              
16              
17              
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30 6     6   1386 use Moo qw( has );
  6         17123  
  6         62  
31              
32             our @CARP_NOT;
33              
34              
35              
36              
37              
38              
39              
40              
41              
42              
43              
44              
45              
46              
47              
48              
49              
50              
51              
52              
53              
54              
55              
56              
57              
58              
59              
60             has 'min' => ( is => ro =>, predicate => 'has_min' );
61             has 'max' => ( is => ro =>, predicate => 'has_max' );
62              
63             has 'min_tag' => ( is => ro =>, predicate => 'has_min_tag' );
64             has 'max_tag' => ( is => ro =>, predicate => 'has_max_tag' );
65              
66             has 'min_sha1' => ( is => ro =>, predicate => 'has_min_sha1' );
67             has 'max_sha1' => ( is => ro =>, predicate => 'has_max_sha1' );
68              
69              
70              
71              
72              
73              
74             sub BUILD {
75 118     118 0 15530 my ($self) = @_;
76 118 50 33     3354 if ( not $self->min and not $self->max ) {
77 0         0 require Carp;
78             ## no critic (Variables::ProhibitLocalVars)
79 0         0 local (@CARP_NOT) = ('Git::Wrapper::Plus::Support::Range');
80 0         0 Carp::croak('Invalid range, must specify either min or max, or both');
81             }
82             }
83              
84              
85              
86              
87              
88              
89              
90              
91              
92              
93              
94              
95              
96              
97             sub supports_version {
98 35     35 1 102 my ( $self, $versions_object ) = @_;
99 35 100 66     1671 if ( $self->has_min and not $self->has_max ) {
100 34 50       342 return 1 if $versions_object->newer_than( $self->min );
101 0         0 return;
102             }
103 1 50 33     33 if ( $self->has_max and not $self->has_min ) {
104 0 0       0 return 1 if $versions_object->older_than( $self->max );
105 0         0 return;
106             }
107 1 50       19 return unless $versions_object->newer_than( $self->min );
108 1 50       26602 return unless $versions_object->older_than( $self->max );
109 0           return 1;
110             }
111              
112 6     6   5582 no Moo;
  6         11  
  6         32  
113             1;
114              
115             __END__