line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Wrap::Smart::XS; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
364818
|
use strict; |
|
5
|
|
|
|
|
47
|
|
|
5
|
|
|
|
|
156
|
|
4
|
5
|
|
|
5
|
|
27
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
150
|
|
5
|
5
|
|
|
5
|
|
31
|
use base qw(Exporter); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
846
|
|
6
|
5
|
|
|
5
|
|
2584
|
use boolean qw(true); |
|
5
|
|
|
|
|
17086
|
|
|
5
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
416
|
use Carp qw(croak); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
234
|
|
9
|
5
|
|
|
5
|
|
3039
|
use Params::Validate ':all'; |
|
5
|
|
|
|
|
50291
|
|
|
5
|
|
|
|
|
1370
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our ($VERSION, @EXPORT_OK, %EXPORT_TAGS, @subs); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$VERSION = '0.07'; |
14
|
|
|
|
|
|
|
@subs = qw(exact_wrap fuzzy_wrap); |
15
|
|
|
|
|
|
|
@EXPORT_OK = @subs; |
16
|
|
|
|
|
|
|
%EXPORT_TAGS = ('all' => [ @subs ]); |
17
|
|
|
|
|
|
|
|
18
|
5
|
|
|
5
|
|
43
|
use constant WRAP_AT_DEFAULT => 160; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
1683
|
|
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
|
4991
|
_validate(@_); |
33
|
10
|
|
|
|
|
505
|
my ($text, $wrap_at) = @_; |
34
|
|
|
|
|
|
|
|
35
|
10
|
|
100
|
|
|
37
|
$wrap_at ||= WRAP_AT_DEFAULT; |
36
|
|
|
|
|
|
|
|
37
|
10
|
|
|
|
|
79
|
return xs_exact_wrap($text, $wrap_at); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub fuzzy_wrap |
41
|
|
|
|
|
|
|
{ |
42
|
68
|
|
|
68
|
1
|
72581
|
_validate(@_); |
43
|
68
|
|
|
|
|
2507
|
my ($text, $wrap_at) = @_; |
44
|
|
|
|
|
|
|
|
45
|
68
|
|
100
|
|
|
229
|
$wrap_at ||= WRAP_AT_DEFAULT; |
46
|
|
|
|
|
|
|
|
47
|
68
|
|
|
|
|
798
|
return xs_fuzzy_wrap($text, $wrap_at); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _validate |
51
|
|
|
|
|
|
|
{ |
52
|
78
|
|
|
78
|
|
346
|
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__ |