Package/File.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 65 CC 5 SCAR 13.6
CC
5
Cov
0%
get_name
6.0
get_mode
6.0
get_md5sum
6.0
CRAP 3.9
1 # $Id$
2 package Youri::Package::File;
3  
4 =head1 NAME
5  
6 Youri::Package::File - Package file class
7  
8 =head1 DESCRIPTION
9  
10 This class represent a package file,
11  
12 =cut
13  
14 use strict;
15 use warnings;
16 use Carp;
17  
18 use constant NAME => 0;
19 use constant MODE => 1;
20 use constant MD5SUM => 2;
21  
22 use constant MODE_MASK => oct(170000);
23 use constant MODE_DIR => oct(40000);
24  
25 =head1 CLASS METHODS
26  
27 =head2 new(%args)
28  
29 Creates and returns a new Youri::Package::File object.
30  
31 =cut
32  
33 sub new {
34 my ($class, $name, $mode, $md5sum) = @_;
35  
36 return bless [
37 $name,
38 $mode,
39 $md5sum,
40 ], $class;
41 }
42  
43 =head2 get_name()
44  
45 Returns the name of this file.
46  
47 =cut
48  
49 sub get_name {
50 my ($self) = @_;
51 croak "Not a class method" unless ref $self;
52  
53 return $self->[NAME];
54 }
55  
56 =head2 get_mode()
57  
58 Return the mode of this file.
59  
60 =cut
61  
62 sub get_mode {
63 my ($self) = @_;
64 croak "Not a class method" unless ref $self;
65  
66 return $self->[MODE];
67 }
68  
69 =head2 get_md5sum()
70  
71 Return the md5sum of this file.
72  
73 =cut
74  
75 sub get_md5sum {
76 my ($self) = @_;
77 croak "Not a class method" unless ref $self;
78  
79 return $self->[MD5SUM];
80 }
81  
82 =head2 is_directory()
83  
84 Returns a true value if this file is a directory.
85  
86 =cut
87  
88 sub is_directory {
89 my ($self) = @_;
90 croak "Not a class method" unless ref $self;
91  
92 ## no critic (ProhibitBitwise)
93 return ($self->[MODE] & MODE_MASK) == MODE_DIR;
94 }
95  
96 1;