PVCS/Attributes.pm untested

filter: Statementstmt 0.0% 0 / 46 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 73 CC 5 SCAR 20.1
CC
5
Cov
0%
getAttributes
12.0
AUTOLOAD
12.0
BEGIN
2.0
CRAP 7.5
1 # Attributes.pm - attribute class for Perl PVCS module
2 #
3 # Copyright (c) 1998 Bill Middleton
4 #
5 #
6  
7 =head1 NAME
8  
9 VCS::PVCS::Attributes - Attributes class for for VCS::PVCS
10  
11 =head1 SYNOPSIS
12  
13 use VCS::PVCS::Project;
14  
15 $proj = new VCS::PVCS::Project("ProjectName");
16  
17 $members = $proj->members(".*");
18  
19 foreach $f (@$members){
20 $attrs = $f->getAttributes();
21 print $attrs->Archive; # Archive name
22 print $attrs->Workfile; # Workfile name
23 print $attrs->Owner; # Owner of archive
24 print $attrs->Archive_created; # Date archive created
25 print $attrs->Last_trunk_rev; # Most recent trunk rev
26 print $attrs->Locks; # current locks on all versions
27 print $attrs->Groups; # current groups assoc with this archive
28 print $attrs->Rev_count; # number of revisions
29 print $attrs->Attributes; # attributes
30 print $attrs->Version_labels; # version labels on this archive
31 print $attrs->Description; # checkin description
32 print $attrs->history; # history and comments
33  
34 }
35  
36 =head1 DESCRIPTION
37  
38 This class is intended for use as an companion to the
39 VCS::PVCS::* classes. The Archive objects inherits Attribute
40 methods, and augment them.
41  
42 =head1 METHODS
43  
44 =over 5
45  
46 =item B<getAttributes>
47  
48 print $attrs->getAttributes(1);
49  
50 repopulate the attibutes object
51  
52 =item B<Archive>
53  
54 print $attrs->Archive; # Archive name
55  
56 =item B<Workfile
57  
58 print $attrs->Workfile; # Workfile name
59  
60 =item B<Owner
61  
62 print $attrs->Owner; # Owner of archive
63  
64 =item B<Archive_created
65  
66 print $attrs->Archive_created; # Date archive created
67  
68 =item B<Last_trunk_rev
69  
70 print $attrs->Last_trunk_rev; # Most recent trunk rev
71  
72 =item B<Locks
73  
74 print $attrs->Locks; # current locks on all versions
75  
76 =item B<Groups
77  
78 print $attrs->Groups; # current groups assoc with this archive
79  
80 =item B<Rev_count
81  
82 print $attrs->Rev_count; # number of revisions
83  
84 =item B<Attributes
85  
86 print $attrs->Attributes; # attributes
87  
88 =item B<Version_labels
89  
90 print $attrs->Version_labels; # version labels on this archive
91  
92 =item B<Description
93  
94 print $attrs->Description; # checkin description
95  
96 =item B<history
97  
98 print $attrs->history; # history and comments
99  
100 =back
101  
102 =head1 COPYRIGHT
103  
104 The PVCS module is Copyright (c) 1998 Bill Middleton.
105 All rights reserved.
106  
107 You may distribute under the terms of either the GNU General Public
108 License or the Artistic License, as specified in the Perl README file.
109  
110 =head1 AUTHOR
111  
112 Bill Middleton, wjm@metronet.com
113  
114 =head1 SUPPORT / WARRANTY
115  
116 The VCS::PVCS modules are free software.
117  
118 B<THEY COME WITHOUT WARRANTY OF ANY KIND.>
119  
120 Commercial support agreements for Perl can be arranged via
121 The Perl Clinic. See http://www.perl.co.uk/tpc for more details.
122  
123 =head1 SEE ALSO
124  
125 VCS::PVCS::Project
126  
127 =cut
128  
129  
130 package VCS::PVCS::Attributes;
131 use strict;
132 use Carp;
133 require Exporter;
134 use VCS::PVCS;
135 use vars qw($VERSION %EXPORT_TAGS @EXPORT_OK @ISA $AUTOLOAD);
136 $VERSION = "0.01";
137 @ISA = qw(Exporter );
138  
139 sub getAttributes{
140 my($self) = shift;
141 my($arpath) = $self->archive();
142 my($attrs) = {};
143 my($force) = shift;
144  
145 ($^O ne "MSWin32") and translatePath2Unix(\$arpath);
146  
147 if((ref($self->{'Attributes'}) !~ /VCS::PVCS::Attributes/) or $force){
148 VCS::PVCS::Commands::vlog("-I -Q", $arpath);
149 }
150 else{
151 return $self->{'Attributes'};
152 }
153  
154 if($PVCSERR){
155 warn $PVCSOUTPUT;
156 $PVCSOUTPUT = "";
157 return undef;
158 }
159  
160 my(@log)= split(/-----------------------------------/,$PVCSOUTPUT);
161  
162 $log[0] =~ m/Archive:\s*(.*)[\r?\n]Workfile:\s*(.*)[\r?\n]Archive created:\s*(.*)[\r?\n]Owner:\s*(.*)[\r?\n]Last trunk rev:\s*(.*)[\r?\n]Locks:\s*(.*)[\r?\n]Groups:\s*(.*)[\r?\n]Rev count:\s*(.*)[\r?\n]Attributes:\s*(.*)[\r?\n]Version labels:\s*(.*)[\r?\n]Description:\s*(.*)[\r?\n]/s;
163  
164 $attrs = {
165 "Archive" => $1,
166 "Workfile" => $2,
167 "Archive_created" => $3,
168 "Owner" => $4,
169 "Last_trunk_rev" => $5,
170 "Locks" => $6,
171 "Groups" => $7,
172 "Rev_count" => $8,
173 "Attributes" => $9,
174 "Version_labels" => $10,
175 "Description" => $11
176 };
177  
178 #for($i=1;$i<$#log;$i++){
179 #$log[$i] =~ m/Rev\s+(\d+\.\d+)[\r?\n]Checked in:\s+(.*)[\r?\n]Last modified:\s+(.*)[\r?\n]Author id:\s+(.*)\s+lines deleted\/added\/moved:\s+(\d+\/\d+\/\d+)\s*[\r?\n](.*)/s;
180 #print "$1 $2 $3 $4 $5 $6\n"
181 #}
182  
183 $attrs->{'History'} = join('-' x 35,@log[1 .. $#log]);
184  
185 bless($attrs,"VCS::PVCS::Attributes");
186 $self->{'Attributes'} = $attrs;
187 $PVCSOUTPUT = "";
188 return $attrs;
189 }
190  
191 sub AUTOLOAD{
192 my($self) = shift;
193 return undef unless ref($self);
194 my($method) = $AUTOLOAD;
195  
196 $method =~ s/.*:://;
197  
198 if(defined $self->{$method}){
199 return $self->{$method};
200 }
201  
202 }
203  
204 1;
205 __END__