]> git.donarmstrong.com Git - debbugs.git/blob - Debbugs/Version/Binary.pm
add VersionTree and Collection::Version
[debbugs.git] / Debbugs / Version / Binary.pm
1 # This module is part of debbugs, and
2 # is released under the terms of the GPL version 2, or any later
3 # version (at your option). See the file README and COPYING for more
4 # information.
5 # Copyright 2018 by Don Armstrong <don@donarmstrong.com>.
6
7 package Debbugs::Version::Binary;
8
9 =head1 NAME
10
11 Debbugs::Version::Binary -- OO interface to Version
12
13 =head1 SYNOPSIS
14
15    use Debbugs::Version::Binary;
16    Debbugs::Version::Binary->new(schema => $s,binaries => [qw(foo)],sources => [qw(bar)]);
17
18 =head1 DESCRIPTION
19
20
21
22 =cut
23
24 use Mouse;
25 use v5.10;
26 use strictures 2;
27 use namespace::autoclean;
28
29 use Debbugs::Config qw(:config);
30 use Debbugs::Collection::Package;
31 use Debbugs::OOTypes;
32
33 extends 'Debbugs::Version';
34
35 sub type {
36     return 'binary';
37 }
38
39 has source_version => (is => 'ro',
40                        isa => 'Debbugs::Version::Source',
41                        lazy => 1,
42                        builder => '_build_source_version',
43                       );
44
45 sub _build_source_version {
46     my $self = shift;
47     my $source_version =
48         $self->package->
49         get_source_version(version => $self->version,
50                            $self->_count_archs?(archs => [$self->_archs]):(),
51                           );
52     if (defined $source_version) {
53         return $source_version;
54     }
55     return Debbugs::Version::Source->new(version => $self->version,
56                                          package => '(unknown)',
57                                          valid => 0,
58                                          package_collection => $self->package_collection,
59                                         );
60 }
61
62 has archs => (is => 'bare',
63               isa => 'ArrayRef[Str]',
64               builder => '_build_archs',
65               traits => ['Array'],
66               handles => {'_archs' => 'elements',
67                           '_count_archs' => 'count',
68                          },
69              );
70
71 sub _build_archs {
72     my $self = shift;
73     # this is wrong, but we'll start like this for now
74     return ['any'];
75 }
76
77 sub arch {
78     my $self = shift;
79     return $self->_count_archs > 0?join('',$self->_archs):'any';
80 }
81
82
83 __PACKAGE__->meta->make_immutable;
84 no Mouse;
85 1;
86
87
88 __END__
89 # Local Variables:
90 # indent-tabs-mode: nil
91 # cperl-indent-level: 4
92 # End: