line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: String Object for Perl 5 |
2
|
|
|
|
|
|
|
package Data::Object::String; |
3
|
|
|
|
|
|
|
|
4
|
49
|
|
|
49
|
|
28313
|
use 5.010; |
|
49
|
|
|
|
|
161
|
|
5
|
|
|
|
|
|
|
|
6
|
49
|
|
|
49
|
|
250
|
use Scalar::Util 'blessed'; |
|
49
|
|
|
|
|
94
|
|
|
49
|
|
|
|
|
3098
|
|
7
|
49
|
|
|
49
|
|
16191
|
use Data::Object 'deduce_deep', 'detract_deep', 'throw'; |
|
49
|
|
|
|
|
110
|
|
|
49
|
|
|
|
|
3294
|
|
8
|
49
|
|
|
49
|
|
15314
|
use Data::Object::Class 'with'; |
|
49
|
|
|
|
|
126
|
|
|
49
|
|
|
|
|
477
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Data::Object::Role::String'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use overload ( |
13
|
49
|
|
|
|
|
511
|
'bool' => 'data', |
14
|
|
|
|
|
|
|
'""' => 'data', |
15
|
|
|
|
|
|
|
'~~' => 'data', |
16
|
|
|
|
|
|
|
fallback => 1, |
17
|
49
|
|
|
49
|
|
54230
|
); |
|
49
|
|
|
|
|
96
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.42'; # VERSION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
172
|
|
|
172
|
0
|
46397
|
my $class = shift; |
23
|
172
|
|
|
|
|
313
|
my $args = shift; |
24
|
172
|
|
|
|
|
262
|
my $role = 'Data::Object::Role::Type'; |
25
|
|
|
|
|
|
|
|
26
|
172
|
0
|
33
|
|
|
1050
|
$args = $args->data if blessed($args) |
|
|
|
33
|
|
|
|
|
27
|
|
|
|
|
|
|
and $args->can('does') |
28
|
|
|
|
|
|
|
and $args->does($role); |
29
|
|
|
|
|
|
|
|
30
|
172
|
50
|
33
|
|
|
1056
|
throw 'Type Instantiation Error: Not a String' |
31
|
|
|
|
|
|
|
unless defined($args) && not ref($args); |
32
|
|
|
|
|
|
|
|
33
|
172
|
|
|
|
|
1149
|
return bless \$args, $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
around 'append' => sub { |
37
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
38
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
39
|
|
|
|
|
|
|
return $self; |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
around 'camelcase' => sub { |
43
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
44
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
45
|
|
|
|
|
|
|
return $self; |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
around 'chomp' => sub { |
49
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
50
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
51
|
|
|
|
|
|
|
return $self; |
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
around 'chop' => sub { |
55
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
56
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
57
|
|
|
|
|
|
|
return $self; |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
around 'concat' => sub { |
61
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
62
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
63
|
|
|
|
|
|
|
return $self; |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
around 'contains' => sub { |
67
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
68
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
69
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
70
|
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub data { |
73
|
189
|
|
|
189
|
0
|
32123
|
goto &detract; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub detract { |
77
|
190
|
|
|
190
|
0
|
604
|
return detract_deep shift; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
around 'hex' => sub { |
81
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
82
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
83
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
84
|
|
|
|
|
|
|
}; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
around 'index' => sub { |
87
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
88
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
89
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
90
|
|
|
|
|
|
|
}; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
around 'lc' => sub { |
93
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
94
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
95
|
|
|
|
|
|
|
return $self; |
96
|
|
|
|
|
|
|
}; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
around 'lcfirst' => sub { |
99
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
100
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
101
|
|
|
|
|
|
|
return $self; |
102
|
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
around 'length' => sub { |
105
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
106
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
107
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
108
|
|
|
|
|
|
|
}; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
around 'lines' => sub { |
111
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
112
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
113
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
114
|
|
|
|
|
|
|
}; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
around 'lowercase' => sub { |
117
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
118
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
119
|
|
|
|
|
|
|
return $self; |
120
|
|
|
|
|
|
|
}; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
around 'replace' => sub { |
123
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
124
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
125
|
|
|
|
|
|
|
return $self; |
126
|
|
|
|
|
|
|
}; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
around 'reverse' => sub { |
129
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
130
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
131
|
|
|
|
|
|
|
return $self; |
132
|
|
|
|
|
|
|
}; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
around 'rindex' => sub { |
135
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
136
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
137
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
138
|
|
|
|
|
|
|
}; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
around 'snakecase' => sub { |
141
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
142
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
143
|
|
|
|
|
|
|
return $self; |
144
|
|
|
|
|
|
|
}; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
around 'split' => sub { |
147
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
148
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
149
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
150
|
|
|
|
|
|
|
}; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
around 'strip' => sub { |
153
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
154
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
155
|
|
|
|
|
|
|
return $self; |
156
|
|
|
|
|
|
|
}; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
around 'titlecase' => sub { |
159
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
160
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
161
|
|
|
|
|
|
|
return $self; |
162
|
|
|
|
|
|
|
}; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
around 'trim' => sub { |
165
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
166
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
167
|
|
|
|
|
|
|
return $self; |
168
|
|
|
|
|
|
|
}; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
around 'uc' => sub { |
171
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
172
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
173
|
|
|
|
|
|
|
return $self; |
174
|
|
|
|
|
|
|
}; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
around 'ucfirst' => sub { |
177
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
178
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
179
|
|
|
|
|
|
|
return $self; |
180
|
|
|
|
|
|
|
}; |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
around 'uppercase' => sub { |
183
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
184
|
|
|
|
|
|
|
$$self = $self->$orig(@args); |
185
|
|
|
|
|
|
|
return $self; |
186
|
|
|
|
|
|
|
}; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
around 'words' => sub { |
189
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
190
|
|
|
|
|
|
|
my $result = $self->$orig(@args); |
191
|
|
|
|
|
|
|
return scalar deduce_deep $result; |
192
|
|
|
|
|
|
|
}; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
1; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
__END__ |