line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Metrics::Metric; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Perl::Metrics::Metric - A Perl Document Metric |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This class provides objects that represent a single metric on a single |
12
|
|
|
|
|
|
|
document (although that document might actual exist as a number of |
13
|
|
|
|
|
|
|
duplicate files in the index). |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 METHODS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
In addition to the general methods provided by L, this class has |
18
|
|
|
|
|
|
|
the following additional methods. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
6
|
|
|
6
|
|
35
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
228
|
|
23
|
6
|
|
|
6
|
|
35
|
use Perl::Metrics (); |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
103
|
|
24
|
6
|
|
|
6
|
|
27
|
use base 'Perl::Metrics::CDBI'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
504
|
|
25
|
|
|
|
|
|
|
|
26
|
6
|
|
|
6
|
|
35
|
use vars qw{$VERSION}; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
280
|
|
27
|
|
|
|
|
|
|
BEGIN { |
28
|
6
|
|
|
6
|
|
1040
|
$VERSION = '0.09'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=pod |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 hex_id |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
In the L system all documents are identified by the |
36
|
|
|
|
|
|
|
hexidecimal MD5 value for their newline-localized contents. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
The C accessor returns this id for the document that the metric |
39
|
|
|
|
|
|
|
is for. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 package |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
The C returns a string which contains the class name of the metrics |
44
|
|
|
|
|
|
|
package that generated the metric. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 name |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
The C accessor returns the name of the metric. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This name is package-specific. That is, a metric with a package of |
51
|
|
|
|
|
|
|
'Foo' and name 'some_metric' is different to a metric with package |
52
|
|
|
|
|
|
|
'Bar' and the same name 'some_metric'. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
The metric name itself must be a valid Perl identifier. This test is |
55
|
|
|
|
|
|
|
done using the C<_IDENTIFIER> function from L. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 version |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
In L some metrics packages will produce metrics that are |
60
|
|
|
|
|
|
|
"version-unstable". In other words, if the metrics package is upgraded, |
61
|
|
|
|
|
|
|
the metrics need to be recalculated. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
The C accessor returns the version of the metrics package at the |
64
|
|
|
|
|
|
|
time the metric was calculated. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 value |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The C accessor returns the value of the accessor. This could be |
69
|
|
|
|
|
|
|
a number, word, or anything else. Please note that a value of C, |
70
|
|
|
|
|
|
|
does B mean the lack of a metric, but rather it means "unknown" |
71
|
|
|
|
|
|
|
or "indeterminate" or has some other signficant meaning (in the context |
72
|
|
|
|
|
|
|
of the metrics package). |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Perl::Metrics::Metric->table( 'metrics' ); |
77
|
|
|
|
|
|
|
Perl::Metrics::Metric->columns( Primary => |
78
|
|
|
|
|
|
|
'hex_id', # Document MD5 Identifier - 'abcdef1234567890' |
79
|
|
|
|
|
|
|
'package', # Metrics Package Class Name - 'Perl::Metrics::Plugin::Core' |
80
|
|
|
|
|
|
|
'name', # Package Metric Name - 'tokens' |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
Perl::Metrics::Metric->columns( Essential => |
83
|
|
|
|
|
|
|
'hex_id', |
84
|
|
|
|
|
|
|
'package', |
85
|
|
|
|
|
|
|
'name', |
86
|
|
|
|
|
|
|
'version', # Metrics Package Version - '1.04' |
87
|
|
|
|
|
|
|
'value', # Metric Value - '17', undef, 'Foo', '1.234' |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=pod |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 files @conditions |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Because metrics are stored based on a document identifier rather than |
95
|
|
|
|
|
|
|
by file name, if there are duplicate files indexed, one set of metrics |
96
|
|
|
|
|
|
|
may related to more than one file. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The C accessor searchs for all indexed C<::File> objects that have a |
99
|
|
|
|
|
|
|
matching C to the C<::Metric> object. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub files { |
104
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Apply default search options to those passed |
107
|
0
|
|
|
|
|
|
my @params = ( hex_id => $self->hex_id, @_ ); |
108
|
0
|
0
|
|
|
|
|
unless ( ref($params[-1]) eq 'HASH' ) { |
109
|
|
|
|
|
|
|
# Add standard ordering |
110
|
0
|
|
|
|
|
|
push @params, { order_by => 'file' }; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# Execute the search |
114
|
0
|
|
|
|
|
|
Perl::Metrics::File->search( @params ); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=pod |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 SUPPORT |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Bugs should be reported via the CPAN bug tracker at |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
L |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
For other issues, contact the author. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 AUTHOR |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Adam Kennedy Eadamk@cpan.orgE |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SEE ALSO |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L, L |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 COPYRIGHT |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Copyright 2005 - 2008 Adam Kennedy. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This program is free software; you can redistribute |
142
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
The full text of the license can be found in the |
145
|
|
|
|
|
|
|
LICENSE file included with this module. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |