File Coverage

lib/Clearcase/Vobs.pm
Criterion Covered Total %
statement 24 32 75.0
branch 4 8 50.0
condition n/a
subroutine 6 8 75.0
pod 4 4 100.0
total 38 52 73.0


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