File Coverage

blib/lib/Rubyish/Kernel.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             =head1
2              
3             Rubyish::Kernel - Kernel (module)
4              
5             =cut
6              
7             package Rubyish::Kernel;
8 17     17   86 use strict;
  17         28  
  17         550  
9 17     17   9371 use Rubyish::Hash;
  0            
  0            
10             use Rubyish::Array;
11             use Rubyish::String;
12              
13             use Sub::Exporter;
14             Sub::Exporter::setup_exporter({
15             exports => [qw(Array String Hash puts)],
16             groups => { default => [qw(Array String Hash puts)] },
17             });
18              
19             sub String {
20             Rubyish::String->new($_[0]);
21             }
22              
23             sub Array {
24             Rubyish::Array->new($_[0]);
25             }
26              
27             sub Hash {
28             Rubyish::Hash->new($_[0]);
29             }
30              
31             sub puts {
32             print map { ref($_) =~ /Rubyish/ ? $_->inspect : $_ } @_;
33             print "\n";
34             }
35              
36             1;
37              
38             =head1 NAME
39              
40             Rubyish::Kernel - The Kernel implementation
41              
42             =head1 SYNOPSIS
43              
44             use Rubyish::Kernel;
45              
46             my $arr = Array[1..3];
47              
48             puts "Hello world";
49              
50             =head1 DESCRIPTION
51              
52             This module exports several convienent sub-routines to make your
53             program looks rubyish. Several of them might be re-organized into a
54             more proper place.
55              
56             =over 4
57              
58             =item puts
59              
60             The C in ruby.
61              
62             =item Array
63              
64             The C constructor. The standard usage is like:
65              
66             my $arr1 = Array[1..3];
67             my $arr2 = Array[qw(a b c)];
68              
69             =item Hash
70              
71             The C constructor. The standard usage is like:
72              
73             my $h = Hash({ a => 1, b => 2 });
74              
75             $h->fetch("a"); # returns 1
76              
77             =item String
78              
79             The L constructor. Use it like:
80              
81             my $str1 = String("food");
82             my $str2 = $str1->gsub(qr/oo/, "nor");
83              
84             puts $str2; # "fnord"
85              
86             =back
87              
88             =head1 SEE ALSO
89              
90             L, L, L for the full
91             reference of their instance methods.
92              
93             =head1 AUTHOR
94              
95             Kang-min Liu C<< >>, shelling C
96              
97             =head1 LICENCE AND COPYRIGHT
98              
99             Copyright (c) 2008,2009, Kang-min Liu C<< >>.
100              
101             This is free software, licensed under:
102              
103             The MIT (X11) License
104              
105             =head1 DISCLAIMER OF WARRANTY
106              
107             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
108             FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
109             OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
110             PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
111             EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
112             WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
113             ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
114             YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
115             NECESSARY SERVICING, REPAIR, OR CORRECTION.
116              
117             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
118             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
119             REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
120             LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
121             OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
122             THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
123             RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
124             FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
125             SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
126             SUCH DAMAGES.