package MooseX::Status; use strict; our $VERSION = '0.0.1'; use Moose; use Cwd; use SVN::Agent; with qw(MooseX::Getopt); has module => ( isa => 'Str', is => 'ro', required => 1, ); has trunk => ( isa => 'Str', is => 'ro', required => 1, ); has install => ( isa => 'Bool', is => 'ro', default => 0, ); has _report => ( reader => 'report', isa => 'Str', lazy_build => 1, ); sub _build__report { my $module = $_[0]->module; my ( $day, $month, $year ) = ( localtime(time) )[ 3 ... 5 ]; $year += 1900; $month = sprintf( "%02d", ++$month ); return "reports/$module-results-$year-$month-$day.txt"; } sub run_report { my ($self) = @_; die "trunk dir doesn't exist" unless -e $self->trunk; die "trunk dir isn't a directory" unless -d _; die "trunk dir isn't readable" unless -r _; die "trunk dir isn't writable" unless -w _; my $sa = SVN::Agent->load( { path => $self->trunk } ); $sa->update; my $program_dir = cwd; chdir $self->trunk; system("perl Makefile.PL"); system("make"); system("make test TEST_VERBOSE=1 2>&1 > $program_dir/${\$self->report}"); system("make install") if $self->install; system("make distclean"); } no Moose; # unimport Moose's keywords so they won't accidentally become methods 1; # Magic true value required at end of module __END__