Data-Perl-0.002009/0000755000175000017500000000000012353141421011655 5ustar mmpmmpData-Perl-0.002009/META.yml0000644000175000017500000000143512353141421013131 0ustar mmpmmp--- abstract: 'Base classes wrapping fundamental Perl data types.' author: - 'Matthew Phillips ' build_requires: Test::Deep: 0 Test::Fatal: 0 Test::Output: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 5.019, CPAN::Meta::Converter version 2.141520' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Data-Perl requires: Class::Method::Modifiers: 0 List::MoreUtils: 0 List::Util: 0 Module::Runtime: 0 Role::Tiny: 0 Scalar::Util: 0 parent: 0 strictures: 0 resources: bugtracker: https://github.com/mattp-/Data-Perl/issues homepage: https://github.com/mattp-/Data-Perl repository: https://github.com/mattp-/Data-Perl.git version: 0.002009 Data-Perl-0.002009/Makefile.PL0000644000175000017500000000274312353141421013635 0ustar mmpmmp # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.019. use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "Base classes wrapping fundamental Perl data types.", "AUTHOR" => "Matthew Phillips ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Data-Perl", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "Data::Perl", "PREREQ_PM" => { "Class::Method::Modifiers" => 0, "List::MoreUtils" => 0, "List::Util" => 0, "Module::Runtime" => 0, "Role::Tiny" => 0, "Scalar::Util" => 0, "parent" => 0, "strictures" => 0 }, "TEST_REQUIRES" => { "Test::Deep" => 0, "Test::Fatal" => 0, "Test::Output" => 0 }, "VERSION" => "0.002009", "test" => { "TESTS" => "t/*.t t/collection/*.t" } ); my %FallbackPrereqs = ( "Class::Method::Modifiers" => 0, "List::MoreUtils" => 0, "List::Util" => 0, "Module::Runtime" => 0, "Role::Tiny" => 0, "Scalar::Util" => 0, "Test::Deep" => 0, "Test::Fatal" => 0, "Test::Output" => 0, "parent" => 0, "strictures" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); Data-Perl-0.002009/README0000644000175000017500000000567512353141421012552 0ustar mmpmmpNAME Data::Perl - Base classes wrapping fundamental Perl data types. VERSION version 0.002009 SYNOPSIS use Data::Perl; my $array = array(1,2,3, qw/a b c/); $array->count; # 6 my @elements = $array->grep(sub {/b/}); # (b) my $hash = hash(a => 1, b => 2); $hash->keys; # ('a', 'b'); my $number = number(5); $number->add(10); # 15 my $string = string("foo\n"); $string->chomp; # return 1, chomps string my $counter = counter(); $counter->inc; # counter is now 1 my $sub = code(sub { 'foo' }); $sub->execute; # returns 'foo' $foo DESCRIPTION Data::Perl is a collection of classes that wrap fundamental data types that exist in Perl. These classes and methods as they exist today are an attempt to mirror functionality provided by Moose's Native Traits. One important thing to note is all classes currently do no validation on constructor input. Data::Perl is a container class for the following classes: * Data::Perl::Collection::Hash * Data::Perl::Collection::Array * Data::Perl::String * Data::Perl::Number * Data::Perl::Counter * Data::Perl::Bool * Data::Perl::Code ALPHA API The API provided by these modules is as of now considered alpha and undecided. The API WILL change. If you are writing code that you will not touch again for years, do not use this until this warning is removed. PROVIDED FUNCTIONS Data::Perl exports helper constructor functions to interface with the above classes: * hash(key, value, ...) Returns a Data::Perl::Collection::Hash object initialized with the optionally passed in key/value args. * array(@args) Returns a Data::Perl::Collection::Array object initialized with the optionally passed in values. * string($arg) Returns a Data::Perl::String object initialized with the optionally passed in scalar arg. * number($arg) Returns a Data::Perl::Number object initialized with the optionally passed in scalar arg. * counter($arg) Returns a Data::Perl::Counter object initialized with the optionally passed in scalar arg. * bool($arg) Returns a Data::Perl::Bool object initialized with the truth value of the passed in scalar arg. * code($arg) Returns a Data::Perl::Code object initialized with the optionally passed in scalar coderef as an arg. THANKS Much thanks to the Moose team for their work with native traits, for which much of this work is based. SEE ALSO * MooX::HandlesVia AUTHOR Matthew Phillips COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Data-Perl-0.002009/t/0000755000175000017500000000000012353141421012120 5ustar mmpmmpData-Perl-0.002009/t/helpers.t0000644000175000017500000000142312353141421013747 0ustar mmpmmpuse Data::Perl; use Test::More; my $array = array(qw/1 2 3 4/); isa_ok($array, 'Data::Perl::Collection::Array'); my $hash = hash(qw/1 2 3 4/); isa_ok($hash, 'Data::Perl::Collection::Hash'); my $code = code(); isa_ok($code, 'Data::Perl::Code'); my $code2 = code(sub { 'foo' }); isa_ok($code2, 'Data::Perl::Code'); my $number = number(); isa_ok($number, 'Data::Perl::Number'); $number2 = number(2); isa_ok($number2, 'Data::Perl::Number'); my $bool = bool(1); isa_ok($bool, 'Data::Perl::Bool'); my $string = string(); isa_ok($string, 'Data::Perl::String'); my $string2 = string('foo'); isa_ok($string2, 'Data::Perl::String'); my $counter = counter(); isa_ok($counter, 'Data::Perl::Counter'); my $counter2 = counter(1); isa_ok($counter2, 'Data::Perl::Counter'); done_testing(); Data-Perl-0.002009/t/number.t0000644000175000017500000000074312353141421013601 0ustar mmpmmpuse Test::More; use Data::Perl; use strict; # constructor is ref(number(1)), 'Data::Perl::Number', 'constructor shortcut works'; my $c = number(5); is $$c, 5, 'nondefault set works'; # add $c->add(5); is $$c, 10, 'add works'; # sub $c->sub(5); is $$c, 5, 'sub works'; # mul $c->mul(6); is $$c, 30, 'mul works'; # div $c->div(7); is $$c, 30/7, 'div works'; # mod $$c = 12; $c->mod(5); is $$c, 2, 'mod works'; $$c = -5; # abs $c->abs; is $$c, 5, 'abs works'; done_testing(); Data-Perl-0.002009/t/string.t0000644000175000017500000000252412353141421013616 0ustar mmpmmpuse Test::More; use Data::Perl; use strict; # constructor is ref(string('a')), 'Data::Perl::String', 'constructor shortcut works'; my $c = string('a'); is $$c, 'a', 'nondefault set works'; $c->inc; is $$c, 'b', 'inc works'; $c = string(123); is $$c, '123', 'nondefault set with number works'; # append $c->append('z'); is $$c, '123z', 'append works'; # prepend $c->prepend('a'); is $$c, 'a123z', 'prepend works'; # replace $c->replace(qr/2/, 'e'); is $$c, 'a1e3z', 'replace works'; $c->replace('3', sub { ok 1, 'sub called in regex replace'; 'r'}); is $$c, 'a1erz', 'replace works'; # match $c = string('5555'); ok $c->match(qr/5/), 'match works'; # chop $c->chop; is $$c, '555', 'chop works'; # chomp $c = string("foo\n\n\n"); is $c->chomp, 1, 'chomp works'; # clear $c->clear; is $$c, '', 'clear works'; # length $c = string("12345"); is $c->length, 5, 'length works'; # substr my $s = string("The black cat climbed the green tree"); is $s->substr(4, 5), 'black', 'substr 1'; is $s->substr(4, -11), 'black cat climbed the', 'substr 2'; is $s->substr(14), 'climbed the green tree', 'substr 3'; is $s->substr(-4), 'tree', 'substr 4'; is $s->substr(-4, 2), 'tr', 'substr 5'; is $s->substr(-4, 2), 'tr', 'substr 5'; is $s->substr(1, 2, 'foobar'), 'he', 'substr 6'; is $$s,'Tfoobar black cat climbed the green tree', 'string matches'; done_testing(); Data-Perl-0.002009/t/release-pod-syntax.t0000644000175000017500000000045612353141421016036 0ustar mmpmmp#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Data-Perl-0.002009/t/collection/0000755000175000017500000000000012353141421014253 5ustar mmpmmpData-Perl-0.002009/t/collection/hash.t0000644000175000017500000000570412353141421015371 0ustar mmpmmpuse Test::More; use Test::Deep qw/cmp_bag/; use Data::Perl; use strict; use Scalar::Util qw/refaddr/; # thanks to Mojo::Collection for skeleton test is ref(hash('a',1,'b',2)), 'Data::Perl::Collection::Hash', 'constructor shortcut works'; # hash is hash('a', 1, 'b', 2)->{'b'}, 2, 'right result'; is_deeply {%{hash(a => 1, b => 2)}}, { a=>1, b=>2 }, 'right result'; # set my $h = Data::Perl::Collection::Hash->new(a=>1); $h->set(d=>5,e=>6); is_deeply $h, {a=>1,d=>5,e=>6}, 'set many right result'; my ($obj) = $h->set(x=>5,y=>6); is_deeply $obj, [5,6], 'set many right result in list context'; $h = hash(b=>3); $h->set(d=>5); is_deeply $h, {d=>5,b=>3}, 'set right result'; my ($results) = $h->set(d=>5, b => 3, e => 6); is_deeply $results, [5,3,6], 'set list context works'; # get is hash(a => 1, b => 2)->get('b'), 2, 'get right result'; is_deeply [hash(a => 1, b => 2)->get(qw/a b c/)->all], [1, 2, undef ], 'get many right result'; # delete $h = hash(qw/b 3 a 1 c 2 d 3 e 4 y 5 u 7/); is_deeply $h->delete(qw/b/)->all, 3, 'delete returned right result'; is_deeply $h, {qw/a 1 c 2 d 3 e 4 y 5 u 7/}, 'delete right result'; is_deeply [$h->delete(qw/4444/)->all], [undef], 'delete returned right result'; ($results) = $h->delete(qw/a c d e y u/); is_deeply $results, [qw/1 2 3 4 5 7/], 'delete right result'; is_deeply $h, {}, 'delete right result'; # keys $h = hash(a=>1,b=>2,c=>3); is_deeply [sort $h->keys->all], [qw/a b c/], 'keys works'; # exists ok $h->exists('a'), 'exists ok'; ok !$h->exists('r'), 'exists fails ok'; $h->set('a'=>undef); ok $h->exists('a'), 'exists on undef ok'; # defined $h = hash(a=>1); ok $h->defined('a'), 'defined ok'; ok !$h->defined('x'), 'defined not ok on undef'; # values $h = hash(a=>1,b=>2); is_deeply [sort $h->values->all], [1,2], 'values ok'; # kv cmp_bag [$h->kv->all], [[qw/a 1/], [qw/b 2/]], 'kv works'; # elements is_deeply [sort $h->all], [ qw/1 2 a b/], 'all elements works'; # clear $h = hash(a=>1,b=>2); my $old_addr = refaddr($h); $h->clear; is_deeply {%{$h}}, {}, 'clear works'; is refaddr($h), $old_addr, 'refaddr matches on clear'; # count/is_empty is $h->count, 0, 'empty count works'; is $h->is_empty, 1, 'is empty works'; $h = hash(a=>1,b=>2); is $h->count, 2, 'count works'; is $h->is_empty, 0, 'is empty works'; # accessor $h = hash(a=>1,b=>2); is $h->accessor('a'), 1, 'accessor get works'; is $h->accessor('a', '4'), 4, 'accessor set works'; is $h->accessor('r'), undef, 'accessor get on undef works'; is $h->accessor('r', '5'), 5, 'accessor set on undef works'; is $h->accessor(), '', 'no arg accessor get returning undef works'; # shallow_clone $h = hash(a=>1,b=>2); my $foo = $h->shallow_clone; cmp_bag [$h->kv->all], [[qw/a 1/], [qw/b 2/]], 'shallow clone is a clone'; isnt refaddr($h), refaddr($foo), 'refaddr doesnt match on clone'; # shallow_clone as a class method $foo = Data::Perl::Collection::Hash::shallow_clone({1=>2,3=>4}); is_deeply($foo, {1,2,3,4}, 'shallow clone is a clone as a class method'); done_testing(); Data-Perl-0.002009/t/collection/array.t0000644000175000017500000002043012353141421015555 0ustar mmpmmpuse Test::More; use Data::Perl; use Scalar::Util qw/refaddr/; use Test::Output; use strict; # thanks to Mojo::Collection for skeleton test # size my $collection = array(); is $collection->count, 0, 'right size'; $collection = array(undef); is @{$collection}, 1, 'right size'; $collection = array(23); is $collection->count, 1, 'right size'; $collection = array([2, 3]); is $collection->count, 1, 'right size'; $collection = array(5, 4, 3, 2, 1); is @{$collection}, 5, 'right size'; # Array is array(1,2,3)->[1], 2, 'right result'; is_deeply [@{array(3, 2, 1)}], [3, 2, 1], 'right result'; $collection = array(1, 2); push @$collection, 3, 4, 5; is_deeply [@$collection], [1, 2, 3, 4, 5], 'right result'; =begin # each $collection = array(3, 2, 1); is_deeply [$collection->each], [3, 2, 1], 'right all'; $collection = array([3], [2], [1]); my @results; $collection->each(sub { push @results, $_->[0] }); is_deeply \@results, [3, 2, 1], 'right all'; @results = (); $collection->each(sub { push @results, shift->[0], shift }); is_deeply \@results, [3, 1, 2, 2, 1, 3], 'right all'; =cut #count/is_empty is array()->count, 0, 'count correct.'; is array(1,2,3)->count, 3, 'count correct.'; is array()->is_empty, 1, 'is_empty correct.'; is array(1,2,3)->is_empty, 0, 'is_empty correct.'; # all is_deeply [array()->all], [], 'all correct.'; is_deeply [array(1, 2, 3)->all], [1,2,3], 'all correct.'; # get is array()->get(0), undef, 'get correct'; is array(1,2)->get(1), 2, 'get correct'; # accessor get is array()->accessor(0), undef, 'accessor get correct'; is array(1,2)->accessor(1), 2, 'accessor get correct'; is array(1,2)->accessor(), '', 'accessor get 0 arg does nothing'; # pop is array()->pop, undef, 'pop correct'; is array(1,2)->pop, 2, 'pop correct'; # push my $ar = array(2); $ar->push(1); is_deeply [$ar->all], [2,1], 'push works'; # shift $ar = array(2,3); is $ar->shift(), 2, 'shift works'; is_deeply [$ar->all], [3], 'shift works'; # unshift $ar = array(3); $ar->unshift(2); is_deeply [$ar->all], [2,3], 'unshift works'; # splice $ar = array(1); $ar->splice(0,1,2); is_deeply [$ar->all], [2], 'splice works'; $ar = array(9,8,7,6); my ($b) = $ar->splice(0,2,2, 3, 4); is_deeply [$b->all], [9,8], 'splice autoflatten works'; # first/first_index $collection = array(5, 4, [3, 2], 1); is_deeply $collection->first(sub { ref $_ eq 'ARRAY' }), [3, 2], 'right result'; is_deeply $collection->first_index(sub { ref $_ eq 'ARRAY' }), 2, 'right result'; is $collection->first(sub { $_ < 5 }), 4, 'right result'; is $collection->first_index(sub { $_ < 5 }), 1, 'right result'; is $collection->first(sub { ref $_ eq 'CODE' }), undef, 'no result'; is $collection->first_index(sub { ref $_ eq 'CODE' }), -1, 'no result'; $collection = array(); is $collection->first(sub { defined $_ }), undef, 'no result'; is $collection->first_index(sub { defined $_ }), -1, 'no result'; #is $collection->first, 5, 'right result'; #is $collection->first(qr/[1-4]/), 4, 'right result'; #is $collection->first, undef, 'no result'; # grep $collection = array(1, 2, 3, 4, 5, 6, 7, 8, 9); is_deeply [$collection->grep(sub {/[6-9]/})->all], [6, 7, 8, 9], 'right all'; is_deeply [$collection->grep(sub { $_ > 5 })->all], [6, 7, 8, 9], 'right all'; is_deeply [$collection->grep(sub { $_ < 5 })->all], [1, 2, 3, 4], 'right all'; is_deeply [$collection->grep(sub { $_ == 5 })->all], [5], 'right all'; is_deeply [$collection->grep(sub { $_ < 1 })->all], [], 'no all'; is_deeply [$collection->grep(sub { $_ > 9 })->all], [], 'no all'; # map $collection = array(1, 2, 3); $collection->map(sub { $_ + 1 }); is_deeply [@$collection], [1, 2, 3], 'right all'; $collection->map(sub { shift() + 2 }); is_deeply [@$collection], [1, 2, 3], 'right all'; # reduce $collection = array(1..5); is $collection->reduce(sub { $_[0] + $_[1] }), 15, 'reduce works'; # sort $collection = array(5,2,4,1,3); is_deeply [$collection->sort(sub { $_[0] <=> $_[1] })->all], [1,2,3,4,5], 'sort works'; # sort_in_place $collection = array(5,2,4,1,3); $collection->sort_in_place(sub { $_[1] <=> $_[0] }); is_deeply [$collection->all], [5,4,3,2,1], 'sort works'; $collection->sort_in_place; is_deeply [$collection->all], [1,2,3,4,5], 'sort works'; # shuffle $collection = array(0 .. 10); my $random = [$collection->shuffle->all]; is $collection->count, scalar @$random, 'same number of elements after shuffle'; isnt "@$collection", "@$random", 'different order'; is_deeply [array()->shuffle->all], [], 'no elements in shuffle'; # sort $collection = array(2, 5, 4, 1); is_deeply [$collection->sort->all], [1, 2, 4, 5], 'right order'; is_deeply [$collection->sort(sub { $_[1] cmp $_[0] })->all], [5, 4, 2, 1], 'right order'; $collection = array(qw(Test perl Mojo)); is_deeply [$collection->sort(sub { uc(shift) cmp uc(shift) })->all], [qw(Mojo perl Test)], 'right order'; $collection = array(); is_deeply [$collection->sort->all], [], 'no all'; is_deeply [$collection->sort(sub { $_[1] cmp $_[0] })->all], [], 'no all'; # uniq $collection = array(1, 2, 3, 2, 3, 4, 5, 4); is_deeply [$collection->uniq->all], [1, 2, 3, 4, 5], 'right result'; #is_deeply [$collection->uniq->reverse->uniq ], [5, 4, 3, 2, 1], 'right result'; # join $collection = array(1, 2, 3); is $collection->join, '1,2,3', 'right result'; is $collection->join(''), '123', 'right result'; is $collection->join('---'), '1---2---3', 'right result'; is $collection->join("\n"), "1\n2\n3", 'right result'; #$collection = array(array(1, 2, 3), array(3, 2, 1)); #is $collection->join(''), "1\n2\n33\n2\n1", 'right result'; #is $collection->join('/')->url_escape, '1%2F2%2F3', 'right result'; # set $ar = array(1,2,3); $ar->set(0, 2); is_deeply $ar, [2,2,3], 'set works'; $ar->set(5, 4); is_deeply $ar, [2,2,3,undef,undef,4], 'set works'; # accessor set $ar = array(1,2,3); $ar->accessor(0, 2); is_deeply $ar, [2,2,3], 'set works'; $ar->accessor(0, 2,9,9,9); is_deeply $ar, [2,2,3], 'set works, extraneous args do nothing'; $ar->set(5, 4); is_deeply $ar, [2,2,3,undef,undef,4], 'set works'; # delete $ar = array(1,2,3); $ar->delete(1); is_deeply [$ar->all], [1,3], 'delete works'; # insert $ar = array(1,2,3); $ar->insert(1, 5); is_deeply [$ar->all], [1,5,2,3], 'insert works'; # natatime $ar = array(1,2,3,4,5,6,7,8,9,10,11); my $it = $ar->natatime(5); is_deeply [$it->()], [1,2,3,4,5], 'iterator returns correct'; is_deeply [$it->()], [6,7,8,9,10], 'iterator returns correct'; is_deeply [$it->()], [11], 'iterator returns correct'; $ar->natatime(11, sub { is_deeply([@_], [1..11], 'passing coderef works for natatime iterator')}); # shallow_clone $ar = array(1,2,3); my $foo = $ar->shallow_clone; is_deeply([$ar->all], $foo, 'shallow clone is a clone'); # shallow_clone as a class method $foo = Data::Perl::Collection::Array::shallow_clone([1,2,3]); is_deeply($foo, [1,2,3], 'shallow clone is a clone as a class method'); isnt refaddr($ar), refaddr($foo), 'refaddr doesnt match on clone'; # flatten_deep my $a = Data::Perl::Collection::Array->new(1, 2, [3, [4, [5] ] ], 6); is_deeply [Data::Perl::Collection::Array->new(1, 2, [3, [4, [5] ] ], 6)->flatten_deep(2)], [1,2,3,4,[5], 6], 'flatten_deep(depth) works'; is_deeply [Data::Perl::Collection::Array->new(1, 2, [3, [4, [5] ] ], 6)->flatten_deep], [1,2,3,4,5,6], 'flatten_deep(depth) works'; # reverse $a = array(1,2,3,4,5); is_deeply([$a->reverse->all], [5,4,3,2,1], 'reverse works'); # print stdout_is(sub { $a->print }, '1,2,3,4,5', 'print works'); stdout_is(sub { $a->print(*STDOUT, ':') }, '1:2:3:4:5', 'print works with join arg'); stderr_is(sub { $a->print(*STDERR) }, '1,2,3,4,5', 'print to different handle works'); =begin # slice $collection = array(1, 2, 3, 4, 5, 6, 7, 10, 9, 8); is_deeply [$collection->slice(0)], [1], 'right result'; is_deeply [$collection->slice(1)], [2], 'right result'; is_deeply [$collection->slice(2)], [3], 'right result'; is_deeply [$collection->slice(-1)], [8], 'right result'; is_deeply [$collection->slice(-3, -5)], [10, 6], 'right result'; is_deeply [$collection->slice(1, 2, 3)], [2, 3, 4], 'right result'; is_deeply [$collection->slice(6, 1, 4)], [7, 2, 5], 'right result'; is_deeply [$collection->slice(6 .. 9)], [7, 10, 9, 8], 'right result'; # pluck $collection = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)); is $collection->pluck('reverse'), "3\n2\n1\n6\n5\n4\n9\n8\n7", 'right result'; is $collection->pluck(join => '-'), "1-2-3\n4-5-6\n7-8-9", 'right result'; =cut done_testing(); Data-Perl-0.002009/t/collection/subclassing.t0000644000175000017500000000136612353141421016763 0ustar mmpmmpuse strict; use warnings; use Test::More; use Data::Perl; BEGIN { package Local::Array; use parent 'Data::Perl::Collection::Array'; sub monkey_around { my $self = shift; ref($self)->new(map "Bonobo", @$self); } }; BEGIN { package Local::Hash; use parent 'Data::Perl::Collection::Hash'; use constant _array_class => "Local::Array"; }; my $hash = Local::Hash->new(a => 1, b => 2); isa_ok( $hash->keys, 'Data::Perl::Collection::Array', 'hash keys are an array', ); isa_ok( $hash->keys, 'Local::Array', 'hash keys are our subclass of array', ); can_ok( $hash->keys, 'monkey_around', ); is_deeply( $hash->keys->monkey_around, Local::Array->new(qw/ Bonobo Bonobo /), 'our custom method works', ); done_testing; Data-Perl-0.002009/t/counter.t0000644000175000017500000000071512353141421013767 0ustar mmpmmpuse Test::More; use Data::Perl; use Scalar::Util qw/refaddr/; use strict; # constructor is ref(counter(1)), 'Data::Perl::Counter', 'constructor shortcut works'; my $c = counter(5); is $$c, 5, 'nondefault set works'; # inc $c->inc; is $$c, 6, 'inc 1 works'; $c->inc(3); is $$c, 9, 'inc n works'; # dec $c = counter(4); $c->dec; is $$c, 3, 'dec 1 works'; $c->dec(2); is $$c, 1, 'dec n works'; # reset $c->reset; is $$c, 0, 'reset works'; done_testing(); Data-Perl-0.002009/t/release-pod-coverage.t0000644000175000017500000000057212353141421016302 0ustar mmpmmp#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Data-Perl-0.002009/t/bool.t0000644000175000017500000000105312353141421013237 0ustar mmpmmpuse Test::More; use Data::Perl; use strict; use Scalar::Util qw/refaddr/; # constructor is ref(bool(1)), 'Data::Perl::Bool', 'constructor shortcut works'; my $b = bool(5); is $$b, 1, 'nondefault set reduces to 1'; $b = bool(); is $$b, 0, 'default set reduces to 0'; # set $b->set(); is $$b, 1, 'set sets to 1'; $b->set(); # unset $b->unset; is $$b, 0, 'unset works.'; # toggle $b->toggle; is $$b, 1, 'toggle works'; $b->toggle; is $$b, 0, 'toggle works'; # not is $b->not, 1, 'not works'; $b->toggle; is $b->not, '', 'not works'; done_testing(); Data-Perl-0.002009/t/code.t0000644000175000017500000000105112353141421013214 0ustar mmpmmpuse Test::More; use Data::Perl; use strict; use Scalar::Util qw/reftype/; use Test::Fatal qw/dies_ok/; # constructor is ref(code(sub{})), 'Data::Perl::Code', 'constructor shortcut works'; is code->execute, undef, 'execute on blank sub returns correct undef'; my $b = code(sub { 2 }); is reftype($b), 'CODE', 'inner struct is coderef of ctr'; is $b->(), 2, 'coderef returns correct value'; is $b->execute, 2, 'execute returns correct value'; # tbd: execute_method dies_ok { $b->execute_method; } 'execute_method fails for now.'; done_testing(); Data-Perl-0.002009/README.mkdn0000644000175000017500000000626512353141421013476 0ustar mmpmmp# NAME Data::Perl - Base classes wrapping fundamental Perl data types. # VERSION version 0.002009 # SYNOPSIS use Data::Perl; my $array = array(1,2,3, qw/a b c/); $array->count; # 6 my @elements = $array->grep(sub {/b/}); # (b) my $hash = hash(a => 1, b => 2); $hash->keys; # ('a', 'b'); my $number = number(5); $number->add(10); # 15 my $string = string("foo\n"); $string->chomp; # return 1, chomps string my $counter = counter(); $counter->inc; # counter is now 1 my $sub = code(sub { 'foo' }); $sub->execute; # returns 'foo' $foo # DESCRIPTION Data::Perl is a collection of classes that wrap fundamental data types that exist in Perl. These classes and methods as they exist today are an attempt to mirror functionality provided by Moose's Native Traits. One important thing to note is all classes currently do no validation on constructor input. Data::Perl is a container class for the following classes: - [Data::Perl::Collection::Hash](http://search.cpan.org/perldoc?Data::Perl::Collection::Hash) - [Data::Perl::Collection::Array](http://search.cpan.org/perldoc?Data::Perl::Collection::Array) - [Data::Perl::String](http://search.cpan.org/perldoc?Data::Perl::String) - [Data::Perl::Number](http://search.cpan.org/perldoc?Data::Perl::Number) - [Data::Perl::Counter](http://search.cpan.org/perldoc?Data::Perl::Counter) - [Data::Perl::Bool](http://search.cpan.org/perldoc?Data::Perl::Bool) - [Data::Perl::Code](http://search.cpan.org/perldoc?Data::Perl::Code) # ALPHA API The API provided by these modules is as of now considered alpha and undecided. The API __WILL__ change. If you are writing code that you will not touch again for years, do not use this until this warning is removed. # PROVIDED FUNCTIONS Data::Perl exports helper constructor functions to interface with the above classes: - __hash(key, value, ...)__ Returns a Data::Perl::Collection::Hash object initialized with the optionally passed in key/value args. - __array(@args)__ Returns a Data::Perl::Collection::Array object initialized with the optionally passed in values. - __string($arg)__ Returns a Data::Perl::String object initialized with the optionally passed in scalar arg. - __number($arg)__ Returns a Data::Perl::Number object initialized with the optionally passed in scalar arg. - __counter($arg)__ Returns a Data::Perl::Counter object initialized with the optionally passed in scalar arg. - __bool($arg)__ Returns a Data::Perl::Bool object initialized with the truth value of the passed in scalar arg. - __code($arg)__ Returns a Data::Perl::Code object initialized with the optionally passed in scalar coderef as an arg. # THANKS Much thanks to the [Moose](http://search.cpan.org/perldoc?Moose) team for their work with native traits, for which much of this work is based. # SEE ALSO - [MooX::HandlesVia](http://search.cpan.org/perldoc?MooX::HandlesVia) # AUTHOR Matthew Phillips # COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Data-Perl-0.002009/lib/0000755000175000017500000000000012353141421012423 5ustar mmpmmpData-Perl-0.002009/lib/Data/0000755000175000017500000000000012353141421013274 5ustar mmpmmpData-Perl-0.002009/lib/Data/Perl.pm0000644000175000017500000000730412353141421014540 0ustar mmpmmppackage Data::Perl; $Data::Perl::VERSION = '0.002009'; # ABSTRACT: Base classes wrapping fundamental Perl data types. BEGIN { require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(hash array counter string code bool number); } use strictures 1; use Data::Perl::Collection::Array; use Data::Perl::Collection::Hash; use Data::Perl::Code; use Data::Perl::Number; use Data::Perl::Bool; use Data::Perl::String; use Data::Perl::Counter; sub array { Data::Perl::Collection::Array->new(@_) } sub hash { Data::Perl::Collection::Hash->new(@_) } sub code { Data::Perl::Code->new(shift||sub {}) } sub number { Data::Perl::Number->new(shift||0) } sub bool { Data::Perl::Bool->new(shift||0) } sub string { Data::Perl::String->new(shift||'') } sub counter { Data::Perl::Counter->new(shift||0) } 1; =pod =encoding UTF-8 =head1 NAME Data::Perl - Base classes wrapping fundamental Perl data types. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl; my $array = array(1,2,3, qw/a b c/); $array->count; # 6 my @elements = $array->grep(sub {/b/}); # (b) my $hash = hash(a => 1, b => 2); $hash->keys; # ('a', 'b'); my $number = number(5); $number->add(10); # 15 my $string = string("foo\n"); $string->chomp; # return 1, chomps string my $counter = counter(); $counter->inc; # counter is now 1 my $sub = code(sub { 'foo' }); $sub->execute; # returns 'foo' $foo =head1 DESCRIPTION Data::Perl is a collection of classes that wrap fundamental data types that exist in Perl. These classes and methods as they exist today are an attempt to mirror functionality provided by Moose's Native Traits. One important thing to note is all classes currently do no validation on constructor input. Data::Perl is a container class for the following classes: =over 4 =item * L =item * L =item * L =item * L =item * L =item * L =item * L =back =head1 ALPHA API The API provided by these modules is as of now considered alpha and undecided. The API B change. If you are writing code that you will not touch again for years, do not use this until this warning is removed. =head1 PROVIDED FUNCTIONS Data::Perl exports helper constructor functions to interface with the above classes: =over 4 =item * B Returns a Data::Perl::Collection::Hash object initialized with the optionally passed in key/value args. =item * B Returns a Data::Perl::Collection::Array object initialized with the optionally passed in values. =item * B Returns a Data::Perl::String object initialized with the optionally passed in scalar arg. =item * B Returns a Data::Perl::Number object initialized with the optionally passed in scalar arg. =item * B Returns a Data::Perl::Counter object initialized with the optionally passed in scalar arg. =item * B Returns a Data::Perl::Bool object initialized with the truth value of the passed in scalar arg. =item * B Returns a Data::Perl::Code object initialized with the optionally passed in scalar coderef as an arg. =back =head1 THANKS Much thanks to the L team for their work with native traits, for which much of this work is based. =head1 SEE ALSO =over 4 =item * L =back =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/0000755000175000017500000000000012353141421014176 5ustar mmpmmpData-Perl-0.002009/lib/Data/Perl/Code.pm0000644000175000017500000000162112353141421015406 0ustar mmpmmppackage Data::Perl::Code; $Data::Perl::Code::VERSION = '0.002009'; # ABSTRACT: Wrapping class for Perl coderefs. use strictures 1; use Role::Tiny::With; with 'Data::Perl::Role::Code'; 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Code - Wrapping class for Perl coderefs. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/code/; my $code = code(sub { 'Foo'} ); $code->execute(); # returns 'Foo'; =head1 DESCRIPTION This class is a simple consumer of the L role, which provides all functionality. You probably want to look there instead. =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/Bool.pm0000644000175000017500000000161412353141421015431 0ustar mmpmmppackage Data::Perl::Bool; $Data::Perl::Bool::VERSION = '0.002009'; # ABSTRACT: Wrapping class for boolean values. use strictures 1; use Role::Tiny::With; with 'Data::Perl::Role::Bool'; 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Bool - Wrapping class for boolean values. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/bool/; my $bool = bool(0); $bool->toggle; # 1 $bool->unset; # 0 =head1 DESCRIPTION This class is a simple consumer of the L role, which provides all functionality. You probably want to look there instead. =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/Counter.pm0000644000175000017500000000166712353141421016165 0ustar mmpmmppackage Data::Perl::Counter; $Data::Perl::Counter::VERSION = '0.002009'; # ABSTRACT: Wrapping class for a simple numeric counter. use strictures 1; use Role::Tiny::With; with 'Data::Perl::Role::Counter'; 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Counter - Wrapping class for a simple numeric counter. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/counter/; my $c = counter(4); $c->inc; # $c == 5 $c->reset; # $c == 0 =head1 DESCRIPTION This class is a simple consumer of the L role, which provides all functionality. You probably want to look there instead. =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/Role/0000755000175000017500000000000012353141421015077 5ustar mmpmmpData-Perl-0.002009/lib/Data/Perl/Role/Code.pm0000644000175000017500000000300112353141421016301 0ustar mmpmmppackage Data::Perl::Role::Code; $Data::Perl::Role::Code::VERSION = '0.002009'; # ABSTRACT: Wrapping class for Perl coderefs. use strictures 1; use Role::Tiny; sub new { my $cl = shift; bless $_[0], $cl } sub execute { $_[0]->(@_[1..$#_]) } #sub execute_method { $_[0]->($_[0], @_[1..$#_]) } sub execute_method { die 'This remains unimplemented for now.' } 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Role::Code - Wrapping class for Perl coderefs. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/code/; my $code = code(sub { 'Foo'} ); $code->execute(); # returns 'Foo'; =head1 DESCRIPTION This class provides a wrapper and methods for interacting with Perl coderefs. =head1 PROVIDED METHODS =over 4 =item B Constructs a new Data::Perl::Code object, initialized to $coderef as passed in, and returns it. =item B Calls the coderef with the given args. =item B Calls the coderef with the the instance as invocant and given args. B =back =head1 SEE ALSO =over 4 =item * L =item * L =back =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/Role/Bool.pm0000644000175000017500000000303412353141421016330 0ustar mmpmmppackage Data::Perl::Role::Bool; $Data::Perl::Role::Bool::VERSION = '0.002009'; # ABSTRACT: Wrapping class for boolean values. use strictures 1; use Role::Tiny; sub new { my $bool = $_[1] ? 1 : 0; bless(\$bool, $_[0]) } sub set { ${$_[0]} = 1 } sub unset { ${$_[0]} = 0 } sub toggle { ${$_[0]} = ${$_[0]} ? 0 : 1; } sub not { !${$_[0]} } 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Role::Bool - Wrapping class for boolean values. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/bool/; my $bool = bool(0); $bool->toggle; # 1 $bool->unset; # 0 =head1 DESCRIPTION This class provides a wrapper and methods for interacting with boolean values. =head1 PROVIDED METHODS None of these methods accept arguments. =over 4 =item B Constructs a new Data::Perl::Collection::Bool object initialized with the passed in value, and returns it. =item B Sets the value to C<1> and returns C<1>. =item B Set the value to C<0> and returns C<0>. =item B Toggles the value. If it's true, set to false, and vice versa. Returns the new value. =item B Equivalent of 'not C<$value>'. =back =head1 SEE ALSO =over 4 =item * L =item * L =back =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/Role/Counter.pm0000644000175000017500000000357112353141421017062 0ustar mmpmmppackage Data::Perl::Role::Counter; $Data::Perl::Role::Counter::VERSION = '0.002009'; # ABSTRACT: Wrapping class for a simple numeric counter. use strictures 1; use Role::Tiny; sub new { bless \(my $n = $_[1]), $_[0] } sub inc { ${$_[0]} += ($_[1] ? $_[1] : 1) } sub dec { ${$_[0]} -= ($_[1] ? $_[1] : 1) } sub reset { ${$_[0]} = 0 } 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Role::Counter - Wrapping class for a simple numeric counter. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/counter/; my $c = counter(4); $c->inc; # $c == 5 $c->reset; # $c == 0 =head1 DESCRIPTION This class provides a wrapper and methods for a simple numeric counter. =head1 PROVIDED METHODS =over 4 =item B Constructs a new Data::Perl::Collection::Counter object initialized with the passed in value, and returns it. =item B Sets the counter to the specified value and returns the new value. This method requires a single argument. =item B =item B Increases the attribute value by the amount of the argument, or by 1 if no argument is given. This method returns the new value. This method accepts a single argument. =item B =item B Decreases the attribute value by the amount of the argument, or by 1 if no argument is given. This method returns the new value. This method accepts a single argument. =item B Resets the value stored in this slot to its default value, and returns the new value. =back =head1 SEE ALSO =over 4 =item * L =item * L =back =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/Role/String.pm0000644000175000017500000000700112353141421016701 0ustar mmpmmppackage Data::Perl::Role::String; $Data::Perl::Role::String::VERSION = '0.002009'; # ABSTRACT: Wrapping class for Perl scalar strings. use strictures 1; use Role::Tiny; sub new { bless \(my $s = $_[1]), $_[0] } sub inc { ++${$_[0]} } sub append { ${$_[0]} = ${$_[0]} . $_[1] } sub prepend { ${$_[0]} = $_[1] . ${$_[0]} } sub replace { if (ref($_[2]) eq 'CODE') { ${$_[0]} =~ s/$_[1]/$_[2]->()/e; } else { ${$_[0]} =~ s/$_[1]/$_[2]/; } ${$_[0]}; } sub match { ${$_[0]} =~ /$_[1]/; } sub chop { CORE::chop ${$_[0]} } sub chomp { CORE::chomp ${$_[0]} } sub clear { ${$_[0]} = '' } sub length { CORE::length ${$_[0]} } sub substr { if (@_ >= 4) { substr ${$_[0]}, $_[1], $_[2], $_[3]; } elsif (@_ == 3) { substr ${$_[0]}, $_[1], $_[2]; } else { substr ${$_[0]}, $_[1]; } } 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Role::String - Wrapping class for Perl scalar strings. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/string/; my $string = string("foo\n"); $string->chomp; # returns 1, $string == "foo" =head1 DESCRIPTION This class provides a wrapper and methods for interacting with scalar strings. =head1 PROVIDED METHODS =over 4 =item * B Constructs a new Data::Perl::String object, optionally initialized to $value if passed in, and returns it. =item * B Increments the value stored in this slot using the magical string autoincrement operator. Note that Perl doesn't provide analogous behavior in C<-->, so C is not available. This method returns the new value. This method does not accept any arguments. =item * B Appends to the string, like C<.=>, and returns the new value. This method requires a single argument. =item * B Prepends to the string and returns the new value. This method requires a single argument. =item * B Performs a regexp substitution (L). There is no way to provide the C flag, but code references will be accepted for the replacement, causing the regex to be modified with a single C. C can be applied using the C operator. This method returns the new value. This method requires two arguments. =item * B Runs the regex against the string and returns the matching value(s). This method requires a single argument. =item * B Just like L. This method returns the chopped character. This method does not accept any arguments. =item * B Just like L. This method returns the number of characters removed. This method does not accept any arguments. =item * B Sets the string to the empty string (not the value passed to C). This method does not have a defined return value. This method does not accept any arguments. =item * B Just like L, returns the length of the string. =item * B This acts just like L. When called as a writer, it returns the substring that was replaced, just like the Perl builtin. This method requires at least one argument, and accepts no more than three. =back =head1 SEE ALSO =over 4 =item * L =item * L =back =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/Role/Number.pm0000644000175000017500000000370112353141421016666 0ustar mmpmmppackage Data::Perl::Role::Number; $Data::Perl::Role::Number::VERSION = '0.002009'; # ABSTRACT: Wrapping class for Perl scalar numbers. use strictures 1; use Role::Tiny; sub new { bless \(my $n = $_[1]), $_[0] } sub add { ${$_[0]} = ${$_[0]} + $_[1] } sub sub { ${$_[0]} = ${$_[0]} - $_[1] } sub mul { ${$_[0]} = ${$_[0]} * $_[1] } sub div { ${$_[0]} = ${$_[0]} / $_[1] } sub mod { ${$_[0]} = ${$_[0]} % $_[1] } sub abs { ${$_[0]} = abs(${$_[0]}) } 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Role::Number - Wrapping class for Perl scalar numbers. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/number/; my $num = number(123); $num->add(5); # $num == 128 $num->div(2); # $num == 64 =head1 DESCRIPTION This class provides a wrapper and methods for interacting with scalar strings. =head1 PROVIDED METHODS All of these methods modify the attribute's value in place. All methods return the new value. =over 4 =item B Constructs a new Data::Perl::Collection::Number object initialized with the passed in value, and returns it. =item B Adds the current value of the attribute to C<$value>. =item B Subtracts C<$value> from the current value of the attribute. =item B Multiplies the current value of the attribute by C<$value>. =item B Divides the current value of the attribute by C<$value>. =item B Returns the current value of the attribute modulo C<$value>. =item B Sets the current value of the attribute to its absolute value. =back =head1 SEE ALSO =over 4 =item * L =item * L =back =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/Role/Collection/0000755000175000017500000000000012353141421017172 5ustar mmpmmpData-Perl-0.002009/lib/Data/Perl/Role/Collection/Hash.pm0000644000175000017500000001334012353141421020414 0ustar mmpmmppackage Data::Perl::Role::Collection::Hash; $Data::Perl::Role::Collection::Hash::VERSION = '0.002009'; # ABSTRACT: Wrapping class for Perl's built in hash structure. use strictures 1; use Role::Tiny; use Scalar::Util qw/blessed/; use Module::Runtime qw/use_package_optimistically/; sub new { my $cl = shift; bless({ @_ }, $cl) } sub _array_class { 'Data::Perl::Collection::Array' } sub get { my $self = shift; if (@_ > 1) { my @res = @{$self}{@_}; blessed($self) ? use_package_optimistically($self->_array_class)->new(@res) : @res; } else { $self->{$_[0]}; } } sub set { my $self = shift; my @keys_idx = grep { ! ($_ % 2) } 0..$#_; my @values_idx = grep { $_ % 2 } 0..$#_; @{$self}{@_[@keys_idx]} = @_[@values_idx]; my @res = @{$self}{@_[@keys_idx]}; blessed($self) ? use_package_optimistically($self->_array_class)->new(@res) : @res; } sub delete { my $self = shift; my @res = CORE::delete @{$self}{@_}; blessed($self) ? use_package_optimistically($self->_array_class)->new(@res) : @res; } sub keys { my ($self) = @_; my @res = keys %{$self}; blessed($self) ? use_package_optimistically($self->_array_class)->new(@res) : @res; } sub exists { CORE::exists $_[0]->{$_[1]} } sub defined { CORE::defined $_[0]->{$_[1]} } sub values { my ($self) = @_; my @res = CORE::values %{$_[0]}; blessed($self) ? use_package_optimistically($self->_array_class)->new(@res) : @res; } sub kv { my ($self) = @_; my @res = CORE::map { [ $_, $self->{$_} ] } CORE::keys %{$self}; blessed($self) ? use_package_optimistically($self->_array_class)->new(@res) : @res; } { no warnings 'once'; sub all { my ($self) = @_; my @res = CORE::map { $_, $self->{$_} } CORE::keys %{$self}; @res; } *elements = *all; } sub clear { %{$_[0]} = () } sub count { CORE::scalar CORE::keys %{$_[0]} } sub is_empty { CORE::scalar CORE::keys %{$_[0]} ? 0 : 1 } sub accessor { if (@_ == 2) { $_[0]->{$_[1]}; } elsif (@_ > 2) { $_[0]->{$_[1]} = $_[2]; } } sub shallow_clone { blessed($_[0]) ? bless({%{$_[0]}}, ref $_[0]) : {%{$_[0]}} } 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Role::Collection::Hash - Wrapping class for Perl's built in hash structure. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/hash/; my $hash = hash(a => 1, b => 2); $hash->values; # (1, 2) $hash->set('foo', 'bar'); # (a => 1, b => 2, foo => 'bar') =head1 DESCRIPTION This class provides a wrapper and methods for interacting with a hash. All methods that return a list do so via a Data::Perl::Collection::Array object. =head1 PROVIDED METHODS =over 4 =item B Given an optional list of keys/values, constructs a new Data::Perl::Collection::Hash object initalized with keys/values and returns it. =item B Returns a list of values in the hash for the given keys. This method requires at least one argument. =item B $value, $key2 =E $value2...)> Sets the elements in the hash to the given values. It returns the new values set for each key, in the same order as the keys passed to the method. This method requires at least two arguments, and expects an even number of arguments. =item B Removes the elements with the given keys. Returns a list of values in the hash for the deleted keys. =item B Returns the list of keys in the hash. This method does not accept any arguments. =item B Returns true if the given key is present in the hash. This method requires a single argument. =item B Returns true if the value of a given key is defined. This method requires a single argument. =item B Returns the list of values in the hash. This method does not accept any arguments. =item B Returns the key/value pairs in the hash as an array of array references. for my $pair ( $object->option_pairs ) { print "$pair->[0] = $pair->[1]\n"; } This method does not accept any arguments. =item B Returns the key/value pairs in the hash as a flattened list.. This method does not accept any arguments. =item B Resets the hash to an empty value, like C<%hash = ()>. This method does not accept any arguments. =item B Returns the number of elements in the hash. Also useful for not empty: C<< has_options => 'count' >>. This method does not accept any arguments. =item B If the hash is populated, returns false. Otherwise, returns true. This method does not accept any arguments. =item B =item B If passed one argument, returns the value of the specified key. If passed two arguments, sets the value of the specified key. When called as a setter, this method returns the value that was set. =item B This method returns a shallow clone of the hash reference. The return value is a reference to a new hash with the same keys and values. It is I because any values that were references in the original will be the I references in the clone. =item B<_array_class> The name of the class which returned lists are instances of; i.e. C<< Data::Perl::Collection::Array >>. Subclasses of this class can override this method. =back Note that C is deliberately omitted, due to its stateful interaction with the hash iterator. C or C are much safer. =head1 SEE ALSO =over 4 =item * L =item * L =back =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/Role/Collection/Array.pm0000644000175000017500000003121612353141421020611 0ustar mmpmmppackage Data::Perl::Role::Collection::Array; $Data::Perl::Role::Collection::Array::VERSION = '0.002009'; # ABSTRACT: Wrapping class for Perl's built in array structure. use strictures 1; use Role::Tiny; use List::Util; use List::MoreUtils; use Scalar::Util qw/blessed/; sub new { my $cl = CORE::shift; bless([ @_ ], $cl) } # find the package name if possible else default to __PACKAGE__ #sub _blessed { blessed($_[0]) || __PACKAGE__ } sub count { CORE::scalar @{$_[0]} } sub is_empty { CORE::scalar @{$_[0]} ? 0 : 1 } { no warnings 'once'; sub all { @{$_[0]} } *elements = *all; *flatten = *all; } sub get { $_[0]->[ $_[1] ] } sub pop { CORE::pop @{$_[0]} } sub push { CORE::push @{$_[0]}, @_[1..$#_] } sub shift { CORE::shift @{$_[0]} } sub unshift { CORE::unshift @{$_[0]}, @_[1..$#_] } sub clear { @{$_[0]} = () } sub first { &List::Util::first($_[1], @{$_[0]}) } sub first_index { &List::MoreUtils::first_index($_[1], @{$_[0]}) } sub reduce { List::Util::reduce { $_[1]->($a, $b) } @{$_[0]} } sub set { $_[0]->[ $_[1] ] = $_[2] } sub accessor { if (@_ == 2) { $_[0]->[$_[1]]; } elsif (@_ > 2) { $_[0]->[$_[1]] = $_[2]; } } sub natatime { my $iter = List::MoreUtils::natatime($_[1], @{$_[0]}); if ($_[2]) { while (my @vals = $iter->()) { $_[2]->(@vals); } } else { $iter; } } sub shallow_clone { blessed($_[0]) ? bless([@{$_[0]}], ref $_[0]) : [@{$_[0]}] } # Data::Collection methods that return a Data::Perl::Collection::Array object #sub members { # my ($self) = @_; # qw/map grep member_count sort reverse print any all one none join/; #} sub map { my ($self, $cb) = @_; my @res = CORE::map { $cb->($_) } @$self; blessed($self) ? blessed($self)->new(@res) : @res; } sub grep { my ($self, $cb) = @_; my @res = CORE::grep { $cb->($_) } @$self; blessed($self) ? blessed($self)->new(@res) : @res; } sub sort { my ($self, $cb) = @_; my @res = $cb ? CORE::sort { $cb->($a, $b) } @$self : CORE::sort @$self; blessed($self) ? blessed($self)->new(@res) : @res; } sub reverse { my ($self) = @_; my @res = CORE::reverse @$self; blessed($self) ? blessed($self)->new(@res) : @res; } sub sort_in_place { @{$_[0]} = ($_[1] ? sort { $_[1]->($a, $b) } @{$_[0]} : sort @{$_[0]}); $_[0]; } sub splice { my ($self) = @_; my @res = CORE::splice @{$_[0]}, $_[1], $_[2], @_[3..$#_]; blessed($self) ? blessed($self)->new(@res) : @res; } sub shuffle { my ($self) = @_; my @res = List::Util::shuffle(@$self); blessed($self) ? blessed($self)->new(@res) : @res; } sub uniq { my ($self) = @_; my @res = List::MoreUtils::uniq(@$self); blessed($self) ? blessed($self)->new(@res) : @res; } sub delete { my ($self, $idx) = @_; my ($res) = CORE::splice(@$self, $idx, 1); $res; } sub insert { my ($self, $idx, $el) = @_; my ($res) = CORE::splice(@$self, $idx, 0, $el); $res; } sub flatten_deep { my ($self, $depth) = @_; _flatten_deep(@$self, $depth); } sub _flatten_deep { my @array = @_; my $depth = CORE::pop @array; --$depth if (defined($depth)); my @elements = CORE::map { (ref eq 'ARRAY') ? (defined($depth) && $depth == -1) ? $_ : _flatten_deep( @$_, $depth ) : $_ } @array; } sub join { my ($self, $with) = @_; CORE::join((defined $with ? $with : ','), @$self); } sub print { my ($self, $fh, $arg) = @_; print { $fh || *STDOUT } CORE::join((defined $arg ? $arg : ','), @$self); } 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Role::Collection::Array - Wrapping class for Perl's built in array structure. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/array/; my $array = array(1, 2, 3); $array->push(5); $array->grep(sub { $_ > 2 })->map(sub { $_ ** 2 })->elements; # (3, 5); =head1 DESCRIPTION This class provides a wrapper and methods for interacting with an array. All methods that return a list do so via a Data::Perl::Collection::Array object. =head1 PROVIDED METHODS =over 4 =item B Constructs a new Data::Perl::Collection::Array object initialized with passed in values, and returns it. =item B Returns the number of elements in the array. $stuff = Data::Perl::Collection::Array->new(qw/foo bar baz boo/); print $stuff->count; # prints 4 This method does not accept any arguments. =item B Returns a boolean value that is true when the array has no elements. $stuff->is_empty ? die "No options!\n" : print "Good boy.\n"; This method does not accept any arguments. =item B Returns all of the elements of the array as an array (not an array reference). my @options = $stuff->elements; print "@options\n"; # prints "foo bar baz boo" This method does not accept any arguments. =item B Returns an element of the array by its index. You can also use negative index numbers, just as with Perl's core array handling. my $option = $stuff->get(1); print "$option\n"; # prints "bar" If the specified element does not exist, this will return C. This method accepts just one argument. =item B Just like Perl's builtin C. This method does not accept any arguments. =item B Just like Perl's builtin C. Returns the number of elements in the new array. This method accepts any number of arguments. =item B Just like Perl's builtin C. This method does not accept any arguments. =item B Just like Perl's builtin C. Returns the number of elements in the new array. This method accepts any number of arguments. =item B Just like Perl's builtin C. In scalar context, this returns the last element removed, or C if no elements were removed. In list context, this returns all the elements removed from the array, wrapped in a Collection::Array object. This method requires at least one argument. =item B This method returns the first matching item in the array, just like L's C function. The matching is done with a subroutine reference you pass to this method. The subroutine will be called against each element in the array until one matches or all elements have been checked. my $found = $stuff->find_option( sub {/^b/} ); print "$found\n"; # prints "bar" This method requires a single argument. =item B This method returns the index of the first matching item in the array, just like L's C function. The matching is done with a subroutine reference you pass to this method. The subroutine will be called against each element in the array until one matches or all elements have been checked. This method requires a single argument. =item B This method returns every element matching a given criteria, just like Perl's core C function. This method requires a subroutine which implements the matching logic. The returned list is provided as a Collection::Array object. my @found = $stuff->grep( sub {/^b/} ); print "@found\n"; # prints "bar baz boo" This method requires a single argument. =item B This method transforms every element in the array and returns a new array, just like Perl's core C function. This method requires a subroutine which implements the transformation. The returned list is provided as a Collection::Array object. my @mod_options = $stuff->map( sub { $_ . "-tag" } ); print "@mod_options\n"; # prints "foo-tag bar-tag baz-tag boo-tag" This method requires a single argument. =item B This method turns an array into a single value, by passing a function the value so far and the next value in the array, just like L's C function. The reducing is done with a subroutine reference you pass to this method. my $found = $stuff->reduce( sub { $_[0] . $_[1] } ); print "$found\n"; # prints "foobarbazboo" This method requires a single argument. =item B =item B Returns the elements of the array in sorted order. You can provide an optional subroutine reference to sort with (as you can with Perl's core C function). However, instead of using C<$a> and C<$b> in this subroutine, you will need to use C<$_[0]> and C<$_[1]>. The returned list is provided as a Collection::Array object. # ascending ASCIIbetical my @sorted = $stuff->sort(); # Descending alphabetical order my @sorted_options = $stuff->sort( sub { lc $_[1] cmp lc $_[0] } ); print "@sorted_options\n"; # prints "foo boo baz bar" This method accepts a single argument. =item B =item B Sorts the array I, modifying the value of the attribute. You can provide an optional subroutine reference to sort with (as you can with Perl's core C function). However, instead of using C<$a> and C<$b>, you will need to use C<$_[0]> and C<$_[1]> instead. The returned list is provided as a Collection::Array object. This method accepts a single argument. =item B Returns the elements of the array in reversed order. The returned list is provided as a Collection::Array object. This method does not accept any arguments. =item B Returns the elements of the array in random order, like C from L. The returned list is provided as a Collection::Array object. This method does not accept any arguments. =item B Returns the array with all duplicate elements removed, like C from L. The returned list is provided as a Collection::Array object. This method does not accept any arguments. =item B Joins every element of the array using the separator given as argument, just like Perl's core C function. my $joined = $stuff->join(':'); print "$joined\n"; # prints "foo:bar:baz:boo" This method requires a single argument. =item B Prints the output of join($str) to $handle. $handle defaults to STDOUT, and join $str defaults to join()'s default of ','. $joined = $stuff->print(*STDERR, ';'); # prints foo;bar;baz to STDERR =item B Given an index and a value, sets the specified array element's value. This method returns the value at C<$index> after the set. This method requires two arguments. =item B Removes the element at the given index from the array. This method returns the deleted value, either as an array or scalar as dependent on splice context semantics. Note that if no value exists, it will return C. This method requires one argument. =item B Inserts a new element into the array at the given index. This method returns the new value at C<$index>, either as an array or scalar as dependent on splice context semantics. This method requires two arguments. =item B Empties the entire array, like C<@array = ()>. This method does not define a return value. This method does not accept any arguments. =item B =item B This method provides a get/set accessor for the array, based on array indexes. If passed one argument, it returns the value at the specified index. If passed two arguments, it sets the value of the specified index. When called as a setter, this method returns the new value at C<$index>. This method accepts one or two arguments. =item B =item B This method returns an iterator which, on each call, returns C<$n> more items from the array, in order, like C from L. A coderef can optionally be provided; it will be called on each group of C<$n> elements in the array. This method accepts one or two arguments. =item B This method returns a shallow clone of the array reference. The return value is a reference to a new array with the same elements. It is I because any elements that were references in the original will be the I references in the clone. =item B This method returns a list of elements in the array. This method is an alias to the I method. =item B This method returns a flattened list of elements in the array. Will flatten arrays contained within the root array recursively - depth is controlled by the optional $level parameter. =back =head1 SEE ALSO =over 4 =item * L =item * L =back =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/String.pm0000644000175000017500000000166212353141421016007 0ustar mmpmmppackage Data::Perl::String; $Data::Perl::String::VERSION = '0.002009'; # ABSTRACT: Wrapping class for Perl scalar strings. use strictures 1; use Role::Tiny::With; with 'Data::Perl::Role::String'; 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::String - Wrapping class for Perl scalar strings. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/string/; my $string = string("foo\n"); $string->chomp; # returns 1, $string == "foo" =head1 DESCRIPTION This class is a simple consumer of the L role, which provides all functionality. You probably want to look there instead. =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/Number.pm0000644000175000017500000000166712353141421015776 0ustar mmpmmppackage Data::Perl::Number; $Data::Perl::Number::VERSION = '0.002009'; # ABSTRACT: Wrapping class for Perl scalar numbers. use strictures 1; use Role::Tiny::With; with 'Data::Perl::Role::Number'; 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Number - Wrapping class for Perl scalar numbers. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/number/; my $num = number(123); $num->add(5); # $num == 128 $num->div(2); # $num == 64 =head1 DESCRIPTION This class is a simple consumer of the L role, which provides all functionality. You probably want to look there instead. =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/Collection/0000755000175000017500000000000012353141421016271 5ustar mmpmmpData-Perl-0.002009/lib/Data/Perl/Collection/Hash.pm0000644000175000017500000000207112353141421017512 0ustar mmpmmp package Data::Perl::Collection::Hash; $Data::Perl::Collection::Hash::VERSION = '0.002009'; # ABSTRACT: Wrapping class for Perl's built in hash structure. use strictures 1; use Role::Tiny::With; with 'Data::Perl::Role::Collection::Hash'; 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Collection::Hash - Wrapping class for Perl's built in hash structure. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/hash/; my $hash = hash(a => 1, b => 2); $array->push(5); $hash->values; # (1, 2) $hash->set('foo', 'bar'); # (a => 1, b => 2, foo => 'bar') =head1 DESCRIPTION This class is a simple consumer of the L role, which provides all functionality. You probably want to look there instead. =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/lib/Data/Perl/Collection/Array.pm0000644000175000017500000000205412353141421017706 0ustar mmpmmppackage Data::Perl::Collection::Array; $Data::Perl::Collection::Array::VERSION = '0.002009'; # ABSTRACT: Wrapping class for Perl's built in array structure. use strictures 1; use Role::Tiny::With; with 'Data::Perl::Role::Collection::Array'; 1; =pod =encoding UTF-8 =head1 NAME Data::Perl::Collection::Array - Wrapping class for Perl's built in array structure. =head1 VERSION version 0.002009 =head1 SYNOPSIS use Data::Perl qw/array/; my $array = array(1, 2, 3); $array->push(5); $array->grep(sub { $_ > 2 })->map(sub { $_ ** 2 })->elements; # (3, 5); =head1 DESCRIPTION This class is a simple consumer of the L role, which provides all functionality. You probably want to look there instead. =head1 AUTHOR Matthew Phillips =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __END__ ==pod Data-Perl-0.002009/META.json0000644000175000017500000000316312353141421013301 0ustar mmpmmp{ "abstract" : "Base classes wrapping fundamental Perl data types.", "author" : [ "Matthew Phillips " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.019, CPAN::Meta::Converter version 2.141520", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Data-Perl", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "requires" : { "Class::Method::Modifiers" : "0", "List::MoreUtils" : "0", "List::Util" : "0", "Module::Runtime" : "0", "Role::Tiny" : "0", "Scalar::Util" : "0", "parent" : "0", "strictures" : "0" } }, "test" : { "requires" : { "Test::Deep" : "0", "Test::Fatal" : "0", "Test::Output" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/mattp-/Data-Perl/issues" }, "homepage" : "https://github.com/mattp-/Data-Perl", "repository" : { "type" : "git", "url" : "https://github.com/mattp-/Data-Perl.git", "web" : "https://github.com/mattp-/Data-Perl" } }, "version" : "0.002009" } Data-Perl-0.002009/MANIFEST0000644000175000017500000000137512353141421013014 0ustar mmpmmp# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.019. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README README.mkdn dist.ini lib/Data/Perl.pm lib/Data/Perl/Bool.pm lib/Data/Perl/Code.pm lib/Data/Perl/Collection/Array.pm lib/Data/Perl/Collection/Hash.pm lib/Data/Perl/Counter.pm lib/Data/Perl/Number.pm lib/Data/Perl/Role/Bool.pm lib/Data/Perl/Role/Code.pm lib/Data/Perl/Role/Collection/Array.pm lib/Data/Perl/Role/Collection/Hash.pm lib/Data/Perl/Role/Counter.pm lib/Data/Perl/Role/Number.pm lib/Data/Perl/Role/String.pm lib/Data/Perl/String.pm t/bool.t t/code.t t/collection/array.t t/collection/hash.t t/collection/subclassing.t t/counter.t t/helpers.t t/number.t t/release-pod-coverage.t t/release-pod-syntax.t t/string.t Data-Perl-0.002009/Changes0000644000175000017500000000334012353141421013150 0ustar mmpmmp0.002009 2014-06-26 21:04:12EDT-0400 America/Toronto - fixes pod test failures. thanks gregor herrmann / Debian perl team! 0.002008 2014-06-25 11:37:43EDT-0400 America/Toronto 0.002007 2013-05-19 22:22:25 America/Toronto - fixes another hash-ordering dependency failure. no lib change 0.002006 2013-03-15 13:19:36 EST5EDT - fixes hash-ordering dependency test failure/bug on new (5.17+) perls 0.002005 2013-03-01 22:01:14 America/Toronto - modification to API alpha unstability warning. Removes guarantee on Moose native trait compatibility. - adds parent as dep for older (<=5.10 perls) 0.002003 2013-02-25 12:21:48 EST5EDT - fixes improperly specified requirements in meta, updated dist.ini to fix 0.002002 2013-02-25 10:00:23 EST5EDT - adds missing Module::Runtime dep to dist.ini/build_requires 0.002001 2013-02-22 18:18:01 EST5EDT 0.002000 2013-02-22 18:13:38 EST5EDT - Make it easier to subclass the collection classes (@tobyink) - all logic has been moved to Data::Perl::Role roles via Role::Tiny for code easier reuse. 0.001005 2013-02-07 10:03:48 EST5EDT - adds missed changelog entries for 0.001004 release. 0.001004 2013-02-06 18:17:44 EST5EDT - method chaining introduced as default functionality with Array and Hash collection classes. For old behavior, Collection::Hash::AutoFlatten and Collection::Array::AutoFlatten subclasses are provided. - bugfixes and test suite work 0.001003 2013-01-25 20:26:52 America/Toronto - added other missing dependencies. 0.001002 2013-01-25 16:11:38 EST5EDT - fixes ugly POD typo in Data::Perl 0.001001 2013-01-25 13:22:36 EST5EDT - adds missing dependencies on strictures. 0.001000 2013-01-18 17:17:05 EST5EDT - Initial drop to cpan. Data-Perl-0.002009/dist.ini0000644000175000017500000000141012353141421013315 0ustar mmpmmpname = Data-Perl author = Matthew Phillips license = Perl_5 copyright_holder = Matthew Phillips version = 0.002009 [@Basic] [MetaJSON] [NextRelease] [@Git] allow_dirty = Changes allow_dirty = dist.ini allow_dirty = README.mkdn add_files_in = Changes add_files_in = dist.ini add_files_in = README.mkdn [PodWeaver] [GithubMeta] issues = 1 [CheckChangeLog] [PkgVersion] [ReadmeFromPod] [ReadmeMarkdownFromPod] [PodCoverageTests] [PodSyntaxTests] [Prereqs / RuntimeRequires] strictures = 0 Scalar::Util = 0 List::Util = 0 List::MoreUtils = 0 Role::Tiny = 0 Class::Method::Modifiers = 0 Module::Runtime = 0 parent = 0 [Prereqs / TestRequires] Test::Output = 0 Test::Fatal = 0 Test::Deep = 0 [Run::BeforeRelease] run = cp %d%pREADME.mkdn . Data-Perl-0.002009/LICENSE0000644000175000017500000004375212353141421012675 0ustar mmpmmpThis software is copyright (c) 2014 by Matthew Phillips . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2014 by Matthew Phillips . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2014 by Matthew Phillips . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End