| 1 | package Bio::MUST::Apps::Debrief42; | ||
| 2 | # ABSTRACT: Main class for debrief-42 tool | ||
| 3 | # CONTRIBUTOR: Mick VAN VLIERBERGHE <mvanvlierberghe@doct.uliege.be> | ||
| 4 | $Bio::MUST::Apps::Debrief42::VERSION = '0.262780'; | ||
| 5 | use Moose; | ||
| 6 | use namespace::autoclean; | ||
| 7 | |||
| 8 | use autodie; | ||
| 9 | use feature qw(say); | ||
| 10 | |||
| 11 | use Smart::Comments; | ||
| 12 | |||
| 13 | use Carp; | ||
| 14 | |||
| 15 | use Bio::MUST::Core; | ||
| 16 | use aliased 'Bio::MUST::Apps::Debrief42::RunReport'; | ||
| 17 | |||
| 18 | |||
| 19 | has 'report_dir' => ( | ||
| 20 | is => 'ro', | ||
| 21 | isa => 'Str', | ||
| 22 | required => 1, | ||
| 23 | ); | ||
| 24 | |||
| 25 | |||
| 26 | has 'config' => ( | ||
| 27 | traits => ['Hash'], | ||
| 28 | is => 'ro', | ||
| 29 | isa => 'HashRef', | ||
| 30 | required => 1, | ||
| 31 | handles => { | ||
| 32 | args_for => 'get', | ||
| 33 | }, | ||
| 34 | ); | ||
| 35 | |||
| 36 | |||
| 37 | sub run_report { | ||
| 38 | my $self = shift; | ||
| 39 | my $args = shift // {}; # HashRef (should not be empty...) | ||
| 40 | |||
| 41 | # load config file (42's YAML) | ||
| 42 | my @orgs = map { $_->{'org'} } @{ $self->args_for('orgs') }; | ||
| 43 | |||
| 44 | my @tax_report_files = File::Find::Rule | ||
| 45 | ->file() | ||
| 46 | ->name( qr{ \.tax-report\z }xmsi ) | ||
| 47 | ->maxdepth(1) | ||
| 48 | ->in( $self->report_dir ) | ||
| 49 | ; | ||
| 50 | |||
| 51 | return RunReport->new( orgs => \@orgs, tax_reports => \@tax_report_files ); | ||
| 52 | } | ||
| 53 | |||
| 54 | |||
| 55 | __PACKAGE__->meta->make_immutable; | ||
| 56 | 1; | ||
| 57 | |||
| 58 | __END__ |