package Daje::Plugin::Output::Table;
use Mojo::Base  -base, -signatures;

use Mojo::File;

our $VERSION = "0.01";

has 'config' ;
has 'file';
has 'sql';

sub save_file($self) {

    my $filename = $self->create_new_filename();
    open (my $fh, ">", $filename) or die "Could not open file '$filename";
    print $fh $self->sql();
    close $fh;

    return;
}

sub create_new_filename($self) {
    my $filename;
    eval {
        $filename = $self->config->{PATH}->{sql_target_dir} . Mojo::File->new($self->file)->basename();
        $filename =~ s/json/sql/ig;
    };
    die "create_new_filename failed '$@'" if $@;

    return $filename;
}
1;

#################### pod generated by Pod::Autopod - keep this line to make pod updates possible ####################

=head1 NAME

Daje::Plugin::Output::Table


=head1 DESCRIPTION

pod generated by Pod::Autopod - keep this line to make pod updates possible ####################


=head1 REQUIRES

L<Mojo::File> 

L<Mojo::Base> 


=head1 METHODS

=head2 create_new_filename($self)

 create_new_filename($self)();

=head2 save_file($self)

 save_file($self)();


=cut

