terceiro / egypt

DEPRECATED. See analizo insted

This URL has Read+Write access

egypt / egypt-metrics
100755 106 lines (65 sloc) 2.253 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/perl
 
use Getopt::Euclid;
 
=head1 NAME
 
egypt metrics - egypt's metric reporting tool
 
=head1 SYNOPSIS
 
egypt metrics [options] [<input> ...]
 
=head1 DESCRIPTION
 
egypt metrics analyzes source code in the directories passed as arguments and
procudes a matrics report. Such report is written to the standard output in the
YAML format (see I<http://www.yaml.org/>)
 
egypt metrics is part of the egypt suite.
 
=head1 OPTIONS
 
=over
 
=item --extractor <extractor>
 
Define wich extractor method use to analise source code. Default is Doxyparse.
 
=for Euclid:
extractor.type: string, extractor =~ /\A\w+\Z/
extractor.default: 'Doxyparse'
 
When using using GCC extractor, the directories will be parsed to find files
matching *.rtl and *.expand. For info about how to generate those files, please
see Egypt::Extractor::GCC(3).
 
When using the Doxyparse extractor (default), all files matching the languages
supported by doxyparse are processed.
 
=item --help
 
Displays a help message on how to use this tool.
 
=item --list
 
Displays metric list
 
=item <input>...
 
Tells egypt which source code directory(ies) you want to parse.
 
=for Euclid:
input.type: readable
 
=item --output <file>
 
Use a file as output
 
=for Euclid:
file.type: writeable
 
=back
 
=head1 OUTPUT FORMAT
 
The output is a stream of YAML documents. The first one presents metrics for
the project as a whole. The subsequent ones present per-module metrics, and thus
there will be as many of them as there are modules in your project.
 
=head1 COPYRIGHT AND AUTHORS
 
See egypt(1)
 
=cut
 
use strict;
 
use Egypt::Extractor;
use Egypt::Metrics;
 
 
if($ARGV{'--list'}){
    my $metrics_handler = new Egypt::Metrics(model => new Egypt::Model);
    my %metrics = $metrics_handler->list_of_metrics();
    foreach my $key (sort keys %metrics){
        print "$key - $metrics{$key}\n";
    }
    exit(0);
}
 
if($ARGV{'<input>'} =~ /^\s*$/){
    printf("%s: No input files!\n", 'egypt metrics');
    exit(0);
}
 
my $extractor = Egypt::Extractor->load($ARGV{'--extractor'});
my $metrics = Egypt::Metrics->new(model => $extractor->model);
 
$extractor->process(@{$ARGV{'<input>'}});
 
open STDOUT, '>', $ARGV{'--output'} if $ARGV{'--output'};
print $metrics->report;
close STDOUT;
 
exit(0);