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;

has dbname => ( is => 'ro', isa => String, required => 1 ); # hilis4, test, etc
has model => (
    is => 'lazy',
    builder => sub { Reporter::Model->new( dbname => shift->dbname ) }
);
has validator => ( # Data::FormValidator:
    is => 'lazy',
    builder  => sub { Reporter::Validation->new( dbname => shift->dbname ) }
);

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;