<commit_before>package App::KADR::Config;
use Class::Load qw(load_optional_class);
use File::HomeDir;
use List::MoreUtils qw(all);
use Moose;
use Moose::Util::TypeConstraints;

use App::KADR::Path 'dir';

with qw(MooseX::Getopt MooseX::SimpleConfig);

my $appdir = dir(File::HomeDir->my_home)->subdir('.kadr');

subtype 'Collator', as 'CodeRef';
coerce 'Collator', from 'Str', via {
	if ($_ eq 'auto') {
		$_ = load_optional_class('Unicode::Collate') ? 'unicode-i' : 'ascii-i';
	}

	return sub { $_[0] } if $_ eq 'none';
	return sub { [ sort @{ $_[0] } ] } if $_ eq 'ascii';
	return sub { [ sort { lc($a) cmp lc($b) } @{ $_[0] } ] } if $_ eq 'ascii-i';
	if ($_ eq 'unicode-i') {
		require Unicode::Collate;
		my $collator = Unicode::Collate->new(level => 1, normalize => undef);
		return sub { [ $collator->sort(@{ $_[0] }) ] };
	}
};
MooseX::Getopt::OptionTypeMap->add_option_type_to_map(
	'Collator' => '=s'
);

subtype 'ExistingDir' => as class_type('App::KADR::Path::Dir') => where { -d $_ };
coerce 'ExistingDir' => from 'Str' => via { dir($_)->absolute };

subtype 'ExistingDirs', as 'ArrayRef[ExistingDir]' => where { all { -d $_ } @$_ };
coerce 'ExistingDirs', from 'ArrayRef', via { [map { dir($_)->absolute } @$_] };

subtype 'FileTemplate', as 'Str', where { !/\n/ };
coerce 'FileTemplate', from 'Str', via { s/[\r\n]//g; $_ };<commit_msg>collator: Remove ascii option, remove -i from insensitive variants<commit_after>package App::KADR::Config;
use Class::Load qw(load_optional_class);
use File::HomeDir;
use List::MoreUtils qw(all);
use Moose;
use Moose::Util::TypeConstraints;

use App::KADR::Path 'dir';

with qw(MooseX::Getopt MooseX::SimpleConfig);

my $appdir = dir(File::HomeDir->my_home)->subdir('.kadr');

subtype 'Collator', as 'CodeRef';
coerce 'Collator', from 'Str', via {
	if ($_ eq 'auto') {
		$_ = load_optional_class('Unicode::Collate') ? 'unicode' : 'ascii';
	}

	return sub { $_[0] } if $_ eq 'none';
	return sub { [ sort { lc($a) cmp lc($b) } @{ $_[0] } ] } if $_ eq 'ascii';
	if ($_ eq 'unicode') {
		require Unicode::Collate;
		my $collator = Unicode::Collate->new(level => 1, normalize => undef);
		return sub { [ $collator->sort(@{ $_[0] }) ] };
	}
};
MooseX::Getopt::OptionTypeMap->add_option_type_to_map(
	'Collator' => '=s'
);

subtype 'ExistingDir' => as class_type('App::KADR::Path::Dir') => where { -d $_ };
coerce 'ExistingDir' => from 'Str' => via { dir($_)->absolute };

subtype 'ExistingDirs', as 'ArrayRef[ExistingDir]' => where { all { -d $_ } @$_ };
coerce 'ExistingDirs', from 'ArrayRef', via { [map { dir($_)->absolute } @$_] };

subtype 'FileTemplate', as 'Str', where { !/\n/ };
coerce 'FileTemplate', from 'Str', via { s/[\r\n]//g; $_ };
{'fraction_non_alphanumeric': 0.2211073950204385, 'fraction_numerical': 0.0033444816053511705, 'mean_word_length': 4.968957871396896, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '6400408', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1025, 'n_words': 235}