line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Wrap::Smart::XS; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
348972
|
use strict; |
|
5
|
|
|
|
|
46
|
|
|
5
|
|
|
|
|
143
|
|
4
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
141
|
|
5
|
5
|
|
|
5
|
|
29
|
use base qw(Exporter); |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
803
|
|
6
|
5
|
|
|
5
|
|
2311
|
use boolean qw(true); |
|
5
|
|
|
|
|
17002
|
|
|
5
|
|
|
|
|
21
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
354
|
use Carp qw(croak); |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
211
|
|
9
|
5
|
|
|
5
|
|
2786
|
use Params::Validate ':all'; |
|
5
|
|
|
|
|
46945
|
|
|
5
|
|
|
|
|
1325
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our ($VERSION, @EXPORT_OK, %EXPORT_TAGS, @subs); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$VERSION = '0.08'; |
14
|
|
|
|
|
|
|
@subs = qw(exact_wrap fuzzy_wrap); |
15
|
|
|
|
|
|
|
@EXPORT_OK = @subs; |
16
|
|
|
|
|
|
|
%EXPORT_TAGS = ('all' => [ @subs ]); |
17
|
|
|
|
|
|
|
|
18
|
5
|
|
|
5
|
|
40
|
use constant WRAP_AT_DEFAULT => 160; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
1623
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
validation_options( |
21
|
|
|
|
|
|
|
on_fail => sub |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
my ($error) = @_; |
24
|
|
|
|
|
|
|
chomp $error; |
25
|
|
|
|
|
|
|
croak $error; |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
stack_skip => 2, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub exact_wrap |
31
|
|
|
|
|
|
|
{ |
32
|
10
|
|
|
10
|
1
|
4962
|
_validate(@_); |
33
|
10
|
|
|
|
|
590
|
my ($text, $wrap_at) = @_; |
34
|
|
|
|
|
|
|
|
35
|
10
|
|
100
|
|
|
43
|
$wrap_at ||= WRAP_AT_DEFAULT; |
36
|
|
|
|
|
|
|
|
37
|
10
|
|
|
|
|
107
|
return xs_exact_wrap($text, $wrap_at); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub fuzzy_wrap |
41
|
|
|
|
|
|
|
{ |
42
|
68
|
|
|
68
|
1
|
75321
|
_validate(@_); |
43
|
68
|
|
|
|
|
2480
|
my ($text, $wrap_at) = @_; |
44
|
|
|
|
|
|
|
|
45
|
68
|
|
100
|
|
|
227
|
$wrap_at ||= WRAP_AT_DEFAULT; |
46
|
|
|
|
|
|
|
|
47
|
68
|
|
|
|
|
726
|
return xs_fuzzy_wrap($text, $wrap_at); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _validate |
51
|
|
|
|
|
|
|
{ |
52
|
78
|
|
|
78
|
|
358
|
validate_pos(@_, |
53
|
|
|
|
|
|
|
{ type => SCALAR }, |
54
|
|
|
|
|
|
|
{ type => SCALAR, optional => true, regex => qr/^\d+$/ }, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
require XSLoader; |
59
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
__END__ |