line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rubyish; |
2
|
16
|
|
|
16
|
|
146184
|
use 5.010; |
|
16
|
|
|
|
|
56
|
|
|
16
|
|
|
|
|
895
|
|
3
|
|
|
|
|
|
|
our $VERSION = "0.32"; |
4
|
|
|
|
|
|
|
|
5
|
16
|
|
|
16
|
|
162
|
use strict; |
|
16
|
|
|
|
|
26
|
|
|
16
|
|
|
|
|
1604
|
|
6
|
16
|
|
|
16
|
|
158
|
use warnings; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
3614
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my @SPECIAL_WORD = qw(def); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub import { |
11
|
18
|
|
|
18
|
|
1029
|
my ($class, @args) = @_; |
12
|
18
|
|
|
|
|
49
|
my $caller = caller; |
13
|
18
|
100
|
|
|
|
91
|
if($caller eq "main") { |
14
|
9
|
|
|
9
|
|
5470
|
eval qq{ |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
10
|
|
|
|
|
607
|
|
15
|
|
|
|
|
|
|
package $caller; |
16
|
|
|
|
|
|
|
use Rubyish::Kernel; |
17
|
|
|
|
|
|
|
use Rubyish::Syntax::class; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
else { |
22
|
9
|
|
|
8
|
|
743
|
eval qq{ |
|
7
|
|
|
1
|
|
44
|
|
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
5434
|
|
23
|
|
|
|
|
|
|
package $caller; |
24
|
|
|
|
|
|
|
use base 'Rubyish::Object'; |
25
|
|
|
|
|
|
|
use Rubyish::Attribute; |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
} |
28
|
16
|
|
|
16
|
|
168
|
eval qq{ |
|
16
|
|
|
16
|
|
28
|
|
|
16
|
|
|
|
|
102
|
|
|
16
|
|
|
|
|
18633
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
18
|
|
|
|
|
22014
|
|
29
|
|
|
|
|
|
|
package $caller; |
30
|
|
|
|
|
|
|
use Rubyish::Syntax::def; |
31
|
|
|
|
|
|
|
use Rubyish::Syntax::nil; |
32
|
|
|
|
|
|
|
use Rubyish::Syntax::true; |
33
|
|
|
|
|
|
|
use Rubyish::String; |
34
|
|
|
|
|
|
|
use Rubyish::Array; |
35
|
|
|
|
|
|
|
use Rubyish::Hash; |
36
|
|
|
|
|
|
|
use Rubyish::Dir; |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
18
|
|
|
|
|
10825
|
require Rubyish::Autobox; |
40
|
17
|
|
|
|
|
114
|
Rubyish::Autobox::import($caller); |
41
|
|
|
|
|
|
|
}; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Rubyish - Perl programming, the rubyish way. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 SYNOPSIS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Define a Cat class; |
52
|
|
|
|
|
|
|
package Cat; |
53
|
|
|
|
|
|
|
use Rubyish; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
attr_accessor "name", "color"; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
def sound { "meow, meow" } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
def speak { |
60
|
|
|
|
|
|
|
print "A cat goes " . $self->sound . "\n"; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
### |
64
|
|
|
|
|
|
|
package main; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $pet = Cat->new->name("oreo"); |
67
|
|
|
|
|
|
|
$cat->speak; #=> "A cat goes meow, meow" |
68
|
|
|
|
|
|
|
$cat->name; #=> "oreo" |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Rubyish provides a way to let you write perl programs that look like |
73
|
|
|
|
|
|
|
ruby. You can use it to write Classes, or just executable programs. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
As you can see in the synopsis, you can use C to define instance |
76
|
|
|
|
|
|
|
methods of your classes. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 Classes |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=over 4 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item L |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item L |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item L |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item L |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item L |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item L |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item L |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item L |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item L |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHOR |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Kang-min Liu C<< >>, shelling C |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 LICENCE AND COPYRIGHT |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Copyright (c) 2008,2009, Kang-min Liu C<< >>. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is free software, licensed under: |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
The MIT (X11) License |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
117
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
118
|
|
|
|
|
|
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
119
|
|
|
|
|
|
|
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
120
|
|
|
|
|
|
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
121
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
122
|
|
|
|
|
|
|
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
123
|
|
|
|
|
|
|
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
124
|
|
|
|
|
|
|
NECESSARY SERVICING, REPAIR, OR CORRECTION. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
127
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
128
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE |
129
|
|
|
|
|
|
|
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
130
|
|
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
131
|
|
|
|
|
|
|
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
132
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
133
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
134
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
135
|
|
|
|
|
|
|
SUCH DAMAGES. |