Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |