Changed cvs_man.php -> scm_man.php.
[clearscm.git] / lib / Clearcase / Vobs.pm
1 =pod
2
3 =head1 NAME $RCSfile: Vobs.pm,v $
4
5 Object oriented interface to Clearcase VOBs
6
7 =head1 VERSION
8
9 =over
10
11 =item Author
12
13 Andrew DeFaria <Andrew@ClearSCM.com>
14
15 =item Revision
16
17 $Revision: 1.17 $
18
19 =item Created
20
21 Thu Dec 29 12:07:59 PST 2005
22
23 =item Modified
24
25 $Date: 2011/11/16 19:46:13 $
26
27 =back
28
29 =head1 SYNOPSIS
30
31 Provides access to information about all Clearcase VOBs.
32
33  # Create VOBs object
34  my $vobs = new Clearcase::Vobs;
35
36  display "There are " . $vobs->vobs . " vobs to process";
37
38  # Iterrate through the list of vobs
39  foreach ($vobs->vobs) {
40    my $vob = new Clearcase::Vob $_;
41    ...
42  } # foreach
43
44  # VOBs manipulation
45  display "Umounting all vobs";
46
47  $vobs->umount;
48
49  display "Mounting all vobs";
50
51  $vobs->mount;
52
53 =head1 DESCRIPTION
54
55 This module implements a Clearcase vobs object to  deal with the lists
56 of vobs in the current region.
57
58 =head1 ROUTINES
59
60 The following routines are exported:
61
62 =cut
63
64 package Clearcase::Vobs;
65
66 use strict;
67 use warnings;
68
69 use lib '..';
70
71 use Clearcase;
72 use Display;
73 use OSDep;
74
75 sub new () {
76   my ($class) = @_;
77
78 =pod
79
80 =head2 new (tag)
81
82 Construct a new Clearcase Vobs object.
83
84 Parameters:
85
86 =for html <blockquote>
87
88 =over
89
90 =item none
91
92 =back
93
94 =for html </blockquote>
95
96 Returns:
97
98 =for html <blockquote>
99
100 =over
101
102 =item Clearcase VOBs object
103
104 =back
105
106 =for html </blockquote>
107
108 =cut
109
110   my ($status, @output) = $Clearcase::CC->execute ("lsvob -short");
111
112   return if $status;
113
114   # Strip $VOBTAG_PREFIX
115   foreach (@output) {
116     if ($ARCH eq 'windows' or $ARCH eq 'cygwin') {
117       s/\\//;
118     } else {
119       s/$Clearcase::VOBTAG_PREFIX//;
120     } # if
121   } # foreach
122
123   return bless {
124     vobs => \@output
125   }, $class; # bless
126 } # new
127
128 sub vobs () {
129   my ($self) = @_;
130
131 =pod
132
133 =head3 vobs
134
135 Return a list of VOB tags in an array context or the number of vobs in
136 a scalar context.
137
138 Parameters:
139
140 =for html <blockquote>
141
142 =over
143
144 =over
145
146 =item none
147
148 =back
149
150 =back
151
152 =for html </blockquote>
153
154 Returns:
155
156 =for html <blockquote>
157
158 =over
159
160 =over
161
162 =item List of VOBs or number of VOBs
163
164 Array of VOB tags in an array context or the number of vobs in a scalar context.
165
166 =back
167
168 =back
169
170 =for html </blockquote>
171
172 =cut
173
174   if (wantarray) {
175     my @returnVobs = sort @{$self->{vobs}};
176     
177     return @returnVobs;
178   } else {
179     return scalar @{$self->{vobs}};
180   } #if
181 } # vobs
182
183 sub mount () {
184   my ($self) = @_;
185
186 =pod
187
188 =head3 mount
189
190 Mount all VOBs
191
192 Parameters:
193
194 =for html <blockquote>
195
196 =over
197
198 =over
199
200 =item none
201
202 =back
203
204 =back
205
206 =for html </blockquote>
207
208 Returns:
209
210 =for html <blockquote>
211
212 =over
213
214 =over
215
216 =item $status
217
218 Status from cleartool
219
220 =item @output
221
222 Ouput from cleartool
223
224 =back
225
226 =back
227
228 =for html </blockquote>
229
230 =cut
231
232   my ($status, @output) = $Clearcase::CC->execute ("mount -all");
233
234   return $status;
235 } # mount
236
237 sub umount () {
238   my ($self) = @_;
239
240 =pod
241
242 =head3 umount
243
244 Unmounts all VOBs
245
246 Parameters:
247
248 =for html <blockquote>
249
250 =over
251
252 =over
253
254 =item none
255
256 =back
257
258 =back
259
260 =for html </blockquote>
261
262 Returns:
263
264 =for html <blockquote>
265
266 =over
267
268 =over
269
270 =item $status
271
272 Status from cleartool
273
274 =item @output
275
276 Ouput from cleartool
277
278 =back
279
280 =back
281
282 =for html </blockquote>
283
284 =cut
285
286   my ($status, @output) = $Clearcase::CC->execute ("umount -all");
287
288   return $status;
289 } # umount
290
291 1;
292
293 =pod
294
295 =head2 DEPENDENCIES
296
297 =head3 ClearSCM Perl Modules
298
299 =for html <p><a href="/php/scm_man.php?file=lib/Clearcase.pm">Clearcase</a></p>
300
301 =for html <p><a href="/php/scm_man.php?file=lib/Display.pm">Display</a></p>
302
303 =for html <p><a href="/php/scm_man.php?file=lib/OSDep.pm">OSdep</a></p>
304
305 =head2 BUGS AND LIMITATIONS
306
307 There are no known bugs in this module
308
309 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
310
311 =head2 LICENSE AND COPYRIGHT
312
313 Copyright (c) 2007, ClearSCM, Inc. All rights reserved.
314
315 =cut