File Coverage

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


line stmt bran cond sub pod time code
1             package Data::Perl;
2             $Data::Perl::VERSION = '0.002011';
3             # ABSTRACT: Base classes wrapping fundamental Perl data types.
4              
5             BEGIN {
6 9     9   540383 require Exporter;
7 9         333 our @ISA = qw(Exporter);
8 9         362 our @EXPORT = qw(hash array counter string code bool number);
9             }
10              
11 9     9   4314 use strictures 1;
  9         14602  
  9         386  
12              
13 9     9   4542 use Data::Perl::Collection::Array;
  9         30  
  9         279  
14 9     9   4224 use Data::Perl::Collection::Hash;
  9         21  
  9         300  
15 9     9   3763 use Data::Perl::Code;
  9         25  
  9         245  
16 9     9   3485 use Data::Perl::Number;
  9         22  
  9         240  
17 9     9   3582 use Data::Perl::Bool;
  9         20  
  9         248  
18 9     9   3748 use Data::Perl::String;
  9         22  
  9         247  
19 9     9   4050 use Data::Perl::Counter;
  9         22  
  9         1921  
20              
21 49     49 1 5662 sub array { Data::Perl::Collection::Array->new(@_) }
22              
23 15     15 1 3314 sub hash { Data::Perl::Collection::Hash->new(@_) }
24              
25 5   100 1 1 937 sub code { Data::Perl::Code->new(shift||sub {}) }
        5      
26              
27 4   100 4 1 1046 sub number { Data::Perl::Number->new(shift||0) }
28              
29 4   100 4 1 1205 sub bool { Data::Perl::Bool->new(shift||0) }
30              
31 9   100 9 1 2404 sub string { Data::Perl::String->new(shift||'') }
32              
33 5   100 5 1 1585 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.002011
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 MAINTAINER
168              
169             Toby Inkster since version 0.002010.
170              
171             =head1 CONTRIBUTORS
172              
173             =for stopwords Graham Knop Jon Portnoy kristof.pap@gmail.com Matt Phillips Toby Inkster
174              
175             =over 4
176              
177             =item *
178              
179             Graham Knop
180              
181             =item *
182              
183             Jon Portnoy
184              
185             =item *
186              
187             kristof.pap@gmail.com
188              
189             =item *
190              
191             Matt Phillips
192              
193             =item *
194              
195             Toby Inkster
196              
197             =back
198              
199             =head1 COPYRIGHT AND LICENSE
200              
201             This software is copyright (c) 2020 by Matthew Phillips .
202              
203             This is free software; you can redistribute it and/or modify it under
204             the same terms as the Perl 5 programming language system itself.
205              
206             =cut
207              
208             __END__