<commit_before>package CoGe::Accessory::Workflow;
use strict;
use warnings;
use 5.10.0;

use Moose;

# Attributes
has 'id' => (
    is       => 'ro',
);

has 'name' => (
    is       => 'ro',
    isa      => 'Str',
    required => 1,
    default  => "",
);

has 'priority' => (
    is       => 'ro',
    isa      => 'Int',
    default  => 0,
);

has 'logfile' => (
    is       => 'rw',
    default  => "",
);

has 'jobs' => (
    is       => 'rw',
    isa      => 'ArrayRef',
    default  => sub { [] },
    required => 0,
);

# Public functions
sub add_job {
    my ( $self, %opts ) = @_;
    my $cmd         = $opts{cmd};
    my $script      = "" unless defined( $opts{script} );
    my $args        = $opts{args};
    my $inputs      = $opts{inputs};
    my $options     = $opts{options};
    my $outputs     = $opts{outputs};
    my $description = $opts{description};
    my $size        = $self->jobs;
    my $overwrite;

    # Set default
    $options //= {};

    if ( defined( $opts{overwrite} ) && $opts{overwrite} > 0 ) {
        $overwrite = 1;
    }
    else {
        $overwrite = 0;
    }

    push(
        @{ $self->jobs },
        {
            cmd         => $cmd,
            options     => $options,
            script      => $script,
            args        => $args,
            description => $description,
            overwrite   => $overwrite,
            inputs      => $inputs,
            outputs     => $outputs,
        }
    );

    return scalar( $self->jobs() ) > $size;
}

__PACKAGE__->meta->make_immutable;
no Moose;
1;
__END__
<commit_msg>Set defaults for jobs missing fields<commit_after>package CoGe::Accessory::Workflow;
use strict;
use warnings;
use 5.10.0;

use Moose;

# Attributes
has 'id' => (
    is       => 'ro',
);

has 'name' => (
    is       => 'ro',
    isa      => 'Str',
    required => 1,
    default  => "",
);

has 'priority' => (
    is       => 'ro',
    isa      => 'Int',
    default  => 0,
);

has 'logfile' => (
    is       => 'rw',
    default  => "",
);

has 'jobs' => (
    is       => 'rw',
    isa      => 'ArrayRef',
    default  => sub { [] },
    required => 0,
);

# Public functions
sub add_job {
    my ( $self, %opts ) = @_;
    my $cmd         = $opts{cmd};
    my $script      = "" unless defined( $opts{script} );
    my $args        = $opts{args} || [];
    my $inputs      = $opts{inputs} || [];
    my $options     = $opts{options};
    my $outputs     = $opts{outputs} || [];
    my $description = $opts{description};
    my $size        = $self->jobs;
    my $overwrite;

    # Set default
    $options //= {};

    if ( defined( $opts{overwrite} ) && $opts{overwrite} > 0 ) {
        $overwrite = 1;
    }
    else {
        $overwrite = 0;
    }

    push(
        @{ $self->jobs },
        {
            cmd         => $cmd,
            options     => $options,
            script      => $script,
            args        => $args,
            description => $description,
            overwrite   => $overwrite,
            inputs      => $inputs,
            outputs     => $outputs,
        }
    );

    return scalar( $self->jobs() ) > $size;
}

__PACKAGE__->meta->make_immutable;
no Moose;
1;
__END__

{'fraction_non_alphanumeric': 0.17464788732394365, 'fraction_numerical': 0.006885758998435055, 'mean_word_length': 1.5691318327974277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6953259', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1059, 'n_words': 249}