line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::AttributeHelpers::MethodProvider::String; |
2
|
22
|
|
|
22
|
|
91
|
use Moose::Role; |
|
22
|
|
|
|
|
31
|
|
|
22
|
|
|
|
|
116
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.25'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub append : method { |
7
|
4
|
|
|
4
|
1
|
18
|
my ($attr, $reader, $writer) = @_; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
21
|
return sub { $writer->( $_[0], $reader->($_[0]) . $_[1] ) }; |
|
4
|
|
|
12
|
|
957
|
|
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub prepend : method { |
13
|
2
|
|
|
2
|
1
|
11
|
my ($attr, $reader, $writer) = @_; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
20
|
return sub { $writer->( $_[0], $_[1] . $reader->($_[0]) ) }; |
|
2
|
|
|
|
|
1013
|
|
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub replace : method { |
19
|
4
|
|
|
6
|
1
|
20
|
my ($attr, $reader, $writer) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
return sub { |
22
|
4
|
|
|
4
|
|
981
|
my ( $self, $regex, $replacement ) = @_; |
23
|
4
|
|
|
|
|
18
|
my $v = $reader->($_[0]); |
24
|
|
|
|
|
|
|
|
25
|
4
|
50
|
50
|
|
|
100
|
if ( (ref($replacement)||'') eq 'CODE' ) { |
26
|
4
|
|
|
|
|
21
|
$v =~ s/$regex/$replacement->()/e; |
|
4
|
|
|
|
|
10
|
|
27
|
|
|
|
|
|
|
} else { |
28
|
0
|
|
|
|
|
0
|
$v =~ s/$regex/$replacement/; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
27
|
$writer->( $_[0], $v); |
32
|
4
|
|
|
|
|
30
|
}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub match : method { |
36
|
4
|
|
|
8
|
1
|
16
|
my ($attr, $reader, $writer) = @_; |
37
|
4
|
|
|
6
|
|
19
|
return sub { $reader->($_[0]) =~ $_[1] }; |
|
6
|
|
|
|
|
502
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub chop : method { |
41
|
2
|
|
|
8
|
1
|
13
|
my ($attr, $reader, $writer) = @_; |
42
|
|
|
|
|
|
|
return sub { |
43
|
2
|
|
|
2
|
|
958
|
my $v = $reader->($_[0]); |
44
|
2
|
|
|
|
|
48
|
CORE::chop($v); |
45
|
2
|
|
|
|
|
6
|
$writer->( $_[0], $v); |
46
|
2
|
|
|
|
|
25
|
}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub chomp : method { |
50
|
2
|
|
|
4
|
1
|
13
|
my ($attr, $reader, $writer) = @_; |
51
|
|
|
|
|
|
|
return sub { |
52
|
4
|
|
|
4
|
|
1972
|
my $v = $reader->($_[0]); |
53
|
4
|
|
|
|
|
98
|
chomp($v); |
54
|
4
|
|
|
|
|
12
|
$writer->( $_[0], $v); |
55
|
2
|
|
|
|
|
12
|
}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub inc : method { |
59
|
2
|
|
|
6
|
1
|
12
|
my ($attr, $reader, $writer) = @_; |
60
|
|
|
|
|
|
|
return sub { |
61
|
4
|
|
|
4
|
|
930
|
my $v = $reader->($_[0]); |
62
|
4
|
|
|
|
|
105
|
$v++; |
63
|
4
|
|
|
|
|
13
|
$writer->( $_[0], $v); |
64
|
2
|
|
|
|
|
11
|
}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub clear : method { |
68
|
2
|
|
|
6
|
1
|
10
|
my ($attr, $reader, $writer) = @_; |
69
|
2
|
|
|
2
|
|
589
|
return sub { $writer->( $_[0], '' ) } |
70
|
2
|
|
|
|
|
10
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub length : method { |
73
|
2
|
|
|
4
|
1
|
10
|
my ($attr, $reader, $writer) = @_; |
74
|
|
|
|
|
|
|
return sub { |
75
|
6
|
|
|
6
|
|
4728
|
my $v = $reader->($_[0]); |
76
|
6
|
|
|
|
|
157
|
return CORE::length($v); |
77
|
2
|
|
|
|
|
13
|
}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub substr : method { |
81
|
4
|
|
|
10
|
1
|
16
|
my ($attr, $reader, $writer) = @_; |
82
|
|
|
|
|
|
|
return sub { |
83
|
8
|
|
|
8
|
|
930
|
my $self = shift; |
84
|
8
|
|
|
|
|
30
|
my $v = $reader->($self); |
85
|
|
|
|
|
|
|
|
86
|
8
|
50
|
|
|
|
204
|
my $offset = defined $_[0] ? shift : 0; |
87
|
8
|
100
|
|
|
|
16
|
my $length = defined $_[0] ? shift : CORE::length($v); |
88
|
8
|
100
|
|
|
|
13
|
my $replacement = defined $_[0] ? shift : undef; |
89
|
|
|
|
|
|
|
|
90
|
8
|
|
|
|
|
7
|
my $ret; |
91
|
8
|
100
|
|
|
|
14
|
if (defined $replacement) { |
92
|
4
|
|
|
|
|
36
|
$ret = CORE::substr($v, $offset, $length, $replacement); |
93
|
4
|
|
|
|
|
13
|
$writer->($self, $v); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
else { |
96
|
4
|
|
|
|
|
9
|
$ret = CORE::substr($v, $offset, $length); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
8
|
|
|
|
|
122
|
return $ret; |
100
|
4
|
|
|
|
|
20
|
}; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=pod |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=encoding UTF-8 |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 NAME |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
MooseX::AttributeHelpers::MethodProvider::String |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 VERSION |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
version 0.25 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 DESCRIPTION |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This is a role which provides the method generators for |
122
|
|
|
|
|
|
|
L<MooseX::AttributeHelpers::String>. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 METHODS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over 4 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item B<meta> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 PROVIDED METHODS |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over 4 |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item B<append> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item B<prepend> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item B<replace> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item B<match> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item B<chomp> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item B<chop> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item B<inc> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item B<clear> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item B<length> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item B<substr> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=back |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 SUPPORT |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-AttributeHelpers> |
161
|
|
|
|
|
|
|
(or L<bug-MooseX-AttributeHelpers@rt.cpan.org|mailto:bug-MooseX-AttributeHelpers@rt.cpan.org>). |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
164
|
|
|
|
|
|
|
L<http://lists.perl.org/list/moose.html>. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
167
|
|
|
|
|
|
|
L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 AUTHOR |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Stevan Little <stevan@iinteractive.com> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Stevan Little and Infinity Interactive, Inc. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
178
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |