File Coverage

lib/Clearcase/UCM/Component.pm
Criterion Covered Total %
statement 9 33 27.2
branch 0 6 0.0
condition n/a
subroutine 3 9 33.3
pod 6 6 100.0
total 18 54 33.3


line stmt bran cond sub pod time code
1              
2             =pod
3              
4             =head1 NAME Component.pm
5              
6             Object oriented interface to UCM Component
7              
8             =head1 VERSION
9              
10             =over
11              
12             =item Author
13              
14             Andrew DeFaria
15              
16             =item Revision
17              
18             $Revision: 1.8 $
19              
20             =item Created
21              
22             Fri May 14 18:16:16 PDT 2010
23              
24             =item Modified
25              
26             $Date: 2011/11/15 02:00:58 $
27              
28             =back
29              
30             =head1 SYNOPSIS
31              
32             Provides access to information about Clearcase Components.
33              
34             my $stream = new Clearcase::UCM::Component($name, $pvob);
35              
36             =head1 DESCRIPTION
37              
38             This module implements a UCM Component object
39              
40             =head1 ROUTINES
41              
42             The following routines are exported:
43              
44             =cut
45              
46             package Clearcase::UCM::Component;
47              
48 1     1   865 use strict;
  1         2  
  1         27  
49 1     1   4 use warnings;
  1         2  
  1         32  
50              
51 1     1   3 use Carp;
  1         2  
  1         450  
52              
53             sub new ($$) {
54 0     0 1   my ($class, $name, $pvob) = @_;
55              
56             =pod
57              
58             =head2 new
59              
60             Construct a new Clearcase Component object.
61              
62             Parameters:
63              
64             =for html
65              
66             =over
67              
68             =item name
69              
70             Name of Component
71              
72             =item pvob
73              
74             Associated pvob
75              
76             =back
77              
78             =for html
79              
80             Returns:
81              
82             =for html
83              
84             =over
85              
86             =item Clearcase Component object
87              
88             =back
89              
90             =for html
91              
92             =cut
93              
94 0           $class = bless {
95             name => $name,
96             pvob => $pvob,
97             },
98             $class; # bless
99              
100 0           return $class;
101             } # new
102              
103             sub name () {
104 0     0 1   my ($self) = @_;
105              
106             =pod
107              
108             =head2 name
109              
110             Returns the name of the component
111              
112             Parameters:
113              
114             =for html
115              
116             =over
117              
118             =item none
119              
120             =back
121              
122             =for html
123              
124             Returns:
125              
126             =for html
127              
128             =over
129              
130             =item name
131              
132             =back
133              
134             =for html
135              
136             =cut
137              
138 0           return $self->{name};
139             } # name
140              
141             sub pvob () {
142 0     0 1   my ($self) = @_;
143              
144             =pod
145              
146             =head2 pvob
147              
148             Returns the pvob of the component
149              
150             Parameters:
151              
152             =for html
153              
154             =over
155              
156             =item none
157              
158             =back
159              
160             =for html
161              
162             Returns:
163              
164             =for html
165              
166             =over
167              
168             =item pvob
169              
170             =back
171              
172             =for html
173              
174             =cut
175              
176 0           return $self->{pvob};
177             } # pvob
178              
179             sub create (;$$) {
180 0     0 1   my ($self, $root, $comment) = @_;
181              
182             =pod
183              
184             =head2 create
185              
186             Creates a new UCM Component Object
187              
188             Parameters:
189              
190             =for html
191              
192             =over
193              
194             =item none
195              
196             =back
197              
198             =for html
199              
200             Returns:
201              
202             =for html
203              
204             =over
205              
206             =item $status
207              
208             Status from cleartool
209              
210             =item @output
211              
212             Ouput from cleartool
213              
214             =back
215              
216             =for html
217              
218             =cut
219              
220 0 0         return (0, ()) if $self->exists;
221              
222 0           $comment = Clearcase::setComment $comment;
223              
224 0           my $rootOpt;
225              
226 0 0         if ($root) {
227 0 0         if (-d $root) {
228 0           $self->{root} = $root;
229              
230 0           $rootOpt = "-root $root";
231             } else {
232 0           carp "Root $root not found";
233             } # if
234             } else {
235 0           $self->{root} = undef;
236              
237 0           $rootOpt = '-nroot';
238             } # if
239              
240             return $Clearcase::CC->execute (
241 0           "mkcomp $comment $rootOpt " . $self->{name} . '@' . $self->{pvob}->tag);
242             } # create
243              
244             sub remove () {
245 0     0 1   my ($self) = @_;
246              
247             =pod
248              
249             =head2 remove
250              
251             Removes UCM Component
252              
253             Parameters:
254              
255             =for html
256              
257             =over
258              
259             =back
260              
261             =for html
262              
263             Returns:
264              
265             =for html
266              
267             =over
268              
269             =item $status
270              
271             Status from cleartool
272              
273             =item @output
274              
275             Ouput from cleartool
276              
277             =back
278              
279             =for html
280              
281             =cut
282              
283 0           return $Clearcase::CC->execute (
284             'rmcomp -f ' . $self->name . '@' . $self->pvob->tag);
285             } # remove
286              
287             sub exists() {
288 0     0 1   my ($self) = @_;
289              
290             =pod
291              
292             =head3 exists
293              
294             Returns true if the component exists - false otherwise.
295              
296             Parameters:
297              
298             =for html
299              
300             =over
301              
302             =item none
303              
304             =back
305              
306             =for html
307              
308             Returns:
309              
310             =for html
311              
312             =over
313              
314             =item boolean
315              
316             =back
317              
318             =for html
319              
320             =cut
321              
322             my ($status, @output) = $Clearcase::CC->execute (
323 0           'lscomp ' . $self->{name} . '@' . $self->{pvob}->name);
324              
325 0           return !$status;
326             } # exists
327              
328             1;
329              
330             =head1 DEPENDENCIES
331              
332             =head2 Modules
333              
334             =over
335              
336             =item L
337              
338             =item L
339              
340             =item L
341              
342             =back
343              
344             =head1 INCOMPATABILITIES
345              
346             None
347              
348             =head1 BUGS AND LIMITATIONS
349              
350             There are no known bugs in this module.
351              
352             Please report problems to Andrew DeFaria .
353              
354             =head1 COPYRIGHT AND LICENSE
355              
356             Copyright (C) 2020 by Andrew@DeFaria.com
357              
358             This library is free software; you can redistribute it and/or modify
359             it under the same terms as Perl itself, either Perl version 5.38.0 or,
360             at your option, any later version of Perl 5 you may have available.
361              
362             =cut