blib/lib/UML/Sequence/PerlSeq.pm

filter: Statementstmt 86.4% 32 / 37 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 3 totaltotal 77.1% 44 / 57 CC 5 SCAR 8.7
CC
5
Cov
80%
parse_signature
6.0
_read_tmon
3.0
grab_methods
2.0
CRAP 2.4
« blib/lib/UML/Sequence/PerlOOSeq.pm ↑ Summary blib/lib/UML/genericseq.pl »
1 package UML::Sequence::PerlSeq;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head1 NAME
6  
7 UML::Sequence::PerlSeq - for use with genericseq.pl script, works on Perl programs
8  
9 =head1 SYNOPSIS
10  
11 genericseq.pl UML::Sequence::PerlSeq methods_file perl_program [args...] > sequence.xml
12 seq2svg.pl sequence.xml > sequence.svg
13  
14 OR
15  
16 genericseq.pl UML::Sequence::PerlSeq methods_file program [args...] | seq2svg.pl > sequence.svg
17  
18 =head1 DESCRIPTION
19  
20 This file must be used by a script. On demand it will form an outline by
21 running the supplied program with -d:UML::CallSeq which is included in
22 the UML::Sequence distribution. This has been developed on
23 Cygwin under Windows 2000 and tested on Red Hat Linux 7.1.
24  
25 The methods file should list methods you WANT to hear about. If it isn't
26 in the list, it will not appear in the picture. The format of the file
27 is like this:
28  
29 DiePair::new
30 Die::new
31 DiePair::roll
32 Die::roll
33 DiePair::total
34 DiePair::doubles
35 DiePair::to_string
36  
37 Order is not important.
38  
39 =cut
40  
41 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 1 our $VERSION = "0.02";
45  
46 1 my $methods_file;
47  
48 =head1 grab_outline_text
49  
50 Call this method first. Call it through the class
51 (UML::Sequence::PerlSeq->grab_outline_text)
52 passing it the methods_file, the program to run, and any args for that program.
53 Returns an outline (suitable for printing or passing on to SeqOutline).
54  
55 =cut
56 1 ▶sub grab_outline_text {
Subroutine grab_outline_text: called CC=1 SCAR=0.0
Pod undocumented
57 1 shift; # discard class name
58 1 $methods_file = shift;
59 1 _profile(@_);
60 1 return _read_tmon();
61 }
62  
63 1 ▶sub _profile {
Subroutine _profile: called CC=1 SCAR=0.0
64 1 `perl -d:CallSeq @_`;
65 }
66  
67 1 ▶sub _read_tmon {
Subroutine _read_tmon: called CC=3 SCAR=11.0
68 1 my @retval;
69 1 ▶ open TMON, "tmon.out" or die "Couldn't read tmon.out from Devel::CallSeq\n";
Branch: 1 branch
BranchTrueFalseTotal
open TMON, "tmon.out" or die "Couldn't read tmon.out from Devel::CallSeq\n" 1 0 1
70 1 ▶ while (<TMON>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline TMON)) 10 1 11
71 10 chomp;
72 10 push @retval, $_;
73 }
74 1 unlink "tmon.out";
75 1 return \@retval;
76 }
77  
78 =head1 grab_methods
79  
80 Call this only after you have called grab_outline. Call it through the class:
81 UML::Sequence::PerlSeq->grab_methods. Arguments are ignored.
82 Returns a reference to an array listing the methods of interest.
83  
84 =cut
85  
86 1 ▶sub grab_methods {
Subroutine grab_methods: called CC=2 SCAR=7.0
Pod undocumented
87 1 shift; # discard class
88  
89 1 ▶ open METHODS, "$methods_file" or die "Couldn't open $methods_file\n";
Branch: 1 branch
BranchTrueFalseTotal
open METHODS, "$methods_file" or die "Couldn't open $methods_file\n" 1 0 1
90 1 chomp(my @methods = <METHODS>);
91 1 close METHODS;
92  
93 1 return \@methods;
94 }
95  
96 =head1 parse_signature
97  
98 Pass a reference to this method to the UML::Sequence constructor. It must
99 accept a method signature and return the class name (in scalar context) or
100 the class and method names in that order (in list context).
101  
102 =cut
103  
104 0 ▶sub parse_signature {
Subroutine parse_signature: not called CC=2 SCAR=17.9
Pod undocumented
105 0 my $signature = shift;
106 0 my $class = $signature;
107 0 $class =~ s/::([^:]+)$//;
108 0 my $method = $1;
109  
110 0 ▶ return wantarray ? ($class, $method) : $class;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
111 }
112  
113 1 1;
« blib/lib/UML/Sequence/PerlOOSeq.pm ↑ Summary blib/lib/UML/genericseq.pl »