Content.pm

filter: Statementstmt 82.3% 14 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod n/a totaltotal 81.8% 18 / 22 CC 1 SCAR 1.8
CC
1
Cov
82%
_genKey
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Entry.pm ↑ Summary Name.pm »
1 #=============================== Content.pm ==================================
2 # Filename: Content.pm
3 # Description: Generalized hash by md5sum and length of file info.
4 # Original Author: Dale M. Amon
5 # Revised by: $Author: amon $
6 # Date: $Date: 2008-08-28 23:35:28 $
7 # Version: $Revision: 1.7 $
8 # License: LGPL 2.1, Perl Artistic or BSD
9 #
10 #=============================================================================
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use FileHash::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use FileHash::Entry;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 package FileHash::Content;
16 1 ▶use vars qw{@ISA};
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 @ISA = qw( FileHash::Base );
18  
19 #=============================================================================
20 # FAMILY METHODS
21 #=============================================================================
22  
23 0 ▶sub _genKey {
Subroutine _genKey: not called CC=1 SCAR=6.9
24 0 my ($s,$entry) = @_;
25 0 my ($md5,$size) = ($entry->md5sum, $entry->sizeBytes);
26 0 return "$md5,$size";
27 }
28
29 #=============================================================================
30 # POD DOCUMENTATION
31 #=============================================================================
32 # You may extract and format the documention section with the 'perldoc' cmd.
33  
34 =head1 NAME
35  
36 FileHash::Content - A Hash of file data keyed by the file's md5sum.
37  
38 =head1 SYNOPSIS
39  
40 use FileHash::Content;
41 $obj = FileHash::Content->alloc;
42  
43 =head1 Inheritance
44  
45 FileHash::Base
46  
47 =head1 Description
48  
49 This is a container for lists of file name entries. It modifies the
50 definition of hash to to be a combination of an MD5 hash of a file and the
51 length of the file in bytes, a string which will almost certainly be unique
52 on your file system although theoretically you could have collisions:
53  
54 "$hash,$size"
55  
56 Files with the same size and content will be hashed with the same key so that
57 all such instances will be added to the same bucket.
58  
59 Other than the hash key definition, it inherits its behavior from FileHash::Base.
60  
61 =head1 Examples
62  
63 use FileHash::Content;
64 my $a = FileHash::Content->alloc;
65 $a->initFromTree ("/root");
66  
67 =head1 Class Variables
68  
69 None.
70  
71 =head1 Instance Variables
72  
73 None.
74  
75 =head1 Class Methods
76  
77 =over 4
78  
79 =item B<$obj = FileHash::Content-E<gt>alloc>
80  
81 Allocate an empty instance of FileHash::Content.
82  
83 =back 4
84  
85 =head1 Instance Methods
86  
87 See FileHash::Base.
88  
89 =head1 Private Class Method
90  
91 None.
92  
93 =head1 Private Instance Methods
94  
95 =over 4
96  
97 =item B<$key = $obj-E<gt>_genKey($entry)>
98  
99 Create an appropriate hash key. If needed values are undef,
100 it will generate an md5sum or length of 0 for use in constructing
101 the key.
102  
103 =back 4
104  
105 =head1 Errors and Warnings
106  
107 Lots.
108  
109 =head1 KNOWN BUGS
110  
111 See TODO.
112  
113 =head1 SEE ALSO
114  
115 FileHash::Base, FileHash::Entry.
116  
117 =head1 AUTHOR
118  
119 Dale Amon <amon@vnl.com>
120  
121 =cut
122
123 #=============================================================================
124 # CVS HISTORY
125 #=============================================================================
126 # $Log: Content.pm,v $
127 # Revision 1.7 2008-08-28 23:35:28 amon
128 # perldoc section regularization.
129 #
130 # Revision 1.6 2008-08-04 12:14:34 amon
131 # Syntax bug fix.
132 #
133 # Revision 1.5 2008-07-27 15:16:17 amon
134 # Wrote lexical parse for Entry; error checking on eval and other minor issues.
135 #
136 # Revision 1.4 2008-07-25 14:30:42 amon
137 # Documentation improvements and corrections.
138 #
139 # Revision 1.3 2008-07-24 13:35:26 amon
140 # switch to NeXT style alloc/init format for FileHash and Entry classes.
141 #
142 # Revision 1.2 2008-07-23 21:12:24 amon
143 # Moved notes out of file headers; a few doc updates; added assertion checks;
144 # minor bug fixes.
145 #
146 # 20080717 Dale Amon <amon@vnl.com>
147 # Split FilenameHash, formerly Directory class, into FileHash
148 # FileHash::Name and FileHash::Content. FileHash::Content uses
149 # code from DirTreeHash class I wrote in February.
150 # 20080716 Dale Amon <amon@vnl.com>
151 # Created.
152 # 20080216 Dale Amon <amon@vnl.com>
153 # Created DirTreeHash.
154 1 1;
155  
« Entry.pm ↑ Summary Name.pm »