Skip to content

Commit

Permalink
new command: webstatic
Browse files Browse the repository at this point in the history
  • Loading branch information
jquelin committed Mar 30, 2012
1 parent 2f05197 commit 9ace171
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
63 changes: 63 additions & 0 deletions lib/App/Magpie/Action/WebStatic.pm
@@ -0,0 +1,63 @@
use 5.012;
use strict;
use warnings;

package App::Magpie::Action::WebStatic;
# ABSTRACT: webstatic command implementation

use File::HomeDir::PathClass qw{ my_dist_data };
use Moose;
use Path::Class;
use RRDTool::OO;

with 'App::Magpie::Role::Logging';


=method run
App::Magpie::Action::WebStatic->new->run( $opts );
Update the count of available modules in Mageia, and create a static
website with some information on them.
=cut

sub run {
my ($self, $opts) = @_;

my $dir = dir( $opts->{directory} );
$dir->rmtree; $dir->mkpath;

my $datadir = my_dist_data( "App-Magpie", { create=>1 } );
my $rrdfile = $datadir->file( "modules.rrd" );

my $rrd = RRDTool::OO->new( file=>$rrdfile );
if ( ! -f $rrdfile ) {
$rrd->create(
step => 60*60*24, # 1 measure per day
data_source => {
name => "nbmodules",
type => "GAUGE",
},
archive => { rows => 365 * 100 }, # data kept for 100 years
);
}

#$rrd->update( );
}


1;
__END__
=head1 SYNOPSIS
my $webstatic = App::Magpie::Action::WebStatic->new;
$webstatic->run;
=head1 DESCRIPTION
This module implements the C<webstatic> action. It's in a module of its
own to be able to be C<require>-d without loading all other actions.
43 changes: 43 additions & 0 deletions lib/App/Magpie/App/Command/webstatic.pm
@@ -0,0 +1,43 @@
use 5.012;
use strict;
use warnings;

package App::Magpie::App::Command::webstatic;
# ABSTRACT: create a static web site

use App::Magpie::App -command;


# -- public methods

sub description {
"This command generates a static web site with some statistics &
information on Perl modules available in Mageia Linux."
}

sub opt_spec {
my $self = shift;
return (
[],
[ 'directory|d=s' => "directory where website will be created"
=>{required=>1} ],
[],
$self->verbose_options,
);
}

sub execute {
my ($self, $opts, $args) = @_;
$self->log_init($opts);
require App::Magpie::Action::WebStatic;
App::Magpie::Action::WebStatic->new->run($opts);
}

1;
__END__
=head1 DESCRIPTION
This command generates a static web site with some statistics &
information on Perl modules available in Mageia Linux.

0 comments on commit 9ace171

Please sign in to comment.