File Coverage

blib/lib/Software/Packager/Object/Svr4.pm
Criterion Covered Total %
statement 17 39 43.5
branch 3 14 21.4
condition 3 17 17.6
subroutine 4 10 40.0
pod 2 6 33.3
total 29 86 33.7


line stmt bran cond sub pod time code
1             package Software::Packager::Object::Svr4;
2              
3 1     1   6 use strict;
  1         1  
  1         42  
4 1     1   5 use base qw(Software::Packager::Object);
  1         9  
  1         73  
5 1     1   6 use vars qw($VERSION);
  1         2  
  1         540  
6             $VERSION = 0.02;
7              
8             sub _check_data {
9 16     16   171 my ($self, %data) = @_;
10              
11 16         51 $self->{TYPE} = lc $self->{TYPE};
12 16 50 33     94 if ($self->{TYPE} eq 'file') {
    50          
13 0 0       0 return undef unless -f $self->{SOURCE};
14             } elsif ($self->{TYPE} eq 'hardlink' ||
15             $self->{TYPE} eq 'softlink') {
16 0 0 0     0 return undef unless $self->{SOURCE}
17             and $self->{DESTINATION};
18             }
19              
20 16   33     126 $self->{MODE} ||= [stat($self->{SOURCE})]->[2] % 010000;
21              
22             # make sure PART is set to a number
23 16 50       34 if (scalar $self->{PART}) {
24 0         0 $self->{PART} =~ /\d+/;
25             } else {
26 16         27 $self->{PART} = 1;
27             }
28              
29 16   50     70 $self->{CLASS} ||= "none";
30              
31 16         46 return 1;
32             }
33              
34             sub user {
35 0     0 1   my $self = shift;
36 0           my $value = shift;
37              
38 0 0         $self->{USER} = $value
39             if $value;
40 0   0       $self->{USER} ||= [getpwuid([lstat($self->source)]->[4])]->[0];
41 0           return $self->{USER};
42             }
43              
44             sub group
45             {
46 0     0 1   my $self = shift;
47 0           my $value = shift;
48              
49 0 0         $self->{GROUP} = $value
50             if $value;
51 0   0       $self->{GROUP} ||= [getgrgid([lstat($self->source)]->[5])]->[0];
52 0           return $self->{GROUP};
53             }
54              
55              
56             ################################################################################
57             # Function: status()
58             # Description: This function returns the status for this object.
59             # Arguments: none.
60             # Return: package directory.
61             #
62             sub status {
63 0     0 0   my $self = shift;
64 0           return $self->{STATUS};
65             }
66              
67             ################################################################################
68             # Function: class()
69             # Description: This function returns the class for this object.
70             # Arguments: none.
71             # Return: object class
72             #
73             sub class {
74 0     0 0   my $self = shift;
75 0           return $self->{CLASS};
76             }
77              
78             ################################################################################
79             # Function: part()
80             # Description: This function returns the part for this object.
81             # Arguments: none.
82             # Return: object part
83             #
84             sub part {
85 0     0 0   my $self = shift;
86 0           return $self->{PART};
87             }
88              
89             ################################################################################
90             # Function: prototype()
91             # Description: This function returns the object type for the object as
92             # described in prototype(4) man page.
93             # Arguments: $self
94             # Return: object type
95             #
96             sub prototype
97             {
98 0     0 0   my $self = shift;
99 0           my %proto_types = (
100             'block' => 'b',
101             'charater' => 'c',
102             'directory' => 'd',
103             'edit' => 'e',
104             'file' => 'f',
105             'installation' => 'i',
106             'hardlink' => 'l',
107             'pipe' => 'p',
108             'softlink' => 's',
109             'volatile' => 'v',
110             'exclusive' => 'x',
111             );
112              
113 0           return $proto_types{$self->{'TYPE'}};
114             }
115              
116             1; __END__