<commit_before>package DCAPI::Activation;

use strict;
use warnings;

use Mo qw/default build builder is required option/;

has api => ( is => 'ro', required => 1 );

has sketch => ( is => 'ro', required => 1 );
has environment => ( is => 'ro', required => 1 );
has bundle => ( is => 'ro', required => 1 );
has params => ( is => 'ro', required => 1 );
has metadata => ( is => 'ro', required => 1 );
has prefix => ( is => 'ro', required => 0, default => '' );
has compositions => ( is => 'ro', required => 1, default => [] );
has id => ( is => 'ro', required => 1 );

our $activation_position = 1;

sub make_activation
{
    my $api    = shift;
    my $sketch = shift;
    my $spec   = shift;

    if (ref $spec ne 'HASH')
    {
        return (undef, "Invalid activate spec under $sketch");
    }

    my $env = $spec->{environment} || '--environment not given (NULL)--';

    unless (exists $api->environments()->{$env})
    {
        return (undef, "Invalid activation environment '$env'");
    }

    my $activation_prefix  = $spec->{identifier} || '';

    my $compositions = $spec->{compositions} || [];

    if (ref $compositions ne 'ARRAY')
    {
        return (undef, "Invalid compositions parameter");
    }

    my $metadata = $spec->{metadata} || {};

    if (ref $metadata ne 'HASH')
    {
        return (undef, "Invalid metadata parameter");
    }

    my $found;
    my @repos;
    my $target = glob($spec->{target});
    foreach my $repo (map { $api->load_repo($_) } @{$api->repos()})
    {
        if ($target)
        {
            next if $target ne $repo->location();
        }

        push @repos, $repo;
    }

    $api->log4("Activation of sketch %s will be done against candidate repos %s",
               $sketch,
               \@repos);<commit_msg>cf-dc-api.pl: another logging fix<commit_after>package DCAPI::Activation;

use strict;
use warnings;

use Mo qw/default build builder is required option/;

has api => ( is => 'ro', required => 1 );

has sketch => ( is => 'ro', required => 1 );
has environment => ( is => 'ro', required => 1 );
has bundle => ( is => 'ro', required => 1 );
has params => ( is => 'ro', required => 1 );
has metadata => ( is => 'ro', required => 1 );
has prefix => ( is => 'ro', required => 0, default => '' );
has compositions => ( is => 'ro', required => 1, default => [] );
has id => ( is => 'ro', required => 1 );

our $activation_position = 1;

sub make_activation
{
    my $api    = shift;
    my $sketch = shift;
    my $spec   = shift;

    if (ref $spec ne 'HASH')
    {
        return (undef, "Invalid activate spec under $sketch");
    }

    my $env = $spec->{environment} || '--environment not given (NULL)--';

    unless (exists $api->environments()->{$env})
    {
        return (undef, "Invalid activation environment '$env'");
    }

    my $activation_prefix  = $spec->{identifier} || '';

    my $compositions = $spec->{compositions} || [];

    if (ref $compositions ne 'ARRAY')
    {
        return (undef, "Invalid compositions parameter");
    }

    my $metadata = $spec->{metadata} || {};

    if (ref $metadata ne 'HASH')
    {
        return (undef, "Invalid metadata parameter");
    }

    my $found;
    my @repos;
    my $target = glob($spec->{target});
    foreach my $repo (map { $api->load_repo($_) } @{$api->repos()})
    {
        if ($target)
        {
            next if $target ne $repo->location();
        }

        push @repos, $repo;
    }

    $api->log4("Activation of sketch %s will be done against candidate repos %s",
               $sketch,
               [@repos]);
{'fraction_non_alphanumeric': 0.18321678321678322, 'fraction_numerical': 0.006153846153846154, 'mean_word_length': 2.5058823529411764, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 83, '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': '2392380', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1084, 'n_words': 356}