Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 183 lines (129 sloc) 5.04 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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
#!/usr/bin/perl
use strict;
$|++;

my $VERSION = '0.51';

#----------------------------------------------------------------------------

=head1 NAME

cpanstats-writepages - script to create the CPAN Testers Statistics website.

=head1 SYNOPSIS

perl cpanstats-writepages

=head1 DESCRIPTION

Using the cpanstats database, extracts all the data into the components of
each page. Then creates each HTML page for the site.

=cut

# -------------------------------------
# Library Modules

use lib qw(./lib ../lib);

use Getopt::ArgvFile default=>1;
use Getopt::Long;

use CPAN::Testers::WWW::Statistics;

# -------------------------------------
# Variables

my (%options);

# -------------------------------------
# Program

init_options();

my $stats = CPAN::Testers::WWW::Statistics->new(
        config => $options{config},
        directory => $options{directory},
        templates => $options{templates},
        address => $options{address},
        logfile => $options{logfile},
        logclean => $options{logclean}
);

if($options{all}) { $stats->make_pages(); }
else {
    if($options{basics}) { $stats->make_basics(); }
    if($options{update}) { $stats->update(); }
    if($options{matrix}) { $stats->make_matrix(); }
    if($options{stats}) { $stats->make_stats(); }
    if($options{leader}) { $stats->make_leaders(); }
}

# -------------------------------------
# Subroutines

=head1 FUNCTIONS

=over 4

=item init_options

Prepare command line options

=cut

sub init_options {
    GetOptions( \%options,
        'config=s',
        'templates=s',
        'directory=s',
        'address|a=s',

        'logfile=s',
        'logclean=i',
        
        'all',
        'basics|b',
        'update|u',
        'matrix|m',
        'stats|s',
'leader|l',
        
        'help|h',
        'version|v'
    ) or help(1);

    help(1) if($options{help});
    help(0) if($options{version});

    $options{all} = 1
        unless($options{basics} || $options{update} || $options{matrix} || $options{stats} || $options{leader});
}

sub help {
    my $full = shift;

    if($full) {
        print "\n";
        print "Usage:$0 --config=<file> \\\n";
        print " [--templates=<dir>] \\\n";
        print " [--directory=<dir>] \\\n";
        print " [--address|a=<file>] \\\n";
        print " [--logfile=<file> [--logclean=<1|0>]] \\\n";
        print " [--all] [--basics] [--update] [--matrix] [--stats] \\\n";
        print " [--help|h] [--version|v] \n\n";

# 12345678901234567890123456789012345678901234567890123456789012345678901234567890
        print "This program builds the CPAN Testers Statistics website.\n";

        print "\nFunctional Options:\n";
        print " [--config=<file>] # path to config file [required]\n";
        print " [--templates=<dir>] # path to templates\n";
        print " [--directory=<dir>] # path to website directory\n";
        print " [--address=<file>] # path to address file\n";
        print " [--logfile=<file>] # path to logfile\n";
        print " [--logclean] # overwrite log if specified\n";

        print "\nRun Mode Options:\n";
        print " [--all] # all modes [default if no modes given]\n";
        print " [--basics] # create basic stats pages\n";
        print " [--update] # update data store\n";
        print " [--matrix] # create matrix style pages\n";
        print " [--stats] # create stats style pages\n";
        print " [--leader] # create leaderboard pages\n";

        print "\nOther Options:\n";
        print " [--version] # program version\n";
        print " [--help] # this screen\n";

        print "\nFor further information type 'perldoc $0'\n";
    }

    print "$0 v$VERSION\n";
    exit(0);
}

__END__

=back

=head1 BUGS, PATCHES & FIXES

There are no known bugs at the time of this release. However, if you spot a
bug or are experiencing difficulties, that is not explained within the POD
documentation, please send bug reports and patches to the RT Queue (see below).

Fixes are dependent upon their severity and my availability. Should a fix not
be forthcoming, please feel free to (politely) remind me.

RT Queue -
http://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Testers-WWW-Statistics

=head1 SEE ALSO

L<CPAN::Testers::Data::Generator>,
L<CPAN::Testers::WWW::Reports>,

F<http://www.cpantesters.org/>,
F<http://stats.cpantesters.org/>,
F<http://wiki.cpantesters.org/>

=head1 AUTHOR

Barbie, <barbie@cpan.org>
for Miss Barbell Productions <http://www.missbarbell.co.uk>.

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2005-2012 Barbie for Miss Barbell Productions.

This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

=cut
Something went wrong with that request. Please try again.