File Coverage

blib/lib/Dpkg/Deps/Union.pm
Criterion Covered Total %
statement 25 29 86.2
branch 3 4 75.0
condition n/a
subroutine 5 7 71.4
pod 4 4 100.0
total 37 44 84.0


line stmt bran cond sub pod time code
1             # Copyright © 1998 Richard Braakman
2             # Copyright © 1999 Darren Benham
3             # Copyright © 2000 Sean 'Shaleh' Perry
4             # Copyright © 2004 Frank Lichtenheld
5             # Copyright © 2006 Russ Allbery
6             # Copyright © 2007-2009 Raphaël Hertzog
7             # Copyright © 2008-2009, 2012-2014 Guillem Jover
8             #
9             # This program is free software; you may redistribute it and/or modify
10             # it under the terms of the GNU General Public License as published by
11             # the Free Software Foundation; either version 2 of the License, or
12             # (at your option) any later version.
13             #
14             # This is distributed in the hope that it will be useful,
15             # but WITHOUT ANY WARRANTY; without even the implied warranty of
16             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17             # GNU General Public License for more details.
18             #
19             # You should have received a copy of the GNU General Public License
20             # along with this program. If not, see .
21              
22             package Dpkg::Deps::Union;
23              
24             =encoding utf8
25              
26             =head1 NAME
27              
28             Dpkg::Deps::Union - list of unrelated dependencies
29              
30             =head1 DESCRIPTION
31              
32             This class represents a list of relationships.
33             It inherits from Dpkg::Deps::Multiple.
34              
35             =cut
36              
37 1     1   7 use strict;
  1         2  
  1         29  
38 1     1   5 use warnings;
  1         10  
  1         46  
39              
40             our $VERSION = '1.00';
41              
42 1     1   5 use parent qw(Dpkg::Deps::Multiple);
  1         2  
  1         15  
43              
44             =head1 METHODS
45              
46             =over 4
47              
48             =item $dep->output([$fh])
49              
50             The output method uses ", " to join the list of relationships.
51              
52             =cut
53              
54             sub output {
55 3     3 1 25 my ($self, $fh) = @_;
56              
57             my $res = join(', ', map {
58 6         11 $_->output()
59             } grep {
60 3         21 not $_->is_empty()
  6         10  
61             } $self->get_deps());
62              
63 3 50       11 if (defined $fh) {
64 0         0 print { $fh } $res;
  0         0  
65             }
66 3         15 return $res;
67             }
68              
69             =item $dep->implies($other_dep)
70              
71             =item $dep->get_evaluation($other_dep)
72              
73             These methods are not meaningful for this object and always return undef.
74              
75             =cut
76              
77             sub implies {
78             # Implication test is not useful on Union.
79 0     0 1 0 return;
80             }
81              
82             sub get_evaluation {
83             # Evaluation is not useful on Union.
84 0     0 1 0 return;
85             }
86              
87             =item $dep->simplify_deps($facts)
88              
89             The simplification is done to generate an union of all the relationships.
90             It uses $simple_dep->merge_union($other_dep) to get its job done.
91              
92             =cut
93              
94             sub simplify_deps {
95 2     2 1 20 my ($self, $facts) = @_;
96 2         3 my @new;
97              
98             WHILELOOP:
99 2         4 while (@{$self->{list}}) {
  11         30  
100 9         16 my $odep = shift @{$self->{list}};
  9         16  
101 9         21 foreach my $dep (@new) {
102 17 100       37 next WHILELOOP if $dep->merge_union($odep);
103             }
104 6         15 push @new, $odep;
105             }
106 2         9 $self->{list} = [ @new ];
107             }
108              
109             =back
110              
111             =head1 CHANGES
112              
113             =head2 Version 1.00 (dpkg 1.15.6)
114              
115             Mark the module as public.
116              
117             =cut
118              
119             1;