Data-FeatureFactory
view release on metacpan or search on metacpan
lib/Data/FeatureFactory.pm view on Meta::CPAN
package Data::FeatureFactory;
use strict;
use Carp;
use File::Basename;
use Scalar::Util;
our $VERSION = '0.0405';
my $PATH = &{ sub { return dirname( (caller)[1] ) } };
my $OPEN_OPTIONS;
our $CURRENT_FEATURE;
my %KNOWN_FORMATS = map {;$_=>1} qw/binary normal numeric/;
# check if perl can open files in utf8
{
my $fh;
undef $@;
eval { open $fh, '<:encoding(utf8)', $0 };
if ($@) {
lib/Data/FeatureFactory.pm view on Meta::CPAN
*features = \@{$class."::features"};
use strict;
if (not @features) {
warn "$class has empty set of features. Not much fun";
}
$self->{'features'} = [];
my %feat_named;
$self->{'feat_named'} = \%feat_named;
my @featkeys;
$self->{'featkeys'} = \@featkeys;
$self->{'caller_path'} = dirname( (caller)[1] );
my %supported_option = ( map {;$_=>1} qw(code default format label name postproc range type values values_file) );
my %accepted_option = ( map {;$_=>1} qw(cat2num cat2num_dyna num2cat num2cat_dyna num_values_fh values_ordered) );
# parse the @features array
for my $original_feature (@features) {
my $feature = { %$original_feature };
if (not exists $feature->{'name'}) {
croak q{There was a feature without a name. Each record in the @features array must be a hashref with a 'name' field at least};
}
t/01-translate.t view on Meta::CPAN
#!/usr/bin/perl -w
use strict;
use warnings;
use Test::More tests => 37;
use Carp qw(verbose);
use File::Temp;
use File::Basename;
my $PATH;
BEGIN { $PATH = &{ sub { dirname ( (caller)[1] ) } }; }
use lib $PATH;
my $WARNINGS;
sub catchwarn {
my ($expected_warning, $how_many) = @_;
if (not defined $expected_warning) {
$expected_warning = qr/.*/;
}
if (not defined $how_many) {
$how_many = 1;
( run in 0.292 second using v1.01-cache-2.11-cpan-1e74a51a04c )