RSS Git Download  Clone
Raw Blame History
package Reporter;

use Reporter::Model;
use Reporter::Validation;
use Reporter::Class; # provides Moo, Modern::Perl, Local::MooX::Types & Data::Printer::p

use FindBin qw($RealBin); # warn $RealBin;
use Path::Tiny;
use Git;

my $git = Git->repository(Directory => path($RealBin, '..', '.git')->realpath);
our $VERSION = version(); # warn $VERSION;
say sprintf('>> starting Reporter v%s', $VERSION); # unless $ENV{HARNESS_ACTIVE};

has dbname => ( is => 'ro', isa => String, required => 1 ); # hilis4, test, etc
has model => (
    is => 'lazy',
    builder => sub { Reporter::Model->new( dbname => shift->dbname ) },
    handles => [ 'check_db_connection' ], # to check db handle still connected
);
has validator => ( # Data::FormValidator:
    is => 'lazy',
    builder  => sub { Reporter::Validation->new( dbname => shift->dbname ) }
);
# has logger => ( is => 'ro', required => 1 ); # how to pass this ?

sub enable_sql_trace { $ENV{SQL_TRACE} = 1 }

sub symbolise { Local::Utils::symbolise($_[1]) }

sub version { $git->command_oneline('rev-list', 'HEAD', '--count') }

sub gitlog {
    my @args = ( '--pretty=format:"%ad :: %s"', '--date=relative' );
    my @log = $git->command( 'log', @args );
    return \@log;
};

1;