File Coverage

blib/lib/Data/Perl.pm
Criterion Covered Total %
statement 35 35 100.0
branch n/a
condition 10 10 100.0
subroutine 17 17 100.0
pod 7 7 100.0
total 69 69 100.0


line stmt bran cond sub pod time code
1             package Data::Perl;
2             $Data::Perl::VERSION = '0.002009';
3             # ABSTRACT: Base classes wrapping fundamental Perl data types.
4              
5             BEGIN {
6 9     9   257964 require Exporter;
7 9         148 our @ISA = qw(Exporter);
8 9         335 our @EXPORT = qw(hash array counter string code bool number);
9             }
10              
11 9     9   10097 use strictures 1;
  9         9538  
  9         618  
12              
13 9     9   6651 use Data::Perl::Collection::Array;
  9         39  
  9         267  
14 9     9   8414 use Data::Perl::Collection::Hash;
  9         36  
  9         277  
15 9     9   12508 use Data::Perl::Code;
  9         28  
  9         436  
16 9     9   5656 use Data::Perl::Number;
  9         28  
  9         244  
17 9     9   5404 use Data::Perl::Bool;
  9         26  
  9         220  
18 9     9   5737 use Data::Perl::String;
  9         30  
  9         246  
19 9     9   5295 use Data::Perl::Counter;
  9         28  
  9         2443  
20              
21 48     48 1 5352 sub array { Data::Perl::Collection::Array->new(@_) }
22              
23 15     15 1 3957 sub hash { Data::Perl::Collection::Hash->new(@_) }
24              
25 1   100 1 1 4 sub code { Data::Perl::Code->new(shift||sub {}) }
  5     5   1043  
26              
27 4   100 4 1 960 sub number { Data::Perl::Number->new(shift||0) }
28              
29 4   100 4 1 798 sub bool { Data::Perl::Bool->new(shift||0) }
30              
31 9   100 9 1 1755 sub string { Data::Perl::String->new(shift||'') }
32              
33 5   100 5 1 1763 sub counter { Data::Perl::Counter->new(shift||0) }
34              
35             1;
36              
37             =pod
38              
39             =encoding UTF-8
40              
41             =head1 NAME
42              
43             Data::Perl - Base classes wrapping fundamental Perl data types.
44              
45             =head1 VERSION
46              
47             version 0.002009
48              
49             =head1 SYNOPSIS
50              
51             use Data::Perl;
52              
53             my $array = array(1,2,3, qw/a b c/);
54              
55             $array->count; # 6
56              
57             my @elements = $array->grep(sub {/b/}); # (b)
58              
59             my $hash = hash(a => 1, b => 2);
60              
61             $hash->keys; # ('a', 'b');
62              
63             my $number = number(5);
64              
65             $number->add(10); # 15
66              
67             my $string = string("foo\n");
68              
69             $string->chomp; # return 1, chomps string
70              
71             my $counter = counter();
72              
73             $counter->inc; # counter is now 1
74              
75             my $sub = code(sub { 'foo' });
76              
77             $sub->execute; # returns 'foo'
78              
79             $foo
80              
81             =head1 DESCRIPTION
82              
83             Data::Perl is a collection of classes that wrap fundamental data types that
84             exist in Perl. These classes and methods as they exist today are an attempt to
85             mirror functionality provided by Moose's Native Traits. One important thing to
86             note is all classes currently do no validation on constructor input.
87              
88             Data::Perl is a container class for the following classes:
89              
90             =over 4
91              
92             =item * L
93              
94             =item * L
95              
96             =item * L
97              
98             =item * L
99              
100             =item * L
101              
102             =item * L
103              
104             =item * L
105              
106             =back
107              
108             =head1 ALPHA API
109              
110             The API provided by these modules is as of now considered alpha and undecided.
111             The API B change. If you are writing code that you will not touch again
112             for years, do not use this until this warning is removed.
113              
114             =head1 PROVIDED FUNCTIONS
115              
116             Data::Perl exports helper constructor functions to interface with the above classes:
117              
118             =over 4
119              
120             =item * B
121              
122             Returns a Data::Perl::Collection::Hash object initialized with the optionally passed in key/value args.
123              
124             =item * B
125              
126             Returns a Data::Perl::Collection::Array object initialized with the optionally passed in values.
127              
128             =item * B
129              
130             Returns a Data::Perl::String object initialized with the optionally passed in scalar arg.
131              
132             =item * B
133              
134             Returns a Data::Perl::Number object initialized with the optionally passed in scalar arg.
135              
136             =item * B
137              
138             Returns a Data::Perl::Counter object initialized with the optionally passed in scalar arg.
139              
140             =item * B
141              
142             Returns a Data::Perl::Bool object initialized with the truth value of the passed in scalar arg.
143              
144             =item * B
145              
146             Returns a Data::Perl::Code object initialized with the optionally passed in scalar coderef as an arg.
147              
148             =back
149              
150             =head1 THANKS
151              
152             Much thanks to the L team for their work with native traits, for which
153             much of this work is based.
154              
155             =head1 SEE ALSO
156              
157             =over 4
158              
159             =item * L
160              
161             =back
162              
163             =head1 AUTHOR
164              
165             Matthew Phillips
166              
167             =head1 COPYRIGHT AND LICENSE
168              
169             This software is copyright (c) 2014 by Matthew Phillips .
170              
171             This is free software; you can redistribute it and/or modify it under
172             the same terms as the Perl 5 programming language system itself.
173              
174             =cut
175              
176             __END__