File Coverage

blib/lib/UML/Sequence/PerlOOSeq.pm
Criterion Covered Total %
statement 28 33 84.8
branch 2 6 33.3
condition n/a
subroutine 8 9 88.8
pod 0 3 0.0
total 38 51 74.5


line stmt bran cond sub pod time code
1             package UML::Sequence::PerlOOSeq;
2 1     1   20231 use strict;
  1         3  
  1         31  
3 1     1   4 use warnings;
  1         2  
  1         25  
4              
5             =head1 NAME
6              
7             UML::Sequence::PerlOOSeq - helper for genericseq.pl showing object instances
8              
9             =head1 SYNOPSIS
10              
11             genericseq.pl UML::Sequence::PerlOOSeq methods_file perl_program [args...] > sequence.xml
12             seq2svg.pl sequence.xml > sequence.svg
13              
14             OR
15              
16             genericseq.pl UML::Sequence::PerlOOSeq methods_file program [args...] | seq2svg.pl > sequence.svg
17              
18             =cut
19              
20 1     1   4 use strict;
  1         1  
  1         30  
21 1     1   4 use warnings;
  1         2  
  1         337  
22              
23             our $VERSION = "0.02";
24              
25             my $methods_file;
26              
27             =head1 grab_outline_text
28              
29             Call this method first. Call it through the class
30             (UML::Sequence::PerlOOSeq->grab_outline_text)
31             passing it the methods_file, the program to run, and any args for that program.
32             Returns an outline (suitable for printing or passing on to UML::Sequence).
33              
34             =cut
35             sub grab_outline_text {
36 1     1 0 11 shift; # discard class name
37 1         2 $methods_file = shift;
38 1         5 _profile(@_);
39 1         41 return _read_tmon();
40             }
41              
42             sub _profile {
43 1     1   18691 `perl -d:OOCallSeq @_`;
44             }
45              
46             sub _read_tmon {
47 1     1   9 my @retval;
48 1 50       84 open TMON, "tmon.out" or die "Couldn't run under Devel::OOCallSeq $!\n";
49 1         39 while () {
50 9         13 chomp;
51 9         52 push @retval, $_;
52             }
53 1         27 return \@retval;
54             }
55              
56             =head1 grab_methods
57              
58             Call this only after you have called grab_outline. Call it through the class:
59             PerlSeq->grab_methods. Arguments are ignored.
60             Returns a reference to an array listing the methods of interest.
61              
62             =cut
63              
64             sub grab_methods {
65 1     1 0 1755 shift; # discard class
66              
67 1 50       77 open METHODS, "$methods_file" or die "Couldn't open $methods_file\n";
68 1         42 chomp(my @methods = );
69 1         15 close METHODS;
70              
71 1         9 return \@methods;
72             }
73              
74             =head1 parse_signature
75              
76             Pass a reference to this method to the SeqOutline constructor. It must
77             accept a method signature and return the class name (in scalar context) or
78             the class and method names in that order (in list context).
79              
80             =cut
81              
82             sub parse_signature {
83 0     0 0   my $signature = shift;
84 0           my $class = $signature;
85 0           $class =~ s/::([^:]+)$//;
86 0           my $method = $1;
87              
88 0 0         return wantarray ? ($class, $method) : $class;
89             }
90              
91             1;