| 1 | use 5.008; # utf8 | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use utf8; | ||
| 5 | |||
| 6 | package Git::Wrapper::Plus::Support::RangeSet; | ||
| 7 | $Git::Wrapper::Plus::Support::RangeSet::VERSION = '0.004010'; | ||
| 8 | # ABSTRACT: A set of ranges of supported things | ||
| 9 | |||
| 10 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | ||
| 11 | |||
| 12 | use Moo qw( has ); | ||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | has 'items' => ( is => ro =>, lazy => 1, builder => 1 ); | ||
| 21 | |||
| 22 | sub _build_items { | ||
| 23 | return []; | ||
| 24 | } | ||
| 25 | |||
| 26 | |||
| 27 | |||
| 28 | |||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | |||
| 34 | sub add_range_object { | ||
| 35 | my ( $self, $range_object ) = @_; | ||
| 36 | push @{ $self->items }, $range_object; | ||
| 37 | return $self; | ||
| 38 | } | ||
| 39 | |||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | |||
| 51 | |||
| 52 | |||
| 53 | sub add_range { | ||
| 54 | my ( $self, @args ) = @_; | ||
| 55 | my $config; | ||
| 56 | if ( 1 == @args ) { | ||
| 57 | $config = $args[0]; | ||
| 58 | } | ||
| 59 | else { | ||
| 60 | $config = {@args}; | ||
| 61 | } | ||
| 62 | require Git::Wrapper::Plus::Support::Range; | ||
| 63 | return $self->add_range_object( Git::Wrapper::Plus::Support::Range->new($config) ); | ||
| 64 | } | ||
| 65 | |||
| 66 | |||
| 67 | |||
| 68 | |||
| 69 | |||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | sub supports_version { | ||
| 76 | my ( $self, $version_object ) = @_; | ||
| 77 | for my $item ( @{ $self->items } ) { | ||
| 78 | my $cmp = $item->supports_version($version_object); | ||
| 79 | return $cmp if defined $cmp; | ||
| 80 | } | ||
| 81 | return; | ||
| 82 | } | ||
| 83 | |||
| 84 | no Moo; | ||
| 85 | 1; | ||
| 86 | |||
| 87 | __END__ |