File Coverage

lib/Clearcase/UCM/Project.pm
Criterion Covered Total %
statement 6 26 23.0
branch 0 4 0.0
condition 0 4 0.0
subroutine 2 9 22.2
pod 7 7 100.0
total 15 50 30.0


line stmt bran cond sub pod time code
1              
2             =pod
3              
4             =head1 NAME Project.pm
5              
6             Object oriented interface to UCM Projects
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 UCM Projects.
33              
34             my $project = new Clearcase::UCM::Project ($name, $folder, $pvob);
35              
36             =head1 DESCRIPTION
37              
38             This module implements a UCM Project object
39              
40             =head1 ROUTINES
41              
42             The following routines are exported:
43              
44             =cut
45              
46             package Clearcase::UCM::Project;
47              
48 1     1   934 use strict;
  1         2  
  1         28  
49 1     1   5 use warnings;
  1         1  
  1         398  
50              
51             sub new ($$) {
52 0     0 1   my ($class, $name, $folder, $pvob) = @_;
53              
54             =pod
55              
56             =head2 new
57              
58             Construct a new Clearcase Project object.
59              
60             Parameters:
61              
62             =for html
63              
64             =over
65              
66             =item project
67              
68             Name of project
69              
70             =item folder
71              
72             Folder object
73              
74             =item pvob
75              
76             Associated Pvob
77              
78             =back
79              
80             =for html
81              
82             Returns:
83              
84             =for html
85              
86             =over
87              
88             =item Clearcase Project object
89              
90             =back
91              
92             =for html
93              
94             =cut
95              
96 0 0         $folder = Clearcase::UCM::Folder->new ('RootFolder', $pvob) unless $folder;
97              
98 0           $class = bless {
99             name => $name,
100             folder => $folder,
101             pvob => $pvob,
102             },
103             $class; # bless
104              
105 0           return $class;
106             } # new
107              
108             sub name () {
109 0     0 1   my ($self) = @_;
110              
111             =pod
112              
113             =head2 name
114              
115             Returns the name of the project
116              
117             Parameters:
118              
119             =for html
120              
121             =over
122              
123             =item none
124              
125             =back
126              
127             =for html
128              
129             Returns:
130              
131             =for html
132              
133             =over
134              
135             =item project's name
136              
137             =back
138              
139             =for html
140              
141             =cut
142              
143 0           return $self->{name};
144             } # name
145              
146             sub pvob () {
147 0     0 1   my ($self) = @_;
148              
149             =pod
150              
151             =head2 pvob
152              
153             Returns the pvob of the project
154              
155             Parameters:
156              
157             =for html
158              
159             =over
160              
161             =item none
162              
163             =back
164              
165             =for html
166              
167             Returns:
168              
169             =for html
170              
171             =over
172              
173             =item project's pvob
174              
175             =back
176              
177             =for html
178              
179             =cut
180              
181 0           return $self->{pvob};
182             } # pvob
183              
184             sub create (;$) {
185 0     0 1   my ($self, $opts) = @_;
186              
187             =pod
188              
189             =head2 create
190              
191             Creates a new UCM Project Object
192              
193             Parameters:
194              
195             =for html
196              
197             =over
198              
199             =item opts
200              
201             Optional parameters for cleartool mkproject command
202              
203             =back
204              
205             =for html
206              
207             Returns:
208              
209             =for html
210              
211             =over
212              
213             =item $status
214              
215             Status from cleartool
216              
217             =item @output
218              
219             Ouput from cleartool
220              
221             =back
222              
223             =for html
224              
225             =cut
226              
227 0 0         return (0, ()) if $self->exists;
228              
229 0   0       $opts ||= '';
230              
231             return $Clearcase::CC->execute ("mkproject $opts -in "
232             . $self->{folder}->name . '@'
233             . $self->{pvob}->tag . ' '
234             . $self->{name} . '@'
235 0           . $self->{pvob}->tag);
236             } # create
237              
238             sub remove () {
239 0     0 1   my ($self) = @_;
240              
241             =pod
242              
243             =head2 remove
244              
245             Removes UCM Project
246              
247             Parameters:
248              
249             =for html
250              
251             =over
252              
253             =for html
254              
255             Returns:
256              
257             =for html
258              
259             =over
260              
261             =item $status
262              
263             Status from cleartool
264              
265             =item @output
266              
267             Ouput from cleartool
268              
269             =back
270              
271             =for html
272              
273             =cut
274              
275             return $Clearcase::CC->execute (
276 0           'rmproject -f ' . $self->{name} . "\@" . $self->{pvob}->tag);
277             } # remove
278              
279             sub change($) {
280 0     0 1   my ($self, $opts) = @_;
281              
282             =pod
283              
284             =head2 change
285              
286             Changes UCM Project
287              
288             Parameters:
289              
290             =for html
291              
292             =over
293              
294             =item opts
295              
296             Options
297              
298             =for html
299              
300             Returns:
301              
302             =for html
303              
304             =over
305              
306             =item $status
307              
308             Status from cleartool
309              
310             =item @output
311              
312             Ouput from cleartool
313              
314             =back
315              
316             =for html
317              
318             =cut
319              
320 0   0       $opts ||= '';
321              
322             return $Clearcase::CC->execute (
323 0           "chproject $opts " . $self->{name} . "\@" . $self->{pvob}->name);
324             } # change
325              
326             sub exists() {
327 0     0 1   my ($self) = @_;
328              
329             =pod
330              
331             =head3 exists
332              
333             Returns true if the project exists - false otherwise
334              
335             Parameters:
336              
337             =for html
338              
339             =over
340              
341             =item none
342              
343             =back
344              
345             =for html
346              
347             Returns:
348              
349             =for html
350              
351             =over
352              
353             =item boolean
354              
355             =back
356              
357             =for html
358              
359             =cut
360              
361             my ($status, @output) = $Clearcase::CC->execute (
362 0           'lsproject ' . $self->{name} . '@' . $self->{pvob}->name);
363              
364 0           return !$status;
365             } # exists
366              
367             1;
368              
369             =head1 DEPENDENCIES
370              
371             =head2 Modules
372              
373             =over
374              
375             =item L
376              
377             =item L
378              
379             =back
380              
381             =head1 INCOMPATABILITIES
382              
383             None
384              
385             =head1 BUGS AND LIMITATIONS
386              
387             There are no known bugs in this module.
388              
389             Please report problems to Andrew DeFaria .
390              
391             =head1 COPYRIGHT AND LICENSE
392              
393             Copyright (C) 2020 by Andrew@DeFaria.com
394              
395             This library is free software; you can redistribute it and/or modify
396             it under the same terms as Perl itself, either Perl version 5.38.0 or,
397             at your option, any later version of Perl 5 you may have available.
398              
399             =cut